I manage a high-traffic(1200 request per min), large-scale WordPress website with a dedicated MySQL server. The server has 32GB RAM and a 16-core CPU ubuntu 22.04 LTS.
I've configured Apache and PHP-FPM with the following settings:
Apache (MPM Event) Configuration:
<IfModule mpm_event_module> StartServers 8 MinSpareThreads 32 MaxSpareThreads 96 ThreadLimit 32 ThreadsPerChild 32 MaxRequestWorkers 256 MaxConnectionsPerChild 10000 </IfModule> PHP-FPM Configuration:
pm.max_children = 200 pm.min_spare_servers = 10 pm.max_spare_servers = 40 pm.max_spawn_rate = 32 pm.max_requests = 500 Each PHP-FPM process consumes around 200MB of memory. Initially, when checking with htop, memory usage is about 3.5GB out of 32GB. However, after 5-6 days, memory usage increases to 24GB, even though no other major services are running on the VM. It seems that Apache or PHP-FPM is not properly releasing memory.
After rebooting the VM again it down to the 3 to 4 GB and and next day when i checked it display around 5 -6 GB consumed. Ideally it should remain constant and I do not want to restaring the service or rebooting the VM at every week.
I've experimented with different pm and mpm settings, but the issue persists. How can I identify the root cause and optimize memory usage effectively?
Thank you.