Answer the question
In order to leave comments, you need to log in
What can be improved to send 40000 requests per second?
Good afternoon.
The task is to parse a large amount of data. Parsing occurs by accessing the site's api.
It is necessary to make an average of 5-10 requests at the same time for each of the 4000 entities.
Now a node.js script is written, in which 100 child processes are created, each executes about 4000 asynchronous requests, respectively, and waits for their execution using Promise.all
The execution time of the entire script is about 15 seconds on a 6-core CPU. Server response time ~1s.
Is it possible to improve the speed of execution on current hardware, or can only horizontal scaling help? What kind of hardware is required to execute so many requests every 2 or 5 seconds?
Simplified code:
// main.js
const childProcess = require('child_process');
const entitiesChunks = splitToChunks(entities, 100); // Разделяет массив сущностей на 100 частей
for (let i = 0; i < 100; i++) {
let workerProcess = childProcess.fork('entityWorker.js');
workerProcess.send(entitiesChunks[i]);
}
// entityWorker.js
process.on('message', async (entities) => {
// Проходит по всем эелементам и выполняет 5-10 асинхронных запросов внутри parseEntity()
process.send(await Promise.all(entities.map((el) => parseEntity(el))));
process.exit()
});
Answer the question
In order to leave comments, you need to log in
Now a node.js script has been written, in which 100 child processes are created, each executes about 4000 asynchronous requests, respectively, and waits for their execution using Promise.all
What is required to send 40000 requests per second?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question