Report this

What is the reason for this report?

Having problem with Php fpm

Posted on October 2, 2018

Ok My site is working fine but when the number of visitors increases it breaks suddenly.To find out why it breaks I have been observing the behaviour of my server using the ‘htop’ command.

Using ‘htop’ I noticed that whenever the second value in the figure,

code Tasks 136 , 100 , 2 running

reaches 166 my site breaks,I get something like " 502 Gateway error" .The problem seems to be not coming from RAM because the RAM usage is just 4 to 5 GB but I have 16GB RAM.And also the CPU usage never reaches 100%.So where is the problem coming from? can anyone help me please!

My Server is information:

16GB RAM, 320 GB storage , 6 CPU

My NGinx configuration is :

worker_processes 6;
worker_connections 2000;

My PHP fpm configuration is :

pm = ondemand
pm.max_children = 100
pm.start_servers = 18
pm.min_spare_servers = 9
pm.max_spare_servers = 18
pm.process_idle_timeout = 10s;
pm.max_requests = 500

Am I missing something,I also use WP Super cache!!

Any help will be grateful,thank you in advance.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Increase max_children to 150 and restart fpm. Also, check the php-fpm error log. It should have further clues on why it’s failing.

It’s happening because your max_connections is being reached. Run these commands and copy/paste the output here:

wget http://mysqltuner.pl
mv index.html mysqltuner.pl
perl mysqltuner.pl

On the last command, you might need to run it like this:

perl mysqltuner.pl --user root -pass <mysql_root_passwd>

I had the same issue and solved it by adding a SWAP to my droplet following “How To Add Swap Space on Ubuntu 20.04

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.