Apache : Concurrent threads, Idle threads, max and min possible threads ( Max and Min connections )
Based on the MPM ( multi processing modules ) your apache web server is using, below are the important parameters those governs all these configurations
# StartServers : initial number of server processes to start
# MaxClients : maximum number of simultaneous client connections
# MinSpareThreads : minimum number of worker threads which are kept spare
# MaxSpareThreads : maximum number of worker threads which are kept spare
# ThreadsPerChild : constant number of worker threads in each server process
# MaxRequestsPerChild : maximum number of requests a server process serves
For example -
ServerLimit 16StartServers 2MaxClients 200MinSpareThreads 25MaxSpareThreads 75ThreadsPerChild 251. First of all, whenever an apache is started, it will start 2 child processes which is determined by
StartServers parameter. 2. Then each process will start 25 threads determined by
ThreadsPerChildparameter so this means 2 process can service only 50 concurrent connections/clients i.e. 25x2=50. 3. Now if more concurrent users comes, then another child process will start, that can service another 25 users.
4. But how many child processes can be started is controlled by
ServerLimit parameter, this means that in the configuration above, I can have 16 child processes in total, with each child process can handle 25 thread, in total handling 16x25=400 concurrent users. 5. But if number defined in
MaxClients is less which is 200 here, then this means that after 8 child processes, no extra process will start since we have defined an upper cap of
MaxClients. 6. This also means that if I set
MaxClients to 1000, after 16 child processes and 400 connections, no extra process will start and we cannot service more than 400 concurrent
clients even if we have increase the
MaxClient parameter. In this case, we need to also increase ServerLimit to 1000/25 i.e. MaxClients/ThreadsPerChild=40 So this is the optmized configuration to server 1000 clients
So, the good configuration will be
<IfModule mpm_worker_module> ServerLimit 40 StartServers 2 MaxClients 1000 MinSpareThreads 25 MaxSpareThreads 75 ThreadsPerChild 25 MaxRequestsPerChild 0</IfModule>
No comments:
Post a Comment