unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Laas Toom <laas@toom.ee>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: Is a client uploading a file a slow client from unicorn's point of view?
Date: Tue, 9 Oct 2012 09:31:36 +0300	[thread overview]
Message-ID: <CFC93863-1061-4710-A195-58CBCCBED7B8@toom.ee> (raw)
In-Reply-To: <20121009015800.GA1772@dcvr.yhbt.net>


On 09.10.2012, at 4:58, Eric Wong <normalperson@yhbt.net> wrote:

> I'm not familiar with the nginx upload module, but stock nginx will
> already do full request buffering for you.  It looks like the nginx
> upload module[1] is mostly meant for standalone apps written for
> nginx, and not when nginx is used as a proxy for Rails app...

AFAIK the upload module will give you two things:

1) handle the whole body parsing up to the point of storing the file to disk in correct place. Then it strips the file from POST request and replaces with reference to the location on disk.

2) make the upload progress available, so e.g. AJAX-powered upload forms can show progressbar, which is really neat. No need for Flash-based uploaders.


I have a Rails app that accepts media uploads. All the processing happens in background, front-end handles only the actual upload and stores it to disk.
But with uploads as large as 1.4 GB, I've seen Rails response times > 200 secs. This starts to give timeouts in weird places.

Eric, correct me if I'm wrong, but doesn't Nginx-Unicorn-Rails stack write the whole file up to 3 times to disk:
1) Nginx buffers the body (in encoded state)
2) Unicorn parses the body and writes to TMP folder (as requested by Rails)
3) if Rails accepts the file, it moves it to actual storage. But as /tmp is often different device from storage, this is actually a full copy.

In such a situation the upload module would help out, because instead of simply buffering the body on disk, it actually parses the body. And it is implemented in C, which should make it faster.
Afterwards it will only handle out the file location and Rails can complete it's work a lot faster, freeing up workers.

Unicorn won't even see the file and Rails has the responsibility to delete the file if it's invalid.


Best,
Laas
_______________________________________________
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:[~2012-10-09  6:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09  0:39 Is a client uploading a file a slow client from unicorn's point of view? Jimmy Soho
2012-10-09  1:58 ` Eric Wong
2012-10-09  6:31   ` Laas Toom [this message]
2012-10-09 20:03     ` Eric Wong
2012-10-09 23:06       ` Laas Toom
2012-10-09 23:54         ` Eric Wong
2012-10-10  6:59           ` Laas Toom

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=CFC93863-1061-4710-A195-58CBCCBED7B8@toom.ee \
    --to=laas@toom.ee \
    --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).