How can I prevent tons of apache processes spawning when I start apache and proceeding to kill my machine?

后端 未结 6 2113
执笔经年
执笔经年 2021-01-30 08:29

I have a highly trafficked application on one debian machine and apache has started acting strange.

Every time I start apache, tons of apache processes are spawned, the

6条回答
  •  渐次进展
    2021-01-30 08:56

    use ps -aux | grep apache to find out the number of processes that apache is running on. Look out for the "RSS" column which gives an estimate of the memory used by each process. Alternatively you can use "top", where you shift + f and then select the %MEM column to sort the processes by memory usage.

    The number of processes is determined by "MaxClients" directive in your apache.conf file. The way you come to this figure is as described by this page;

    1. SSH into your server as root.
    2. Run top.
    3. Press shift + m.
    4. Note the highest RES memory used by httpd.
    5. Hit Q to exit top.
    6. Execute: service httpd stop (In debian, sudo service apache2 stop)
    7. Once httpd is stopped, execute: free -m
    8. Note the memory listed under "used".
    9. Find the guaranteed memory for your VPS plan. Support can tell you how much you have guaranteed if you cannot find it.
    10. Subtract the memory USED from the memory that your plan is GUARANTEED. This will give you your base FREE MEMORY POOL.
    11. Multiply the value of your FREE MEMORY POOL by 0.8 to find your average AVAILABLE APACHE POOL (this will allow you a 20% memory reserve for burst periods).
    12. Divide your AVAILABLE APACHE POOL by the highest RES memory used by httpd. This will give you the MaxClients value that should be set for your system. (Round it to the nearest integer less than this value if it has a fraction component.)

    The right value for "MaxClients" will ensure the right memory allocation for your apache server. That's how I solved it.

    In Debian, apache conf file is at /etc/apache2/apache2.conf

提交回复
热议问题