Logo
Digital Openers
Request a Call: +91-9509040731, 8696105555 Working: Monday - Saturday: 9am - 6:30pm
girl
120
blog images

Node.js is one of the most popular technologies nowadays to build scalable and efficent REST API's. It is also used to build hybrid mobile applications, desktop applications and even Internet of Things.

The World Before Node.js

Multi Threaded Server

Web applications were written in a customer/server model where the customer would request assets from the server and the server would react with the assets. The server possibly reacted when the customer mentioned and would close the association after every reaction.

This example is effective on the grounds that each solicitation to the server sets aside time and assets (memory, CPU, and so forth) To go to the following solicitation the server should finish the past one.

Things being what they are, the server goes to one demand at time? Well not actually, when the server gets another solicitation, the solicitation will be handled by a string.

A string in basic words is time and assets the CPU provides for execute a little unit of guidelines. All things considered, the server goes to various demands without a moment's delay, one for each string (additionally called string per-demand model).

blog images

To attend N requests at once, the server needs N threads. If the server gets the N+1 request, then it must wait until any of those N threads is available.

In the Multi Threaded Server example, the server allows up to 4 requests (threads) at once and when it receives the next 3 requests, those requests must wait until any of those 4 threads is available.

A way to solve this limitation is add more resources (memory, CPU cores, etc) to the server but maybe it's not a good idea at all...

Blocking I/O

Assume you are fostering a web-based store and it needs a page where the client can see every one of your items.

The client admittance to http://yourstore.com/items and the server delivers a HTML record with every one of your items from data set. Basic right?

In any case, what happens behind?...

  • At the point when the client admittance to/items a particular strategy or capacity should be executed to go to the solicitation, so a little piece of code (possibly yours or structure's) parses the mentioned url and looks for the right technique or capacity. The string is working. ✔️
  • The strategy or capacity is executed, just as the main lines. The string is working. ✔️
  • Since you are a decent designer, you save all framework signs in a document and obviously, to be certain the course is executing the right strategy/work you log a "Technique X executing!!" string, that is an obstructing I/O activity. The string is pausing. ❌
  • The log is saved and the following lines are being executed. The string is working once more. ✔️
  • It's an ideal opportunity to go to the data set and get all items, a basic inquiry like SELECT * FROM items does the work however prepare to have your mind blown. that is a hindering I/O activity. The string is pausing. ❌
  • You get a cluster or rundown, all things considered, yet to be certain you log them. The string is pausing. ❌
  • With those items it's an ideal opportunity to deliver a layout however before render it you want to peruse it first. The string is pausing. ❌
  • The format motor takes care of it's business and the reaction is shipped off the customer. The string is working once more. ✔️
  • The string is free, similar to a bird. 🕊️
founder

Comments:

girl
girl
girl