Home > Article > Backend Development > How to set the number of concurrent apache_PHP tutorial
Slow website response is not necessarily a problem with the program or database. If there is a problem with the concurrent number of apache, it will also lead to excessive website traffic. When requests are particularly slow or fail, how do you set the number of concurrent apache requests?
1. Modify the httpd.conf file
#Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf
Remove the # comment in the above sentence
2. Determine what MPM mode the current apache is (winnt mode, perfork mode, worker mode)
Enter the apache/bin directory
cmd command: httpd.exe -1
Note: Look at mpm_xxx.c. If xxx is winnt, it means winnt. It may also be perfork or worker
3. Modify the httpd-mpm.conf file
# WinNT MPM
# ThreadsPerChild: constant number of worker threads in the server process
# MaxRequestsPerChild: maximum number of requests a server process serves
ThreadsPerChild 150 //Just modify this value
MaxRequestsPerChild 0
4. Restart apache and test it
Under Linux, the generally used MPM is perfork mode
StartServers 5 5 //Start 5 processes in advance
MinSpareServers 5 5 //Minimum idle process
MaxSpareServers 10 //Maximum idle process
MaxClients 150 //Number of concurrent connections
MaxRequestsPerChild 0 //Refers to how many threads can be started in a process, which is better for workers, 0 means no limit
Give you a reasonable recommended configuration. For some websites and medium-sized websites, the configuration is:
StartServers 5 5 //Start 5 processes in advance
MinSpareServers 5 5 //Minimum idle process
MaxSpareServers 10 //Maximum idle process
ServerLimit 1500 // Used to modify apache programming parameters
MaxClients 1000 //Number of concurrent connections
MaxRequestsPerChild 0 //Refers to how many threads can be started in a process, which is better for workers, 0 means no limit
If your website’s pv is worth millions, you can set it like this:
ServerLimit 2500 // Used to modify apache programming parameters
MaxClients 2000 //Number of concurrent connections