Transitioning from JavaScript to Node.js
JavaScript developers who initially focused on front-end development may transition to Node.js to become full-stack developers. This enables them to work on both the client side (browser) and server side
As JavaScript developer, we know that the language is client-side, meaning it can run in a browser environment only and access browser APIs such as DOM and web APIs.
What if we want to run javascript outside of a browser (client side)? Can we run javascript in server side like java?
Well the answer is NO. With the help of Node.js, Javascript may now be executed on the server side.
How? Let's explore what node.js is and how you can use it to run JavaScript on the server side.
Node JS
Node JS is itself a runtime environment for executing javascript code outside browser(Client Side) i.e, on server. It uses Chrome’s V8 javascript engine to do that. And it provides additional built-in library for handling various tasks such as file I/O, networking and HTTP operations.
Because of its event-driven, non-blocking I/O architecture, it may be used to create highly concurrent systems and real-time applications.
I know that you require further clarification on the above statement, so let's understand Node.js' architecture.
Node JS Architecture
The "Single Threaded Event Loop" architecture is used by Node.js to manage numerous concurrent clients. The JavaScript callback mechanism and event-based architecture serve as the foundation for the Node.js Processing architecture.
Prior to beginning the workflow Let's define certain terminology that are crucial to comprehending the Node.js workflow.
1. Request
Depending on the actions a user wishes to do within a web application, incoming requests may be blocking (complicated) or non-blocking (simple).
2. Node.js Server
Node.js server receives user requests, processes them, and sends back responses to the users who made the original requests.
3. Event Queue
Event queue store all the Incoming client requests, which then forwards each request individually into the Event Loop.
4. Thread Pool
The thread pool is made up of all the threads that are accessible to do certain tasks that may be necessary in order to satisfy client requests.
5. Event Loop
Event Loop accepts requests continuously, responds to them, and sends the responses to the appropriate clients.
6. External Resources
In order to handle client request blockage, external resources are needed. These resources may be used for data storage, processing, etc.
Now that we have discussed all the essential jargon, let's explore the Node.js workflow.
Comments
Post a Comment