Hi Digital Ocean community,
This thread is like an update from my old one found here: https://www.digitalocean.com/community/questions/woocommerce-cdn-cache-advice-spaces-cdn-for-lon1-droplet-uk-only-target-audience-or-no-cdn-just-cache
This is my current setup:
This new setup has been running for nearly a month but the other day it crashed.
I would like to prevent this from happening!
Please can someone advise? What more can I do?
The server crashed when I was editing some products on a Woocommerce site. The site does’t get much traffic so not sure why it did.
Here’s the error logs from when the server crashed:
/var/log/apache2/error.log
[Fri Jul 28 14:51:47.238660 2023] [mpm_event:error] [pid 720372:tid 140080325052288] AH10159: server is within MinSpareThreads of MaxRequestWorkers, consider raising the MaxRequestWorkers setting
[Fri Jul 28 14:51:58.512767 2023] [mpm_event:error] [pid 720372:tid 140080325052288] AH00484: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
[Fri Jul 28 14:52:08.708321 2023] [proxy_fcgi:error] [pid 928099:tid 140080063239744] [client 35.241.215.102:0] AH01071: Got error 'PHP message: RedisException: read error on connection to 127.0.0.1:6379 in /var/www/html/wp-content/object-cache.php:2055\nStack trace:\n#0 /var/www/html/wp-content/object-cache.php(2055): Redis->mget()\n#1 /var/www/html/wp-content/object-cache.php(208): WP_Object_Cache->get_multiple()\n#2 /var/www/html/wp-includes/functions.php(7009): wp_cache_get_multiple()\n#3 /var/www/html/wp-includes/taxonomy.php(4015): _get_non_cached_ids()\n#4 /var/www/html/wp-includes/taxonomy.php(3685): _prime_term_caches()\n#5 /var/www/html/wp-includes/category-template.php(1295): get_object_term_cache()\n#6 /var/www/html/wp-content/plugins/woocommerce/includes/wc-term-functions.php(133): get_the_terms()\n#7 /var/www/html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php(465): wc_get_object_terms()\n#8 /var/www/html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.php(186): WC_Product_Data_Store_CPT->read_attributes()\n#9 /var/www/html/wp-content/plugins/wooco...'
/var/log/php8.0-fpm.log
[27-Jul-2023 13:03:23] WARNING: [pool www] server reached pm.max_children setting (45), consider raising it
[27-Jul-2023 13:38:20] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 13 idle, and 35 total children
[28-Jul-2023 11:06:26] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 12 idle, and 32 total children
[28-Jul-2023 11:06:27] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 9 idle, and 35 total children
[28-Jul-2023 14:50:26] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 8 idle, and 32 total children
[28-Jul-2023 14:50:40] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 14 idle, and 44 total children
[28-Jul-2023 14:50:41] WARNING: [pool www] server reached pm.max_children setting (45), consider raising it
[28-Jul-2023 14:58:47] WARNING: [pool www] server reached pm.max_children setting (45), consider raising it
I’ve made some adjustments to the server since the crash. I will share them here but please if someone who has a better idea than I do can you advise? Are the new settings good enough to prevent future crashes or I need to make it more resilient?
Current settings:
/etc/apache2/mods-enabled/mpm_event.conf
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
I’ve tried applying similar max_children settings found here: https://gist.github.com/josuamarcelc/24b279ee3c80612bf0316c03c379de71
/etc/php/8.0/fpm/pool.d/www.conf
pm = dynamic
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 45
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: (min_spare_servers + max_spare_servers) / 2
pm.start_servers = 15
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 15
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 25
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500
I’ve also raised the PHP memory_limit to 256.
I’m not sure if this is an issue but I will list it anyway. The shop archive pages load 16 images by default each product with approx 5 thumbnails each. They are lazy loaded so the server requests aren’t 16x5 at the same time but maybe if several users are on archives then loading them all will be too must for the server?
Thanks for any help!!
All advice is appreciated.
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.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hi there,
I’ve recently answered a similar question here:
It sounds like you’ve already done some very good work to optimize most of the standard things.
There are a few other things that I could suggest:
Consider removing any plugins that are not critical for your site. for example, I know that Jetpack could sometimes increase the memory consumption of your website and considering that you only have 2GB of RAM that might be an issue. Removing any other plugins that are not used could also be beneficial.
Once you’ve added the swap file, follow the steps form this answer here on how to use the MySQL tuner script to analyze your MySQL database and make the recommended changes:
In some cases, if you allocate too much resources to MySQL it could explain the 90% memory consumption.
I would also recommend using the
htop
command to see which service exactly is consuming the majority of the resources:Let me know how it goes!
Best,
Bobby