unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: scaling unicorn
Date: Wed, 23 Jun 2010 09:32:35 +0000	[thread overview]
Message-ID: <20100623093235.GB19233@dcvr.yhbt.net> (raw)
In-Reply-To: <AANLkTilWNicXuA0N5ouCvt3Pt1Wl0Fu9PEX_GQApzQn4@mail.gmail.com>

snacktime <snacktime@gmail.com> wrote:
> >> Somewhat related -- I've been meaning to discuss the finer points of
> >> backlog tuning.
> >>
> >> I've been experimenting with the multi-server socket+TCP megaunicorn
> >> configuration from your CDT:
> >> http://rubyforge.org/pipermail/mongrel-unicorn/2009-September/000033.html
> 
> So I'm in the position of launching a web app in a couple of weeks
> that is pretty much guaranteed to get huge traffic.  I'm working with
> ops people who are very good but this is not how they would normally
> setup load balancing and scale out.  I'm having a meeting with our
> network ops lead tomorrow to talk about this.  I like the idea of this
> approach, it seems like it gives you more fine grained control over
> how much load you put on individual servers as well as how individual
> requests are handled.  But I'm not too keen on using something like
> this at scale when we simply don't have the chance to test it out at a
> smaller scale.  I have yet to see anyone with this setup running at
> scale.  That of course doesn't mean it's not a great idea, only that I
> doubt our ops guys are going to want to be the first.  They are
> already overworked as it is:)

No worries.  Don't ever feel obligated to try something you're not
comfortable with.  Heck, it took months before anybody besides myself
was comfortable with Unicorn.

> So assuming we will scale out the 'normal' way by not having a short
> backlog, any info on how to manage that?   Should we control the
> backlog queue in nginx (not sure exactly how I would do that) or via
> the listen backlog?  I was looking around last night and couldn't find
> a way to actually poll the listen backlog queue size.

nginx lets you specify a backlog=num with the "listen" directive
much like Unicorn does (Unicorn steals most configuration parameter
names/options from nginx):

  http://wiki.nginx.org/NginxHttpCoreModule#listen

If you use Linux, you can poll the current listen queue
using Raindrops (http://raindrops.bogomips.org/), the ss(8) utility,
or parsing /proc/net/tcp and/or /proc/net/unix.  Unfortunately,
checking the listen queue for Unix domain sockets is expensive,
Raindrops and ss(8) both need to parse /proc/net/unix because
that info isn't available via netlink.

> Also, any ideas on how you would practically manage this type of load
> balancing setup?  Seems like you would have some type of 'reserve'
> cluster for requests that hit the listen backlog, and when you start
> seeing too much traffic going to the reserve, you add more servers to
> your main pool.  How else would you manage the configuration for
> something like this when you are working with 100 - 200 servers?  You
> can't be changing the nginx configs every time you add servers, that's
> just not practical.

I've never tried this setup, so what Jamie said :)

One extra note, 100-200 hosts in an upstream {} block makes a very long
nginx config file.  You could use ERB or something else to template,
but based on a previous reading of the nginx source code, you can
also setup a round-robin DNS entry for all the servers.

nginx only does DNS lookups for upstreams at load time.  For round-robin
DNS entries, nginx adds an entry for every IP address a name resolves
to, so just specify the one DNS name in the upstream block instead of
the list of IP(s).

Just remember to HUP the nginxes (or if you're forgetful, make an
occasional cronjob to HUP them) when you make DNS changes and add/remove
a box.

-- 
Eric Wong
_______________________________________________
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


  parent reply	other threads:[~2010-06-23  9:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTilv4e_DPDKy440xotrlE7ucFIFXs74uHyGrzCKL@mail.gmail.com>
2010-06-22  0:16 ` [Mongrel] scaling unicorn Eric Wong
2010-06-22  2:34   ` Jamie Wilkinson
2010-06-22  4:53     ` Eric Wong
2010-06-22 18:03       ` snacktime
2010-06-22 18:57         ` Jamie Wilkinson
2010-06-23  9:32         ` Eric Wong [this message]
2010-06-22 19:18       ` Jamie Wilkinson
2010-06-22 17:30   ` [Mongrel] " snacktime

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=20100623093235.GB19233@dcvr.yhbt.net \
    --to=normalperson@yhbt.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).