- Node Js is a tool to run it as a web server to build a client server application
- Built upon event driven architecture
- By default, the only single thread is responsible to handle the client request, but we can run multiple threads on the same machine to achieve scalability and fault tolerance.
- In order to build an application, we need to use third party web framework like Express, Meteor etc.
Components of NodeJs
libuv: libuv is originally developed to provide asynchronous I/O that includes asynchronous TCP & UDP sockets, (famous) event loop, asynchronous DNS resolution, file system read/write, and etc. libuv is written in C.
Other low level components
c-ares: c-ares is a C library for asynchronous DNS requests (including name resolves)
HTTP parser: This library is used to parse HTTP messages (request and response) which is written in C
OpenSSL: OpenSSL is an open source project that provides a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols.
zlib and many others.
Node.js Binding: a binding basically is a wrapper around a library written in one language and expose the library to codes written in another language so that codes written in different languages can communicate.
Node.js API: Node.js API is an abstraction upon other low level modules and is the interface with built in libraries.
Application: Node.js application code
- a) Suitable for
- Real time web apps (chat or other application in which connection needs to be open)
- If we need to build API’s
- Streaming Application
- An application which depends on I/O bound tasks.
- b) Not suitable for
- CPU intensive task (There is workaround to achieve CPU intensive task)
Pros and Cons
- Asynchronous event driven I/O helps concurrent request handling
- Use a Single Programming Language
- Delivers Improved Performance
- Easy to Scale
- Nested callbacks
- Lack of Robust Libraries