tags:

views:

118

answers:

3

Hi

I have a doubt regarding the backlog value in listen system call. From man page of listen system call.

If the backlog argument is greater than the value in /proc/sys/net/core/somaxconn, then it is silently truncated to that value; the default value in this file is 128.

It means my server can accept only <128 connections at once. What if I want to accept more connection >128 ?? Can I simply set the value to the possible maximum number so that I can access more number of connection ??

+1  A: 

Yes. Use a command such as

$ echo 1000 >/proc/sys/net/core/somaxconn

To set the limit higher. See, for instance, this page for more tuning tips.

unwind
It seems quite simple and straight forward. But increasing the backlog value to a greatest number does increase the memory allocated for listening queue in Kernel. Is there anything called reasonable value which doesn't increases the overhead and provides better performance ??
codingfreak
Uh ... Storing things generally needs memory. If you need a larger backlog, but are not willing to spend memory to store it ... I'm not sure what you can do, I'm afraid.
unwind
+2  A: 

That number is only the size of the connection queue, where new connections wait for somebody to accept them. As soon as your application calls accept(), a waiting connection is removed from that queue. So, you can definitely handle more than 128 simultaneous connections because they usually only spend a short time in the queue.

Greg Hewgill
@Greg - So backlog value only indicates the size of the Connection queue but not number of connections to be accepted. Once accept is done it is removed from the queue providing space for other connections.
codingfreak
Yes, that is correct.
Greg Hewgill
A: 

The backlog value is not the number of maximum connections, it's the number of outstanding connections, i.e connections which you havn't accept():ed.

Puppe