node.js - nodejs single thread? how does it works if there are lots of concurrent requests -


I am new to nodes, I am currently learning this. I know that nodes are single-threaded, though I'm thinking: for example, if I use non-inhibitory method, for example, 20000 concurrent requests, and need to take a request for a long time Other threads take a little time, so once we meet the request for a long time, Nodes will say, "Hello, please stop, need to use another request", whether for a nodezone The Ifolt time, to determine whether it has been halted? Correct me if I use the wrong word "pus" (because I think this is a single thread, so one request should be stopped computing, if another request wants to be processed.) I think that In the situation, then the long-term request is needed to be processed?

Thank you for helping.

It is true that node.js can only be received or respond to a single request at a time Please, however, it can process many requests at the same time.

For example, you can say that you have a node.js app that is the rest of the API, and the result of each request calls the database except the end point C. The remaining API has 3 end points.

End point A: It takes 3 seconds to talk to the database

End point B: takes 2 seconds to talk to the database

Closing Point C: does not talk to the database, it just gives static text.

More than 1 request is not possible to be at the same time.

Now, suppose we have 10 requests at the same time, in this order:

ABCBCACAC

Here's how they You will receive and answer:

  REC: A REC: B REC: C REP: C REC: B REC: C REP: C REC: C RSP: C REC: RE: A RE: BREC: C REP: C / 2 seconds later REP: BREP: B REP: B1 1 second later REP: ARP: ARP: A   

C is always immediately because it does not get any asynchronous work then you get to B, and then all belongs to a much faster because B.

Depending on the database setup however, the sequence of B and A may vary, for example, if it only handles x, question at one time.

If we take an interconnected action that takes 6 seconds, then you will get the result:

ADABC

  RE: A REC: D / 6 6 seconds later ... REP: D REQ: A RE: B REQ: C REP: C2 2 seconds later ... REP: B1 1 second later .. RESP: A RAP: A  

Because D stops all javascript resources, while this is synchronous operation. 1 end point that executes a synchronous action, it is an easy point of failure to stop your AP for any one.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -