unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Tom Pesman <tom@tnux.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: Unicorn hangs on POST request
Date: Tue, 2 Apr 2013 13:55:02 +0200	[thread overview]
Message-ID: <CAGJrHAZa35dGC5fcJGsLgqNQrQ52JdNQApBr+-A58L4=j83DzQ@mail.gmail.com> (raw)
In-Reply-To: <20130311230157.GB26407@dcvr.yhbt.net>

> The request body doesn't seem to be there, presumably because Heroku
> isn't sending it.
>
> Doe heroku fully buffer the request body before sending it to unicorn?
> nginx fully buffers, and this is why I can only recommend nginx for slow
> clients.
>
> The proxy -> unicorn transfer speed should _never_ be dependent by the
> client -> proxy transfer speed.
>
> 1) client        ------------------ (slow) --------------> proxy
> 2) proxy (nginx) --- (as fast as the connection goes) ---> unicorn
>
> With nginx, 1) and 2) are decoupled and serialized.  This adds latency,
> but is the only way for multiprocess servers like unicorn to efficiently
> handle slow clients.

I've some new information. Heroku buffers the headers of a HTTP
request but it doesn't buffer the body of POST requests. Because of
that I switched to Rainbows! and the responsiveness of the application
increased dramatically.

Right now I'm using this configuration:

worker_processes 4
timeout 15
preload_app true

Rainbows! do
  use :EventMachine
  worker_connections 50
  client_max_body_size 5*1024*1024 # 5 megabytes
  client_header_buffer_size 2 * 1024 # 2 kilobytes
  timeout 10
end

With high load the performance drops, is EventMachine the right choice
for this situation (Rails application with slow POST requests and with
up to 50% POST requests)? Will increasing the worker_connections help?

I'm planning to make a blog post about this and tell Heroku not to
advise Unicorn for Rails applications but to use Rainbows and suggest
a correct/optimised configuration.

Thanks!

Tom
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

  reply	other threads:[~2013-04-02 12:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09 16:02 Unicorn hangs on POST request Tom Pesman
2013-03-09 21:02 ` Eric Wong
2013-03-10 16:22   ` Tom Pesman
2013-03-11 19:49     ` Eric Wong
2013-03-11 22:20       ` Tom Pesman
2013-03-11 23:01         ` Eric Wong
2013-04-02 11:55           ` Tom Pesman [this message]
2013-04-02 17:24             ` Eric Wong
2013-04-02 20:25               ` Tom Pesman
2013-04-02 22:36                 ` Eric Wong
2013-04-03  4:56                   ` Lin Jen-Shin (godfat)
2013-04-03 11:38                     ` Eric Wong

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/unicorn/

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

  git send-email \
    --in-reply-to='CAGJrHAZa35dGC5fcJGsLgqNQrQ52JdNQApBr+-A58L4=j83DzQ@mail.gmail.com' \
    --to=tom@tnux.net \
    --cc=mongrel-unicorn@rubyforge.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.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).