Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

'hard' backlog limit of 128 #1496

Closed
jmanero opened this issue Aug 11, 2011 · 7 comments
Closed

'hard' backlog limit of 128 #1496

jmanero opened this issue Aug 11, 2011 · 7 comments

Comments

@jmanero
Copy link

jmanero commented Aug 11, 2011

The backlog parameter was removed from the HTTP module (or more likely form Net, and inherited by HTTP) some time before Node.js v2 in favor of a hard-coded value of 128.

In terms of load handling, this value limits the maximum size of the listen queue for the server's socket. On BSD systems, netstat -Lan shows the queue status of all sockets in the LISTEN state. Node will limit it's queue size to 128 even if the OS limit is larger. This cause BSD and Windos (Cygwin) OSs (and possibly some Linux systems) to begin to reset incoming TCP requests at loads as low as 4000 requests/second. Not so good for your dreams of a C10K web application...

Workaround:

var server = require('http').createServer( . . . );
server._backlog = 1024; 
server.listen(8000);

The code above works because the net_uv.js module passes the entire Net (or HTTP) object to it's internal wrapper for the listen method of process.binding('tcp_wrap').TCP. Either adding (and documenting) a setter in the HTTP.Server module, or doing this, could alleviate a great deal of suffering for future developers.

@bnoordhuis
Copy link
Member

Thanks, this is under consideration. The backlog is a no-op on modern linux systems but I know freebsd honours it. We're probably going to expose _backlog one way or another.

@rmustacc
Copy link

For what it's worth backlog is also not a no-op on SunOS based stuff.

@sh1mmer
Copy link

sh1mmer commented Oct 26, 2011

I'm going to mark this as low-priority because of the OS support. We'll revisit after 0.6 drops.

@erikdubbelboer
Copy link

Actually on all versions of the linux kernel the backlog is no no-op at all. I did some looking around and found the backlog parameter to listen() still determines the size of the SYN backlog.

The current setting of 128 will actually make the backlog 256 entries big, which is a bit on the small side I think.

I suggest setting the default to 511 (like nxing, redis, apache) and modifying the server.listen() function to allow for an optional backlog size like:

server.listen(port, [host], [backlog], [listeningListener])

since neither host nor listeningListener are numbers it's easy to keep the optional arguments apart. If you want I can fix it and make a pull request for it.

@bnoordhuis
Copy link
Member

@erikdubbelboer: Sure, I would like a PR.

@erikdubbelboer
Copy link

I made a pull request: #3130

The way I changed it isn't backwards compatible with the _backlog variable. But since this was internal and never really documented I see no harm in that.

@bnoordhuis
Copy link
Member

Fixed in 3d69bbf.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants