W
W
Wynell_ru2019-11-12 19:48:17
JavaScript
Wynell_ru, 2019-11-12 19:48:17

How many requests can be made at the same time in NodeJs?

Good evening
How many requests can I send at the same time (for example with node-fetch)? How to do it? If I send requests in a loop, will they be sent almost at the same time? How to implement such multithreading?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Neverov, 2019-11-12
@TTATPuOT

From 1 to a million million. Node js is not a multi-threaded language, but asynchronous. A very good video for understanding asynchrony: https://youtu.be/8cV4ZvHXQL4
And so - most likely, you will never "run into" the request limit. The limit is determined by the optimization of your code and the quality of the hardware on which the application is running. + You can always scale the application horizontally. And also create several parallel applications, distributing the load between them. PM2 can do this, for example.

V
Valentin Sirovsky, 2019-11-12
@smirnovalerka88

Like 500, everything depends on the server!

G
grinat, 2019-11-13
@grinat

You need to select a number, in any case, the node is single-threaded, if a pack leaves at the same time, then the pack will return at about the same time, and there will be no gain, there will just be bursts of load on the CPU and network. Also, if there are a lot of them, then a part will begin to fall off. They must be smoothly smeared in such a way that the flow works all the time and does not fall into network restrictions. That is, send one after another with a small delay. Plus, it depends on the task, if it is a parser, and the target service has a rate limiter, then if you send, for example, 100 requests per second, and the limit is 10, then in the best case, 90 will simply fall off, and in the worst case, you will immediately grab a ban for a while or forever and have to look for a proxy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question