Welcome! Log In Create A New Profile

Advanced

Re: Tuning workers and connections

Momchil Ivanov
July 03, 2009 04:58AM
На Thursday 02 July 2009 03:23:06 Avleen Vig написа:
> Hi folks, I have some questions about tuning nginx for best
> performance, on a site which handle ~1000 requests per second.
>
> In our config, we have:
>
> worker_processes 16;
> worker_rlimit_nofile 32768;
> events {
> worker_connections 8192;
> }
>
> This is on a server with 8 CPU cores and 8Gb RAM.
> My understanding is that this should allow nginx to establish up to
> 32k network connections, because that is the limit of
> worker_rlimit_nofile. We serve very few files off the disk, maybe a
> dozen CSS and JS files. Everything else is handed to backends using
> proxy_pass.
> So with one fd for the browser, and one fd to the upstream, we should
> be able to handle 16k concurrent connections.
>
> However what we're seeing, is that around 5k connections we get a
> performance hit. Connections slow down, take longer to establish, etc.
> The load on the box is almost zero, nginx is clearly working very fast
> and efficiently, but I'm not sure why it slows down.
> Any thoughts?
>
>
> Also, I'm thinking about enabling the multi_accept option, but I
> couldn't find much documentation on how this works.
> It sounds like a high-performance tweak which we should be using if we
> get this many requests per second.
> Could it be that not using multi_accept is the problem?
> Nginx otherwise has to handle the incoming connection requests in
> serial and this is a bottleneck?

The first thing to do would be playing with sysctls, especially increasing
backlog and somaxconn, decreasing tcp_fin_timeout. If this doesn't help a lot
you may consider using keepalive connections (only if you are hitting some
issue with handling lots of accepts).

If you move to keepalive connections, you should make sure that you befefit at
all, therefore monitor requests/handled accepts.

Momchil

--
PGP KeyID: 0x3118168B
Keyserver: pgp.mit.edu
Key fingerprint BB50 2983 0714 36DC D02E  158A E03D 56DA 3118 168B
Subject Author Posted

Tuning workers and connections

Avleen Vig July 01, 2009 09:23PM

Re: Tuning workers and connections

Gabriel Ramuglia July 01, 2009 10:39PM

Re: Tuning workers and connections

Dave Cheney July 02, 2009 01:43AM

Re: Tuning workers and connections

Avleen Vig July 02, 2009 09:58AM

Re: Tuning workers and connections

Maxim Dounin July 02, 2009 05:56AM

Re: Tuning workers and connections

Avleen Vig July 02, 2009 10:01AM

Re: Tuning workers and connections

mike July 02, 2009 01:56PM

Re: Tuning workers and connections

Maxim Dounin July 02, 2009 02:19PM

Re: Tuning workers and connections

mike July 02, 2009 02:34PM

Re: Tuning workers and connections

Maxim Dounin July 02, 2009 03:05PM

Re: Tuning workers and connections

Momchil Ivanov July 03, 2009 04:58AM

Re: Tuning workers and connections

liangrubo August 21, 2012 03:23AM

Re: Tuning workers and connections

liangrubo August 21, 2012 03:48AM

Re: Tuning workers and connections

Stefan Caunter August 21, 2012 05:16AM

Re: Tuning workers and connections

hagai avrahami August 27, 2012 03:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready