Node is a JavaScript runtime environment which executes JavaScript codes outside the browser. It was created in 2009 and has grown it’s popularity in the web development field due to its asynchronous nature in running server side (backend code).

One of the benefits of node is that it is light weight and highly scalable. It differs from other synchronous frameworks out there like ruby on rails, and ASP.NET. Node js is also one of the best choices when it comes to buildimg a suitable backend API for your project. Read more about API’s here. Let’s use a scenario to explain all these concepts of Node for easier understanding.

Let’s use a restaurant in this case, where we have a waiter taking orders from a table. Once the order is taken, the waiter takes the order to the kitchen, which handles the request of the customer at let’s say table 1. Now while the kitchen handles that request, the waiter is free to move to other tables to take in more requests for the kitchen to handle, this simply explains the asynchronous (non blocking) nature.

Node Architecture mind map
Ascynchronous (non blocking) Architecture

From this mini example, we can see that node handles request quite differently from other frameworks. Once a http request is gotten from the client (your browser in this case), the server accepts this request and while the request is still processing, which can take sometime because most of this request involves some database query, it would still be open to take in more http requests from other clients making your app more scalable in the process.

The Synchronous nature of handling http requests

The Synchronous (blocking) nature, which is in contrast with the ascynchronous nature handles http requests quite differently. Let’s use this same restaurant scenario but this time the synchronous version.

Here, the waiter receives the order from table 1, while delivering the order to the kitchen, he remains there till the order has been processed before delivering the order to the table. Now while the waiter waits in the kitchen, he does nothing helpful there which makes him useless till the order is complete, before he can finally take orders from other tables. By then, customers on those tables would have to wait a long time before they get to see a waiter to attend to them which is a bad service.

Well, it won’t be that bad if the restaurant employs multiple waiters to handle different orders. Now let’s get back to the technical explanation of this shall we?

Architecture of the synchronous nature

Once the server receives the http request, no other http requests would be accepted by the server till it’s done handling the current request. This wouldn’t be noticeable because servers are usually powerful machines which handles millions of requests in a second, it wouldn’t be appropriate once your number of users (clients) begins to grow rapidly, rather you would need to purchase extra hardware to handle more requests. It doesn’t offer as much scalability as the ascync nature.

When to use Synchronous and the Ascynchronous frameworks

Even if they both have their advantages and disadvantages, there are benefits when it comes to the kind of application you want to build.

If your application is built to be accommodating alot of users with millions of requests sent per second, then node is the right choice for you. But if you’re building something that requires large file processing like image manipulation or video encoding, rather the synchronous frameworks like ruby on rails would be preferable.

Hope you enjoyed the article, your can follow us on social media to stay updated when ever we upload a new article.

Your favourite software developers. Kudos!


vic okeke

I'm just a web developer hoping to help out junior developers in algorithms for their projects.

2 Comments

VectorWare · February 26, 2022 at 6:51 pm

Very well constructed article. The restaurant was a very helpful illustrative tool.
Please give me an example of a site that requires large file processing for synchronous framework.

    vic okeke · February 26, 2022 at 9:15 pm

    You can take websites like Facebook which compresses your video after uploading

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

%d bloggers like this: