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

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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.
Hey 👋
Indeed, Nginx is great, but a few tweaks can make it even better for handling high traffic:
worker_connections to handle more simultaneous requests:
events {
worker_connections 4096;
}
fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
For more details, check out this guide: 🔗 How To Optimize Nginx Configuration
On the caching side of things, caching is essential for reducing server load:
On another note, a CDN like Cloudflare can handle your static content (images, CSS, JS), reducing load on your server and speeding up delivery for users worldwide. Cloudflare’s free plan works great for most WordPress setups.
On the server side configuration updates, PHP-FPM is responsible for handling PHP requests, and tuning it properly can make a huge difference during high-traffic periods. The key settings to adjust are based on your server’s resources:
In your /etc/php/8.1/fpm/pool.d/www.conf (adjust for your PHP version), you’ll find these parameters:
pm.max_children: The maximum number of PHP-FPM processes that can run at the same time.pm.start_servers: The number of processes to start when PHP-FPM starts.pm.min_spare_servers and pm.max_spare_servers: The minimum and maximum idle processes.pm.max_childrenThe value of pm.max_children depends on the available RAM and the average memory usage of each PHP process. Here’s how you can calculate it:
Check Available RAM: Use the following command to check your server’s available memory:
free -m
For example, if you have 4 GB RAM, reserve some memory for the system and MySQL (let’s say 1.5 GB), leaving 2.5 GB for PHP.
Determine Average PHP Process Memory: Use top or htop during peak usage to monitor the memory usage of a PHP-FPM process. Let’s say each process uses 50 MB.
Calculate pm.max_children:
Divide the available memory for PHP by the average memory usage per process:
pm.max_children = Available RAM for PHP / Memory per PHP Process
Example:
pm.max_children = 2500 MB / 50 MB = 50
So, you’d set:
pm.max_children = 50
Here’s a good starting point for your setup:
pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 15
Monitor your server during peak traffic and adjust as needed.
On the WordPress side of things, make sure ot remove any plugins or themes you’re not using. Extra plugins not only slow down your site but also increase resource usage. Stick to lightweight, well-maintained plugins.
One other thing that you can consider is using a managed database cluster to offload the database load from your server. This can help improve performance and scalability:
Finally, if traffic spikes are consistent and you’re maxing out resources, here are your options:
Hope that this helps!
- Bobby
Heya,
I would try and focus on Nginx:
worker_connections: Your worker_connections 1024; is the default but may be insufficient for high traffic. Update it to a higher value based on your server’s capacity:events {
worker_connections 4096; # Or higher based on load
}
Enable fastcgi_cache: Set up fastcgi_cache to cache PHP responses directly at the Nginx level:
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout updating http_500 http_503;
server {
...
location ~ \.php$ {
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 200 60m;
fastcgi_cache_bypass $http_cookie;
fastcgi_no_cache $http_cookie;
...
}
}
Fine-tune keepalive_timeout: Reduce keepalive_timeout to balance performance and resource usage:
keepalive_timeout 15;
Adjust client_body_buffer_size and fastcgi_buffers: Optimize handling large POST requests:
client_body_buffer_size 128k;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
Also, PHP-FPM
Dynamic process management: Set pm to dynamic and adjust the limits:
pm = dynamic
pm.max_children = 50 # Based on available RAM
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 15
pm.max_children based on this formula:
(Available RAM - other services) / average memory per PHP processHeya, @9987865f2fda44d1addb55c8e16ed4
You can also check the following articles:
Also you can run a script like the MySQL tunner to recommend optimised values for MySQL/MariaDB. There is a mini-tutorial which you can check here:
https://www.digitalocean.com/community/tutorials/how-to-optimize-wordpress-on-ubuntu
Hope that this helps! Happy holidays!