Update on: nginx makes mysqld die all the time

Steve Wilson lists-nginx at swsystem.co.uk
Tue Aug 25 20:39:16 UTC 2015


Hi,

On 25/08/2015 08:36, M. Fioretti wrote:
> On 2015-08-18 15:23, M. Fioretti wrote:
>> Greetings,
>>
>> I just migrated to nginx + php-fpm from apache a few websites, on a
>> centos 6.6 virtual server. The sites are up but... now mysqld
>> (MariaDB, actually) dies every 10/20 **minutes** with status:
> 
> Greetings,
> after a few days, I can report that setting:
> 
> mysql.allow_persistent = Off
> 
> in php.ini, and then tuning some php-fpm parameters as below, fixed
> the problem. There surely still is much more that can be optimized
> (and comments on the parameters below are welcome!) and I'll ask
> about it later, but I haven't seen any more crashes,
> and the websites already load quickly.

This is good news, I was actually wondering if you'd sorted it.

> Thanks to all who helped!!!
> 
> Marco
> 
> pm = dynamic
> pm.max_children = 12
> pm.start_servers = 3
> pm.min_spare_servers = 2
> pm.max_spare_servers = 3
> pm.max_requests = 10

I don't think this is the perfect place to get answers on this, however
my understanding is that this is how it'll work.

php-fpm will manage it's workers dynamically, starting with 3 and being
able to grow to a maximum of 12. To keep resources to a minimum on your
server it will allow for between 2 and 3 of these to be waiting to do
something. If there's more than 3 it'll kill the child, also when each
one has served 10 requests they'll terminate. If there's less than 2
idle children it'll start another until there's a minimum of 2 idle.

The above may not be the optimal configuration for your needs, as
ondemand may be more suited than dynamic or static. I think key factors
are the spec of the server and how busy php is, there may be some way to
monitor the running number of children to fine tune later but may cause
problems if there's a sudden surge in requests.

The php manual has some information on each of these settings at
<http://php.net/manual/en/install.fpm.configuration.php#pm>

Steve.



More information about the nginx mailing list