Welcome! Log In Create A New Profile

Advanced

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Jérôme Loyet
June 15, 2010 05:18PM
2010/6/15 Reinis Rozitis <r@roze.lv>:
>>> The basic approach usually as far as I know is to set worker_processes
>>> based
>>> on your CPU core count (either identical or sometimes there is benefit
>>> setting with some multiplier - 2*cores (I have seen some improvements
>>> when
>>> using nginx as on-the-fly image resizer to utilise the box more)).
>>>
>>> worker_connection - typical 1024 or 2048 usually is enough. Bassically
>>> the
>>> math is based on max_clients where: max_clients = worker_processes *
>>> worker_connections
>>
>> this is right only if your webserver is ONLY serving dynamic content
>> without caching. If nginx is serving static file or dynamic content
>> from cache, you will have less connections to the fcgi backend than
>> you have incoming connections on the web server. There is no way to
>> know exactly how many fcgi concurent connexions. You can set
>> max_children depending on your RAM.
>
> Nginx has a quite small memory footprint (if you dont go overboard with
> buffers per connection).
> And you can have thousands of open connections because of effective event
> models (especially when using it for comet-type applications) and still not
> consuming much memory.
>
> For nginx-type server maximum clients doesnt mean the same as for apache
> MaxClients which could result in the same number as httpd processes running
> (each with php module loaded) consuming loads of memory so you had to be
> extra carefull with that setting otherways things could turn ugly.
>
> The beauty about php in fastcgi mode is the controlled memory consumption
> (besides the typical leaking in php/extensions - which is "fixed" by
> periodically restarting the childs (done by the master php process)) - it
> doesnt really change/jump - eg you set 10 startup childs which easily can
> handle more than just 10 users as nginx makes a queue and will pass the
> requests to the php fcgi backend (of course if you are running php code like
> <? sleep(60); ?> then only 10 clients at time (minute) will be processed for
> dynamic content).
>
>
>
> In short max_clients/worker_connections are only loosely related (it doesnt
> matter if thats a static or dynamic request - all go into the same worker
> threads (there is a bit difference if you make a lot of backend
> connections/proxying)) to amount of php processes in a world of nginx-type
> servers.
>
> And in case you use FPM even the variable PHP_FCGI_CHILDREN has become
> deprecated as the new syntax for process management is something like:
>
> pm = dynamic
> pm.max_children = 70
> pm.start_servers = 20
> pm.min_spare_servers = 5
> pm.max_spare_servers = 20
> pm.max_requests = 1000

make pm.start_servers greater than pm.min_spare_servers and lower than
pm.max_spare_servers
because at startup, if no connection arrives and if start_servers is
lower than min_spare_servers fpm will kill one process per second
until current process count reaches min_spare_servers.

>
>
>
> p.s. afaik the only thing which the php-dev team havent still implemented is
> the FCGI_OVERLOADED (according to fcgi spec) feature..  to let the webserver
> know sooner that there aren't enough resources on the backend to process the
> request rather than after timeouts.

interesting. Does nginx handle this fcgi response ? You can open a bug
on bugs.php.net to request this feature and, if you have so, propose a
corresponding patch.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 11:39AM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Reinis Rozitis June 15, 2010 02:08PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 02:18PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

mike June 15, 2010 02:22PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 03:00PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Reinis Rozitis June 15, 2010 03:26PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Jérôme Loyet June 15, 2010 03:42PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Rahul Bansal June 15, 2010 04:02PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Jérôme Loyet June 15, 2010 04:10PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 04:32PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Piotr Karbowski June 15, 2010 04:36PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Jérôme Loyet June 15, 2010 04:38PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 04:52PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Piotr Karbowski June 15, 2010 05:02PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 05:17PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 05:28PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Piotr Karbowski June 15, 2010 05:34PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Reinis Rozitis June 15, 2010 05:10PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Jérôme Loyet June 15, 2010 05:18PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Reinis Rozitis June 15, 2010 05:46PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Jérôme Loyet June 15, 2010 05:52PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 16, 2010 08:20AM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 05:46PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 05:50PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 26, 2010 07:29PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

ericdeko411 June 26, 2010 09:45PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 27, 2010 10:04AM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 03:12PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Reinis Rozitis June 15, 2010 03:16PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 03:42PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

mike June 15, 2010 04:02PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

rahul286 June 15, 2010 04:12PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

speedway June 17, 2010 10:38PM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Jan Bujk September 09, 2011 08:36AM

Re: Optimizing worker_processes, worker_connections & PHP_FCGI_CHILDREN - Any Good Tutorial?

Reinis Rozitis September 09, 2011 09:40AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 78
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready