Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save deepaknverma/9ddc78bf7c2970dd6e2b to your computer and use it in GitHub Desktop.
Save deepaknverma/9ddc78bf7c2970dd6e2b to your computer and use it in GitHub Desktop.
10 Tips for Optimizing NGINX and PHP-fpm for High Traffic Sites
Please take a look at the original article (http://www.softwareprojects.com/resources/programming/t-optimizing-nginx-and-php-fpm-for-high-traffic-sites-2081.html) as it includes excellent configuration file examples.
1. Switch from TCP to UNIX domain sockets:
When communicating to processes on the same machine UNIX sockets have better performance the TCP because there's less copying and fewer context switches.
2. Adjust Worker Processes:
Set the worker_processes in your nginx.conf file to the number of cores your machine has and increase the number of worker_connections.
3. Setup upstream load balancing:
Multiple upstream backends on the same machine produce higher throughout than a single one.
4. Disable access log files:
Log files on high traffic sites involve a lot of I/O that has to be synchronized across all threads. Can have a big impact.
5. Enable GZip.
6. Cache information about frequently accessed files.
7. Adjust client timeouts.
8. Adjust output buffers.
9. /etc/sysctl.conf tuning.
10. Monitor:
Continually monitor the number of open connections, free memory and number of waiting threads and set alerts if thresholds are breached. Install the NGINX stub_status module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment