0

I want to know if there's many people request URL on a port (exam. 7000) it will handle on a request in a order, right?

And connect to a database through my API server.

So the client post to my API server through URL: Port and then my API sever connect my database and then return data to client though API server by response JSON Format and next it gonna continue do the same right?

So if it’s in a process others request has to wait until it finish a process that I mention above, right?

Alex Kulinkovich
  • 4,408
  • 15
  • 46
  • 50
L Lawliet
  • 13
  • 4

1 Answers1

1

Short Answer

No

Server will not wait for the database operation to complete and therefore keep accepting the other request.

The flow of execution will be as follow:

request ──> make database request
request ──> make database request
request ──> make database request
database request complete ──> send response
database request complete ──> send response
database request complete ──> send response

Read this answer for precise and simple explanation.

This is possible because of following concepts and I recommend you to read about it more to understand how Node.js works

  1. Event Loop
  2. Asynchronous Nature of Node.js
  3. Node.js internally use libuv to handle I/O operation.
Amolpskamble
  • 863
  • 7
  • 12