New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Help Maximize Apache Prefork MPM
Anyone can share prefork config, so i have problem cant maximize my ram and cpu. in my case i have a lots of request but in different pages, kind of news website. like 1-2 view on one page but a lot of pages.
My server had 32Gb ram, but only use 16Gb and load is only 0.5 on its peak traffic of websites. but after a day its always timeout in 60s on every request, so i need to restart apache2 service. how i can optimize prefork, really i need prefork and not other mpm, already try mpm event but the case is same.
Here my prefork config:
<IfModule mpm_prefork_module>
StartServers 8
ServerLimit 512
MaxClients 512
MinSpareServers 5
MaxSpareServers 20
MaxRequestWorkers 256
MaxRequestsPerChild 5120
MaxConnectionsPerChild 0
</IfModule>
Comments
Why would you use prefork and not event ? even worker is better.
i use mpm event on some server, the problem is similiar but with 503 on php-fpm, i limit it to use 24Gb. so on other, i use prefork and seem same for me. the problem is same, after a day its become timeout or 503 code.
most websites on pages has a lot of images, 20-100, kind of gallery. already optimize it using cdn, but it work after had few request on each cdn location.
the problem i think on a lot of request on different pages.
still cant figure it out whick config should i modify, restart it service with cronjob should be not solution.
what's the keep alive setting?
make sure you have proper timeouts and limits to have processes die, if not needed or stuck.
this means don't increase but decrease, especially if you have enough ressources to cope with the slightly higher load that might happen from the need to spawn fresh processes more often.
install something like monitorix to see how the number of apache processes evolve over time.
ps: also check your php settings for high (nonsense) timeouts on execution time and stuff, which might hold apache processes occupied.
i use deafult, keepalive is on and 300 for timeout. should i change to 30 or 60 for timeout. just install monitorix and wait a day for data.
exactly, i need to spawn fresh processes more often as possible. which prefork config should i modify. thanks
300 seconds = 5 minutes, I'm pretty sure there is no page that takes 5 minutes to load.
Just down it to 30 seconds max.
If you are looking for performance, go with nginx (easy to install with Centminmod) or openlitespeed (easy to install with CyberPanel).
Is your website wordpress based?
I suggest to decrease keepalive to only a few seconds or turn it off completly! keepalive essentially keeps the connection reserved for requests coming in from the same client...
I use something like 3 seconds so the same client can reuse this connection long enough to not need apache to server the next request from another child process.
imagine it this way: a child process will be blocked for 300 seconds after e.g. a page was loaded, just waiting, if the same client reappears. IMHO one of the worst settings at all, if done wrong ;-)
same goes for max-execution time with php, people often tend to set this sky-high because they ran into a timeout once during a upload from a bad connection or something like that. if any other php script later got stuck in a loop it will take ages to time out and block the whole apache process too (because it's prefork). probably something like 180sec or less could be reasonable?
of course all settings depend on use case and specific needs of your page, so consider this only ideas on where to start looking. ;-)
PS: just checked, I am using something like this on a prefork server, notice the difference between timeout and keepalivetimeout setting ...
yes, few using wordpress but mostly using laravel. i will try to decrease to 60 then, most of check website use this value.
thanks for you insight, really appreciate. i think should not be a problem for backend for 60 timeout, mostly update post is fast enough and upload an images use multi-threading.
i'll try this config a day, i'll update if its solve the problem. thanks
Move to event, or worker. Prefork handles 256 as standard and no more than that.
And perhaps php-fpm + nginx instead?
This. I've optimised a heavy load website a while back. It was a local news website which ran on a VPS. Also, try something like memcached
If you don't require to use custom htaccess rules, or if you are able to convert them:
Centminmod (Nginx + PHP-FPM) :
CyberPanel (OpenLiteSpeed) :
For Wordpress -> LiteSpeed Cache (It's the best AIO free plugin, caches pages, minifies css/js, optimizes images, integrates CDNs)
Easiest to use : CyberPanel
Safest : CentminMod - comes with more security by default, some stuff that I end up disabling cause it blocks the installation of some wp plugins.
Speed : Both, and you will run out of CPU/IO/Bandwidth before hitting 16GB of RAM.
If you need any help PM me, I'll help with anything I can
mostly i using laravel, but on some i also need a custom .htaccess rules and manipulation path. so nginx dont work for me, i try and ask helping but nginx rules not work in this thread
thanks you, but currently im not considering panel cause in the end i must edit vhost, custom path and compability issues. except its using command line panel.
is CentminMod can use nginx as proxy and apache. i use easyengine a few years ago, and seem not maintened and move to ansipress and i think not ready yet.