From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS14383 205.234.109.0/24 X-Spam-Status: No, score=1.0 required=3.0 tests=AWL,HK_RANDOM_FROM, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: client_header_buffer_size tuning in rainbows.git Date: Tue, 3 May 2011 01:47:22 +0000 Message-ID: <20110503014722.GA21232@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1304387265 18641 80.91.229.12 (3 May 2011 01:47:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 3 May 2011 01:47:45 +0000 (UTC) To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Tue May 03 03:47:41 2011 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:245 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QH4iC-0008QT-Oo for gclrrg-rainbows-talk@m.gmane.org; Tue, 03 May 2011 03:47:41 +0200 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 8C0D718583A3; Mon, 2 May 2011 21:47:38 -0400 (EDT) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id A82B718583A2 for ; Mon, 2 May 2011 21:47:32 -0400 (EDT) Received: from localhost (unknown [127.0.2.5]) by dcvr.yhbt.net (Postfix) with ESMTP id 003D6202DE; Tue, 3 May 2011 01:47:31 +0000 (UTC) This will be in the next release. It mainly affects Thread/Actor/Fiber-based concurrency models since those have an independent (userspace) buffer for client headers. The default is now only 1K (matching nginx) whereas the previous hardcoded value was 16K. If it can't fit in 1K, it'll read again and append to the previous 1K buffer, and so on...[1] Lowering header buffer sizes lowers memory usage for sites with many idle connections. With only 1000 clients, header buffers alone would be 16M in memory usage, 10K clients => 160M. If new clients frequently connect, this will put more pressure on GC to run. Typical HTTP header sizes[2] are smaller than 1K. Most Rails sites use larger headers because the sessions are stored in a cookie, so they end up being in the 1K - 2K range from some quick investigations I did. == Rails cookie sessions users: This may cause more recv(2)/read(2) syscalls per request. If this syscall is measurable overhead (I doubt it is), increase client_header_buffer_size to what your expected session cookie payload to be. == Unicorn Unicorn is much simpler since it only has one client to worry about. Unicorn allocates one 16K buffer and never releases/shrinks it for the duration of the process (though it can grow up to 112K)[1]. Thanks for reading! [1] There's a hard-coded limit of 112K to prevent DoS in the Mongrel/Unicorn parser. [2] search the web, some sites have done research on them -- Eric Wong _______________________________________________ Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org http://rubyforge.org/mailman/listinfo/rainbows-talk Do not quote signatures (like this one) or top post when replying