Hello DigitalOcean Community,
I’m currently managing several WordPress sites hosted on a single droplet, and I’ve started noticing some performance issues as traffic has grown over the past few months. Here are my droplet specs:
The sites run well under normal conditions, but during traffic spikes (especially after publishing new content or during campaigns), I face issues like:
I suspect my Nginx configuration might not be fully optimized for hosting multiple WordPress sites under high traffic. Here’s my current configuration:
worker_processes auto; events { worker_connections 1024; } http { client_max_body_size 100M; keepalive_timeout 65; sendfile on; gzip on; gzip_types text/plain application/javascript application/json text/css; }
How can I optimize Nginx settings for multiple WordPress sites? Are there specific tweaks or best practices to make Nginx handle dynamic WordPress content more efficiently?
Is caching enough to reduce server load significantly? I’ve been looking into caching plugins like WP Super Cache and object caching with Redis. Should I prioritize server-side caching over WordPress plugins, and how should I implement it?
Should I upgrade the droplet or scale horizontally? Would adding a load balancer or distributing sites across multiple droplets be more effective than upgrading the current droplet?
How do I handle PHP-FPM tuning? I suspect the current PHP-FPM settings are not optimized for handling multiple WordPress sites. What values should I adjust to reduce bottlenecks?
What are some DigitalOcean-specific tools or resources I can use? I’ve explored tutorials on DO, but I’m wondering if there are best practices or tools specific to droplets hosting WordPress sites that I might have overlooked.
If anyone has experience running high-traffic WordPress sites on DigitalOcean, I’d love to hear your insights or see examples of your optimized configurations.
Thanks for your time and help!
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: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:
Key PHP-FPM Settings
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
andpm.max_spare_servers
: The minimum and maximum idle processes.How to Calculate
pm.max_children
The 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:
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
orhtop
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:Example:
So, you’d set:
Here’s a good starting point for your setup:
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:
🔗 Managed Databases
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
: Yourworker_connections 1024;
is the default but may be insufficient for high traffic. Update it to a higher value based on your server’s capacity:Enable
fastcgi_cache
: Set upfastcgi_cache
to cache PHP responses directly at the Nginx level:Fine-tune
keepalive_timeout
: Reducekeepalive_timeout
to balance performance and resource usage:Adjust
client_body_buffer_size
andfastcgi_buffers
: Optimize handling large POST requests:Also, PHP-FPM
Dynamic process management: Set
pm
todynamic
and adjust the limits:pm.max_children
based on this formula:(Available RAM - other services) / average memory per PHP process
Heya, @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/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability
https://www.digitalocean.com/community/tutorials/how-to-optimize-wordpress-on-ubuntu
https://www.digitalocean.com/community/tutorials/how-to-speed-up-wordpress-asset-delivery-using-digitalocean-spaces-cdn
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-remote-database-to-optimize-site-performance-with-mysql-on-ubuntu
Hope that this helps! Happy holidays!