E
E
Emanue12017-08-12 17:19:44
JavaScript
Emanue1, 2017-08-12 17:19:44

Implement a node.js request processing queue?

When accessing the port, a rather resource-intensive thing is launched - electron.js. If at the same time ten people turn to this port, then the server will fall (there is no money for a more powerful one). I need that if ten people applied to the port, then a queue would be created for processing these requests and they would be processed one by one. That is, in general, if one request is already being processed at the moment, then all the others are pending. Tell me how to implement it?

var http = require("http");

http.createServer(function(request, response){
  //тут запуск электрона
});
    response.end();
}).listen(8080);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Sergey, 2017-08-12
@hahenty

The simplest, through setTimeout - the interpreter itself will resolve these requests in turn of timers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question