M
M
Max2019-10-01 11:53:03
linux
Max, 2019-10-01 11:53:03

Apache optimization. How to increase the maximum number of Apache Connects?

Good afternoon! There is a loaded north, I can’t figure out the optimization, tell me please. Please do not advise to kill an Indian, an Indian is needed because of the specifics of the sites!
5d930ff30a41e464626519.png
connections regularly rest against the ceiling of 300, although it costs 400 in the config.
Why is this and what should be changed? UPD - I sort of understood, I need to set ServerLimit more, although I didn’t try to figure it out for how long I didn’t understand what these values ​​​​mean lower, it’s not clear what ServerLimit means in particular and why so many Apache processes are created (sometimes I saw 300+, hung, only Apache restart helped).
The config is as follows (apache in prefork mode):

<IfModule mpm_prefork_module>
    StartServers          8
    MinSpareServers       5
    MaxSpareServers      20
    ServerLimit         256
    MaxClients          400
    MaxRequestsPerChild 10000
</IfModule>

1. Theoretically, if I understand correctly, I can have MaxSpareServers
20 parallel servers (Apache processes) with the current config, with each of them holding up to ServerLimit 256 connections, but a maximum of MaxClients400? And MaxRequestsPerChildthis is the number of requests to one of the servers, after which it will be killed, and a new one will be launched? Did I get it right?
2. How to distinguish ApacheServer those that are specified in the config as StartServersfrom the Child thread of this server?
3. I have a large load on HDD disks, because of this, as I understand it, the CPU is heavily loaded, but there are 20 GB free (40 out of 64 are taken by MYSQL).
Zabbix chart
5d93133daa847032873701.png
But 1 Apache process can eat up to 200 MB of RAM. This is due to the fact that I have about 2 GB of PHP code (there are many wordpress sites), and it costs php opcache, so the memory consumed per process starts to grow very quickly.
Memory per Apache process = 53MB, total 6500MB
[email protected]:~# ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Process Size (MB): "x/((y-1)*1024)}'
Apache Memory Usage (MB): 6487.27
Average Process Size (MB): 53.1743

At the same time, my users usually make piece requests, and there are hundreds of sites. How to do it right:
3.1 Make MaxRequestsPerChild= 100000+ , then there will be only MaxSpareServers~ 100 maximum. each will take 200MB
3.2 Make MaxRequestsPerChild= 1000 and MaxSpareServers= 1000 which take only 20MB at startup, then the meaning of Opcache is lost or not? Why is OPcache needed because sites work very fast with it, but I do not understand the process of storing compiled code (where is it stored when it is killed?) and how to optimize it better.
Your contacts are welcome in Telegram, I will thank you and possibly turnkey work if you can explain everything to me and do it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Paul, 2019-10-01
@Meinl

The first step is to make sure that the MPM module is enabled at all.
And then follow https://oxpedia.org/wiki/index.php?title=Tune_apac...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question