Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
Subject: client_header_buffer_size tuning in rainbows.git
Date: Tue, 3 May 2011 01:47:22 +0000	[thread overview]
Message-ID: <20110503014722.GA21232@dcvr.yhbt.net> (raw)

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


                 reply	other threads:[~2011-05-03  1:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/rainbows/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110503014722.GA21232@dcvr.yhbt.net \
    --to=normalperson-rmlxzr9ms24@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
    --subject='Re: client_header_buffer_size tuning in rainbows.git' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

	../../rainbows.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).