R
R
Rouslan9432021-02-07 18:57:12
Node.js
Rouslan943, 2021-02-07 18:57:12

How does nodejs handle tens of thousands of connections?

I know that Node.js uses a single threaded loop and an event loop to process requests that only process one at a time. But still, how does it work, let's say 7,000 concurrent requests. Will the event loop handle all requests? Won't it take too long?
I can't understand how it can be faster than a multi-threaded webserver. Although I understand that a multi-threaded web server will be more expensive in resources (memory, processor), but will it not be even faster? I'm probably wrong; explain how this single-threaded process runs faster with a large number of requests, and what it usually does (at a low level) ?

Answer the question

In order to leave comments, you need to log in

9 answer(s)
S
Sergey Gornostaev, 2021-02-07
​​@Rouslan943

The highest I/O costs. Roughly speaking, if one request waits 90% of the time for I / O, then in the case of 10,000 concurrent requests, the server spends 9.999% of the time waiting for I / O, and asynchronous execution allows this time to be used to good use or simply written off. While a multi-threaded server processing 10k connections will spend 90% of the time on context switches, and even then, if there is enough memory.

E
Evgeniy Dikevich, 2017-08-24
@SA1MON73

Considering that your video card and disk subsystem are normal, I would advise you to pay attention to the i5-6400 (i5-7400) + mother of the ASRock H110M-DVS R3.0 level and 16GB of the most affordable ddr4. The budget does not exceed all this by much (somewhere around 2 thousand). I won’t orient you to the shops - I myself am from Belarus.

A
Amfore, 2017-08-24
@Amfore

If the motherboard + processor + RAM (let's say the junior i5, the average motherboard, ddr4 RAM), but you can hardly meet 20k. And you can’t count on high FPS on ultra in modern games.

C
CityCat4, 2017-08-24
@CityCat4

"... The answer of the Supersystem instantly destroyed the bright hopes: "The task has no solution"..." Leonid Reznik. magic triangle

R
Roman Kulakovich, 2017-08-24
@Wernisag

In good quality, this is at least i5, 8Gb Ram, SSD, 1060 GTX level video card. Open the price, consider. From the current components, you can leave the SSD, case and monitor.

L
Legebocker, 2017-08-24
@EnDeRJaY

You can buy a used laptop for 20K, but it’s not fate to upgrade a computer to a normal one. Mine was 6 years old and at that time it cost 30k. Now all 3D games crash in a minute. Of course, this is most likely due to a shit cooler, but something I'm not sure. Although when I drive in Gungeon, it feels like there are 8 fans in the computer (due to the volume). Probably, I need to install a new cooling system.

A
Alexander Shmelev, 2017-08-24
@shmool

I would take the G4560 + any cheap board for it + 16 RAM. The rest seems to be generally normal.

N
nonname, 2017-08-24
@nonname

If you really want to budget, then the Xeon X5650 on Ali for a penny, a motherboard under 1366 in the same place and a 16g oz can be kept within 20k. I myself have such a kit, in terms of performance as an average new i7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question