[erlang-questions] listen() backlog limited to 16 bits?

Matthew Dempsky <>
Tue Apr 28 02:24:19 CEST 2009

On Mon, Apr 27, 2009 at 4:42 PM, Steven Grady <> wrote:
> Possibly.  Actually, the main problem is that if you pass in a big
> number, it gets masked off.  if you're unlucky enough to choose a
> number like 65536, you'll set it to 0...

Agreed, that's definitely a problem.

> In general, we are using mochiweb (modified to use gen_tcp's active
> mode) and are only able to handle 1,700 connections a second.  We need
> to handle probably 5x that.  But yeah, we are probably not running
> into the 16-bit limit (yet! :-).
> Any thoughts on how to increase the numbers of accepts/sec would be
> welcome.

My only point is that (AFAIK) the listen backlog doesn't directly
affect the number of requests per second or the number of concurrent
connections you can handle.  It's just the number of TCP connections
that have completed the SYN/ACK handshake and not yet been accepted by
user space, and I just wouldn't expect this number to get into the
hundreds of thousands unless the system is heavily overloaded, and
then it probably can't do anything useful with such a huge backlog

(Again, just my understanding; if I'm wrong, I'd love to hear an
explanation why.)

More information about the erlang-questions mailing list