0

I have an Ubuntu droplet with the following:

  • 16GB RAM
  • 8 CPUs

I'm running nginx and PHP FPM, but I don't seem to be getting the most out of my server. Both my CPU usage and my memory usage are at around 10%, even though the server hangs when traffic gets intensive.

nginx summary:

  • worker_processes: 8
  • worker_connections: 6000
  • epoll is enabled
  • multi_accept is on
  • gzip enabled and keep-alive is enabled

php-fpm summary:

In my www.conf file:

  • pm: dynamic
  • pm.max_children: 1600
  • pm.start_servers: 75
  • pm.min_spare_servers: 75
  • pm.max_spare_servers: 90

Everything else uses the default setting.

Oh, and my ulimit is set to 99999 and PHP's opcache is enabled.

Is there any checklist that somebody can go through to make sure they are fine tuning nginx and php-fpm to fully utilise the resources of a server?

  • 1
    The bottleneck is most often the application itself you are running. Proper database design, indexing and caching are the key components you need to consider when optimising for performance. PHP-FPM and nginx settings effect are negligible compared to those. – Tero Kilkanen Oct 26 '17 at 20:11
1

That configuration looks appropriate. You could experiment with both raising and lowering the number of PHP-FPM processes (currently capped at 1600) - sometimes higher is not always better since what those processes are doing may hit performance problems with high concurrency. Try dropping it way down to say 100 just to see what it does. It won't necessarily limit the number of connections that can be served at once as other connections will still stay open and queue while waiting to be processed.

But that said, I don't think that's your problem. It's most likely the simple fact that you are I/O bound, meaning your database or file access is the bottleneck. If you're using a database, look at the config for that instead. With plenty of RAM, make sure it has plenty of buffer size for what it has to do (eg with InnoDB, give it a large buffer pool size of maybe a few Gb). And identify slow queries and optimise them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.