Help troubleshooting Nginx + Php-Fpm Set up

April 14, 2017 585 views
Nginx PHP Linux Basics Server Optimization WordPress

Researched this issue many times and now need help understanding some diagnostics. Basically switched a server over from Apache + Php regular to Nginx + php-fpm . The problem is after a small increase in users Nginx starts encountering 503 and 502 errors. The main error we see in the log is "Connection reset by peer". I ran iostat and top commands sorted by CPU usage and need help understanding if these are normal.
We stress tested with Apache Jmeter and as you can see in the top graphic many child processes get created with about 30 - 40 % cpu. I can't imagine that being good. Also when running iostat the avg-cpu %user column jumps to the 90th percentile . I can't imagine that being good either. The stress test we did was 100 users in 60 seconds which is the kind of activity this site gets.
I imagine this is a php script causing this problem , particularly wordpress. Does anyone have suggestions where to begin debugging this problem? So far we have tried increasing the buffer size, increasing the timeouts in php and nginx, but nothing has worked.

Image for iostat
http://andraebrowne.com/web/images/iostat-stress-test.png

Image for top
http://andraebrowne.com/web/images/apache-jmeter-php-fpm.png

1 Answer

@brownexnadrae

Not sure how I missed this one as I normally get flagged when NGINX is tagged in a post, though if you've not already found a solution, hopefully I can help.

...

When it comes to NGINX, it's all about the configuration. To really get an idea of what we're working with, I'd need to see your configuration -- specifically nginx.conf and how you've configured each of your server blocks.

It'd also be beneficial to take a look at the pool files that you've setup for each site for PHP-FPM.

Have another answer? Share your knowledge.