From d3729b6335f96b62319ebc9739dafdcb411de778 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 14 Aug 2014 15:40:18 -0700 Subject: [PATCH] Reduce the fallback SOMAXCONN value Related issue: #2407 Motivation: The current fallback SOMAXCONN value is 3072. It is way too large comparing to the default SOMAXCONN value of popular OSes. Modifications: Decrease the fallback SOMAXCONN value to 128 or 200 depending on the current OS Result: Saner fallback value --- common/src/main/java/io/netty/util/NetUtil.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/io/netty/util/NetUtil.java b/common/src/main/java/io/netty/util/NetUtil.java index 0dcba4e28b..26beb6874a 100644 --- a/common/src/main/java/io/netty/util/NetUtil.java +++ b/common/src/main/java/io/netty/util/NetUtil.java @@ -180,7 +180,10 @@ public final class NetUtil { LOCALHOST = loopbackAddr; // Determine the default somaxconn (server socket backlog) value of the platform. - int somaxconn = 3072; + // The known defaults: + // - Windows NT Server 4.0+: 200 + // - Linux and Mac OS X: 128 + int somaxconn = PlatformDependent.isWindows() ? 200 : 128; File file = new File("/proc/sys/net/core/somaxconn"); if (file.exists()) { BufferedReader in = null;