What is Node.js ?
- An open source server environment
- Runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
- Ryan Dahl invented Node. js in 2009.
Why Node.js ?
Because of its single-threaded nature, Node. js is best suited for non-blocking, event-driven servers. It was created with real-time, push-based architectures in mind and is used for traditional web sites and back-end API services.
additionally It uses an event-driven I/O model, which is extremely efficient and allows for the creation of scalable network applications. Node. js is a popular framework for developing real-time applications, the Internet of Things, and microservices, with over a billion downloads.
Because most modern kernels are multi-threaded, they can handle multiple background operations. When one of these operations is finished, the kernel notifies Node.js so that the appropriate callback can be added to the poll queue and executed later. This will be explained in greater detail later in this topic.
Phases of the Event Loop
- Timers: Callbacks scheduled by setTimeout() or setInterval() are executed in this phase.
- Pending Callbacks: I/O callbacks deferred to the next loop iteration are executed here.
- Idle, Prepare: Used internally only.
- Poll: Retrieves new I/O events.
- Check: It invokes setIntermediate() callbacks.
- Close Callbacks: It handles some close callbacks
Advantages of Node.js
- Simple to understand
- More fast deployment
- Improved developer efficiency and overall productivity
- Sharing and reusing code
- It is simple to share knowledge within a team.
Disadvantages of Node.js
- When dealing with Heavy Computing Tasks, performance suffers.
- Because of the unstable API, there have been significant code changes.
- Code that is difficult to maintain
- There is a high demand for experienced NodeJS developers, and there are only a few available.
Global Companies That Use Node.js