From owner-freebsd-current@FreeBSD.ORG Wed Oct 3 20:14:25 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C06B0106572A for ; Wed, 3 Oct 2012 20:14:25 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 1B9768FC12 for ; Wed, 3 Oct 2012 20:14:24 +0000 (UTC) Received: (qmail 61788 invoked from network); 3 Oct 2012 21:55:53 -0000 Received: from unknown (HELO [62.48.0.94]) ([62.48.0.94]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 3 Oct 2012 21:55:53 -0000 Message-ID: <506C9CE4.6080400@freebsd.org> Date: Wed, 03 Oct 2012 22:15:32 +0200 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: Adrian Chadd References: <03e101cda197$326dc240$974946c0$@org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd@chrysalisnet.org, freebsd-current@freebsd.org Subject: Re: sysctl kern.ipc.somaxconn limit 65535 why? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Oct 2012 20:14:25 -0000 On 03.10.2012 22:03, Adrian Chadd wrote: > Hi, > > somaxconn is the connection queue depth. If it's sitting at a couple > hundred thousand then something else is going crazily wrong. > > I understand your frustration, but there's a lot of instances where > the application just isn't doing things "right" and the OS tries to > hide it as much as psosible. Blowing out somaxconn to chew up a whole > lot of resources seems a bit silly. I'd rather investigate why the > userland application is not servicing the connect queue often enough. > > I've written network services that supported tens of thousands of new > TCP connections a second on a LAN and I never once had to bump > somaxconn past 32767. I'm not saying that it won't apply to your > scenario, I'm just trying to explain that there's likely more going > on. I guess the problem is rather kern.ipc.maxsockets which is only 25600. The name somaxconn is confusing as it specifies the listen queue limit instead of the maximum number of connections as the it suggests. This would also explain the persisting problems Chris described. maxsockets should be bumped up quite a bit by default IMO. How far needs some analysis because there are some dependencies and memory requirements. -- Andre > Adrian > > On 3 October 2012 11:45, wrote: >> Hi everyone. >> >> Actually 65k sockets is incredibly easy to reach. >> >> I manage some servers for a very large website, it currently has several >> http servers clustered to handle daily traffic and this is only dynamic >> content, static has its own servers, databases also have own servers. >> >> We recently started using memcached to cache some queries and we found on >> default server limits sockets were saturated extremely quickly, on the linux >> servers bumping it to a few hundred K solved the issue, wasnt possible on >> bsd. We did manage to get it down to only needing about 20k by setting >> extremely low timeout values. >> >> In addition we had to migrate all our mysql servers from freebsd to debian >> because they were hitting some arbitary OS limit but I could never figure >> out what, sys% usage went through the roof when this limit was hit, issue >> didnt occur on debian. I feel recently freebsd is more focused on desktop's >> and as such developer's never develop for a heavy server usage scenario, and >> I keep coming across hardcoded low limits. As rightly pointed out default >> values now days are useless 128 for somaxconn? maybe ok for a desktop. >> >> Freebsd also has issues with high numbers of cpu cores, very high locking >> overheads, the problem is the modern hardware is focusing on more and more >> cores and as such much more work on a server so a OS has to handle more and >> more processing and data, this includes more bigger connection queues and so >> on. FreeBSD just isnt scaling with more powerful hardware. Also forgetting >> as well DDOS attack scenarios where a high queue size is useful. >> >> I have used FreeBSD since the 4.x days and have been forced to migrate OS on >> several servers as FreeBSD to be blunt couldnt handle the load on those >> servers. It does seem as if developers of the OS are getting out of touch >> in respect to modern hosting enviromnents. I cant tell app developers to >> fix their apps to work on FreeBSD, they dont care, if it works fine on >> windows and linux then the app isnt broken as far as they are concerned. >> The more FreeBSD dev's have this aatitude of not adapting the less machines >> will run the OS. I hate many things about debian but at the end of the day >> I have to use what can handle the load or I lose my job. >> >> I do accept its entirely possible some tunables could fix any issues I have >> come across but believe me I have spent 100s of man hours on issues, and >> tuned everything I could find. >> >> To me this 32767 limit on somaxconn seems restrive and I vote for it been >> bumped to at least 8x that amount as a minimum. A more suitable default >> would probably be around 1024 as well instead of 128. Dead lingering >> connections in timewait etc. all use one of these, and that can very easily >> get into the 1000s. >> >> Chris >> >> _______________________________________________ >> freebsd-current@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-current >> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > >