Apache uses one of following MPM(Multi-Processing Module) for handling incoming requests and processes them. It modifies basic functionality of the Apache server related to multi-thread and multi-processes style of working. Only one MPM can be loaded into the server at any time.
Types of MPM’s :-
- Prefork MPM
- Worker MPM
- Event MPM
Command to check MPM: httpd –V
Number of connection calculation as per core
CPU.
The
MaxClients is optimal at 200 * the count of CPU cores for the prefork mpm &
300 * the
count of CPU cores for the workermpm.
Below is the
snapshot of "httpd-mpm.conf" file.
<IfModule
mpm_worker_module>
ThreadLimit 30
ServerLimit 10
StartServers 3
MinSpareThreads 5
MaxSpareThreads 20
MaxClients 300
ThreadsPerChild 30
MaxRequestsPerChild 0
</IfModule>
Let’s understand the above MPM_worker _module configuration.
1. Server will going to start with “3” child
processes ( i.e StartServers = 3)
Which
is called as number of child processes during start.
2. Where
each child processes will start handling “30” threads/Requests.
(i.e ThreadsPerChild
= 30)
3. So total
number of concurrent connection/clients = “90”
(i.e StartServers * ThreadsPerChild = concurrent connection/clients at start [3*30=
90])
Total = 90 concurrent connection/clients
4. If more concurrent users where to come then another child
process will go to start/add.
5. As already “3” child processes where consumed/busy
, so another child processes where going to start as per “ServerLimit” ( i.e we have ServerLimit = 10).
6. So total number of max Connections/clients can be serve = 300
( i.e ServerLimit * ThreadsPerChild , 10*30 = 300 MaxClients )
7. A “ServerLimit” can be calculated, As ServerLimit
= MaxClients / ThreadsPerChild
(i.e ServerLimit= 300/30)
8. A “ThreadLimit” where stands for Number of threads on per
child processes.
9. “MinSpareThreads” where stands for minimum
number of worker threads which are kept spare, Sets the desired minimum number
of idle [free] child server processes)
10. If MaxRequestsPerChild / MaxConnectionsPerChild is 0,
then the process will never expire.
The recommended value of maxThreads & MaxClients is 200 per CPU, so here we assume the server is a single core machine.
If it had been quad core, we could push that value to 800 or more depending on RAM and other machine specs.
The total threads is an aggregate value. If Apache and JBoss are on the same server, and that server has four cores, then you would halve the maxThreads and MaxClients to 400 each.
Always ensure the total threads possible doesn't exceed 200 times the number of CPU cores.
Reference links:
No comments:
Post a Comment