tags:

views:

63

answers:

1

hi

I am interesting what are the limits for gen_tcp:accept function? I mean what is max concurrent connection count? Or how can it be configured? (gen_tcp setting, ulimit or something else) how much get_tcp can accept connection per second?

+5  A: 

The maximum concurrent connections is going to depend on the operating system. On unix systems it would be limited by the nfds ulimit as well has the maximum number of connections the kernel is configured to handle.

The number of connections accepted per second is mostly going to be dependent on your application code. It must service the requests in a timely manner. The maximum number of pending connection requests is specified by the backlog option to the listen function. Most systems restrict the maximum backlog size, on linux and freebsd this option is named somaxconn. There's also the matter of half-completed TCP handshakes. You'll want to learn about syncookies and any options for tuning the maximum number of half-established connections.

Geoff Reedy
maybe you known how to get current value of queue of unhandled (yet) sockets? I need it to set optimal value of backlog param.
vinnitu
@vinnitu, I don't think there's a way to get the number of connections in the backlog. You should structure your application so it can accept the connections quickly. If you do, you're unlikely to have the backlog get filled. For example in erlang, you'd accept the connection and spawn a process to handle it so you could accept the next connection almost immediately.
Geoff Reedy