• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Apache & PHP-FPM running out of memory

excede

New Pleskian
Server operating system version
CentOS Linux 7.9.2009 (Core)
Plesk version and microupdate number
Plesk Obsidian v18.0.43_build1800220414.18 os_CentOS 7
We need help, and happy to pay for an expert!
Our Apache & PHP-FPM memory usage is constantly being exceeded and we cant see why. We are running wordpress/woocommerce and the server keeps on going down requiring a reboot to refresh the memory. We are on a very fast server with loads of RAM and have tried increasing the limits significantly in the PHP.INI and Plesk setting but same problem prevails.

If anyone can make suggestions to fix this it would be appreciated but we also need an expert to look at the whole server setup, if that's you please get in touch.
 

Attachments

  • Screen Shot 2022-05-15 at 2.05.58 pm.png
    Screen Shot 2022-05-15 at 2.05.58 pm.png
    129.2 KB · Views: 44
Hi,

We need a little more info.

- what are the PHP-settings?
- which PHP-handler do you use?
- do you use Apache with nginx?
- what are the PHP-FPM-settings, like pm.max_children?
- do you use a cache plugin for the WP sites like W3 Total Cache?
- have you checked the access_ssl_log for bots or lots of POSTs coming from the same IP address?
- have you checked the error_logs for AH0XXXX errors?
 
Last edited:
have tried increasing the limits significantly in the PHP.INI and Plesk setting
Wrong approach. Set it to a reasonable limit. Normally no more than 512 MB, better less. Only very few scripts need more RAM per script execution. The RAM you set in PHP is always "per execution". So if you allow a script to consume a lot of RAM and that script is faulty, it will consume a lot of RAM so that others don't have enough left. The same is true for execution time limits. Make sure that run-away scripts are stopped by setting short execution time limits, such as 10 to 20 seconds. For normal scripts this is sufficient.

Else as said before, more details are needed to get to the root cause. Have you checked your access_ssl_log whether your server receives many requests from bad bots or maybe is under attack?
 
Hi,

We need a little more info.

- what are the PHP-settings?
- which PHP-handler do you use?
- do you use Apache with nginx?
- what are the PHP-FPM-settings, like pm.max_children?
- do you use a cache plugin for the WP sites like W3 Total Cache?
- have you checked the access_ssl_log for bots or lots of POSTs coming from the same IP address?
- have you checked the error_logs for AH0XXXX errors?
Hi There, I appreciate you taking the time to respond but I am not technical enough to answer all of those questions which is why I am offering to pay for an expert to look into and diagnose the issue. Here are my best answers:

- what are the PHP-settings?
attached

- which PHP-handler do you use?
?

- do you use Apache with nginx?
yes

- what are the PHP-FPM-settings, like pm.max_children?
attached

- do you use a cache plugin for the WP sites like W3 Total Cache?
no

- have you checked the access_ssl_log for bots or lots of POSTs coming from the same IP address?
no

- have you checked the error_logs for AH0XXXX errors?
no
 

Attachments

  • Screen Shot 2022-05-16 at 9.29.23 am.png
    Screen Shot 2022-05-16 at 9.29.23 am.png
    153.8 KB · Views: 61
  • Screen Shot 2022-05-16 at 9.29.32 am.png
    Screen Shot 2022-05-16 at 9.29.32 am.png
    42.4 KB · Views: 56
Hi There, I appreciate you taking the time to respond but I am not technical enough to answer all of those questions which is why I am offering to pay for an expert to look into and diagnose the issue. Here are my best answers:

- what are the PHP-settings?
attached

- which PHP-handler do you use?
?

- do you use Apache with nginx?
yes

- what are the PHP-FPM-settings, like pm.max_children?
attached

- do you use a cache plugin for the WP sites like W3 Total Cache?
no

- have you checked the access_ssl_log for bots or lots of POSTs coming from the same IP address?
no

- have you checked the error_logs for AH0XXXX errors?
no

I just updated the setting to this but I have no clue what I'm doing!
 

Attachments

  • Screen Shot 2022-05-16 at 10.05.47 am.png
    Screen Shot 2022-05-16 at 10.05.47 am.png
    117 KB · Views: 50
  • Screen Shot 2022-05-16 at 10.06.31 am.png
    Screen Shot 2022-05-16 at 10.06.31 am.png
    33 KB · Views: 50
Here is a screenshot of the memory usage over 12 months, you can see the steady growth over that time and the limit being reached which is causing the issues we have now.

So my question is (and I've tried): how do I increase the red line to 20 Gib?
 

Attachments

  • Screen Shot 2022-05-16 at 12.58.46 pm.png
    Screen Shot 2022-05-16 at 12.58.46 pm.png
    56.1 KB · Views: 31
  • Screen Shot 2022-05-16 at 12.58.34 pm.png
    Screen Shot 2022-05-16 at 12.58.34 pm.png
    335.8 KB · Views: 34
You can increase the threshold settings by going to
Monitoring -> Memory -> top right settings -> threshold and adjust the "Apache & PHP-FPM memory usage"

1652690795547.png
 
You can increase the threshold settings by going to
Monitoring -> Memory -> top right settings -> threshold and adjust the "Apache & PHP-FPM memory usage"

View attachment 20826
Ok thanks for that. Is there a way to stop the memory climbing or excessive memory usage? It seems the server just stops working when the threshold is exceeded.
 
I just updated the setting to this but I have no clue what I'm doing!
max.children: If all are busy and an additional request comes in, the server won't be able to respond to that request. For that reason it is important to make sure that running processes are not running very long. You can (and should) increase the max.children number a bit, e.g. to 15 or 25 or so, so that your server can still respond to further incoming requests even if it is quite busy with existing requests.

max.requests: A child process will get killed when this number is reached, then a new child instance will be created (until max.children in concurrent children is reached). A single PHP-FPM instance (child) can handle several thousand requests before it needs to get killed. You can set this to a high value such as 5000 or 10000. Too frequent instance-killings only costs valuable cpu slices. A number too high however will give less protection against memory leaks. 100 is too small though, rather start off with a few thousand.

Logs need to be checked for bad bots.

Are you using Fail2Ban on this server? Maybe it is not on or a jail is not on so that brute-force attacks can continue and can cause the high load. Also I recommend to block bad bots. The simple way is adding these lines to the beginning of the .htaccess file of your website:
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (seocompany|LieBaoFast|SEOkicks|Uptimebot|Cliqzbot|ssearch_bot|domaincrawler|AhrefsBot|spot|DigExt|Sogou|MegaIndex.ru|majestic12|80legs|SISTRIX|HTTrack|Semrush|MJ12|MJ12bot|MJ12Bot|Ezooms|CCBot|TalkTalk|Ahrefs|BLEXBot) [NC]
RewriteRule .* - [F]
But there are better ways, e.g. blocking them via Fail2Ban or via Nginx. More complicated though, leave that to an expert on your server.
 
Thanks Peter, I appreciate the detail as it gives me more of an idea and will try to work with that information as best I can. I definitely will use your expert though as it is out of my depth!
 
Back
Top