[Libevent-users] thread-safety (and performance)
Tani Hosokawa
tani at tanihosokawa.org
Tue Jan 22 12:45:43 EST 2008
> On Mon, Jan 21, 2008 at 04:14:08PM -0800, Tani Hosokawa wrote:
> <snip>
>> > @@ -1999,7 +1999,7 @@
>> > if ((fd = bind_socket(address, port)) == -1)
>> > return (-1);
>> >
>> > - if (listen(fd, 10) == -1) {
>> > + if (listen(fd, 8192) == -1) {
>> > event_warn("%s: listen", __func__);
>> > EVUTIL_CLOSESOCKET(fd);
>> > return (-1);
> Probably better to use SOMAXCONN instead of an arbitrary number.
On Linux, you can set somaxconn in proc (|/proc/sys/net/core/somaxconn) to much higher than the value in the header files (128). I could pull the sysctl value, but that isn't all that portable and in any case it's silently truncated to the system's real maximum if you specify something higher. As libevent is typically used for high performance products, it makes sense to me to set it above the system's actual maximum, and let the system limits drag it down. If anyone has some portable code for determining the real somaxconn across all systems, that'd probably be handy.
|
More information about the Libevent-users
mailing list