Search code examples
linuxapachehttpwebserverram

Calculating the RAM required for Apache to respond to a large number of requests


I want to investigate how much RAM a single process consumes when apahce is under load.
And I need to know the amount of RAM that can respond to 10,000 concurrent HTTP requests without delay.

I am using the following versions of Apache:

httpd -V
Server version: Apache/2.4.37 (Red Hat Enterprise Linux)
Server built:   Jun 15 2022 08:27:14
Server's Module Magic Number: xxxxxxxx:xx
Server loaded:  APR 1.6.3, APR-UTIL 1.6.1
Compiled using: APR 1.6.3, APR-UTIL 1.6.1
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)

I have the following settings:

<IfModule mpm_event_module>
    StartServers 3
    ServerLimit 3
    ThreadsPerChild 25
    MaxRequestWorkers 75
</IfModule>

With the above settings, I expect 4 processes (1 parent + 3 child).

But for some reason parent process 1 + child process 5 start.

ps  -ylC httpd
S   UID     PID    PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S     0  877361       1  1  80   0 62512 85183 -      ?        00:00:00 httpd # Parent
S    48  877362  877361  0  80   0 56156 88418 -      ?        00:00:00 httpd # Child1
S    48  877363  877361  0  80   0 56228 88762 -      ?        00:00:00 httpd # Child2
S    48  877364  877361  0  80   0 66152 713989 -     ?        00:00:00 httpd # Child3
S    48  877365  877361  0  80   0 64104 648435 -     ?        00:00:00 httpd # Child4
S    48  877366  877361  0  80   0 64104 664819 -     ?        00:00:00 httpd # Child5

When a large number of Http requests are sent and load is applied, only Child3, 4, 5 RSS increases.

ps  -ylC httpd
S   UID     PID    PPID  C PRI  NI   RSS    SZ WCHAN  TTY          TIME CMD
S     0  877361       1  0  80   0 62512 85183 -      ?        00:00:00 httpd # Parent
S    48  877362  877361  0  80   0 56164 88418 -      ?        00:00:00 httpd # Child1
S    48  877363  877361  0  80   0 56236 88762 -      ?        00:00:00 httpd # Child2
S    48  877364  877361  0  80   0 86996 713989 -     ?        00:00:02 httpd # Child3 : RSS increased
S    48  877365  877361  0  80   0 83868 648435 -     ?        00:00:02 httpd # Child4 : RSS increased
S    48  877366  877361  0  80   0 85908 664819 -     ?        00:00:02 httpd # Child5 : RSS increased

What are the Child1 and Child2 processes doing?

Child3,4,5 RSS average: (86996KB+83868KB+85908KB)/3≒85MB

From the above, when the load is high due to a large number of accesses at once, processing is performed with 25 threads per process, and 85 MB is consumed per process at that time.

10000/25*85MB=34GB

Does that mean I need roughly 34GB of RAM to respond to 10000 concurrent requests without delay? (Of course, it's not strict, but a rough value is OK.And assume that memory is the bottleneck and traffic, RDBMS, and other resources like CPU are all sufficient.)

Thanks in advance.


Solution

  • The following website has convinced me that I am on the right track.

    https://kb.vmware.com/s/article/1036729

    Example: Suppose using worker you have set ThreadsPerChild 25 and MaxClients 50, and the two child processes each use 128MB of RAM and 5% of CPU under full load. You can roughly expect 8 children (MaxClients 200 = 25 x 8) to use 1GB of RAM and 40% of CPU under full load.