You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a http server with throng, the backlog value is not respected. I'm not really sure why. This parameter is very useful if you have multiple concurrent connections and you want to limit how many are processed at the same time. Is this the expected behavior?
This is a minimum example that illustrates this issue:
consthttp=require('http'),throng=require('throng');// ================================================letuseThrong=true;// ================================================letn=0;constserver=http.createServer(async(req,res)=>{letln=++n;console.log(`[${newDate().getSeconds()}] Received request ${ln}`);setTimeout(()=>{res.statusCode=200;res.setHeader('Content-Type','text/plain');res.end(`Pong ${ln}\n`);console.log(`[${newDate().getSeconds()}] Sent response ${ln}`);},1000)});if(useThrong){throng({workers: 1},(id)=>{server.listen(3000,'0.0.0.0',3,()=>{console.log(`Server ${id} running`);});});}else{server.listen(3000,'0.0.0.0',3,()=>{console.log(`Server running`);});}
Without throng, 10 concurrent requests:
Server running
[4] Received request 1
[5] Sent response 1
[5] Received request 2
[5] Received request 3
[5] Received request 4
[5] Received request 5
[6] Sent response 2
[6] Sent response 3
[6] Sent response 4
[6] Sent response 5
[6] Received request 6
[6] Received request 7
[6] Received request 8
[6] Received request 9
[6] Received request 10
[7] Sent response 6
[7] Sent response 7
[7] Sent response 8
[7] Sent response 9
[7] Sent response 10
With throng:
Server 1 running
[4] Received request 1
[5] Sent response 1
[5] Received request 2
[5] Received request 3
[5] Received request 4
[5] Received request 5
[5] Received request 6
[5] Received request 7
[5] Received request 8
[5] Received request 9
[5] Received request 10
[6] Sent response 2
[6] Sent response 3
[6] Sent response 4
[6] Sent response 5
[6] Sent response 6
[6] Sent response 7
[6] Sent response 8
[6] Sent response 9
[6] Sent response 10
The text was updated successfully, but these errors were encountered:
This is an issue with node's cluster module. You can track progress on it at nodejs/node#33827.
I would encourage you to run some tests to ensure that backlog is doing what you think it's doing. My understanding is that backlog limits the maximum pending connection queue depth - not that it limits the level of concurrency of your http handlers, as you described. I could be wrong, though, as it isn't something I've tested.
When running a http server with throng, the backlog value is not respected. I'm not really sure why. This parameter is very useful if you have multiple concurrent connections and you want to limit how many are processed at the same time. Is this the expected behavior?
This is a minimum example that illustrates this issue:
Without throng, 10 concurrent requests:
With throng:
The text was updated successfully, but these errors were encountered: