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

huangapple go评论64阅读模式
英文:

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

问题

我想调查当Apache处于负载状态时,单个进程消耗多少RAM。并且我需要知道可以响应10,000个并发的HTTP请求而没有延迟的RAM量。

我正在使用以下版本的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)

我有以下设置:

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

根据上述设置,我预期会有4个进程(1个父进程+3个子进程)。

但出于某种原因,父进程1和子进程5启动。

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 # 父进程
S    48  877362  877361  0  80   0 56156 88418 -      ?        00:00:00 httpd # 子进程1
S    48  877363  877361  0  80   0 56228 88762 -      ?        00:00:00 httpd # 子进程2
S    48  877364  877361  0  80   0 66152 713989 -     ?        00:00:00 httpd # 子进程3
S    48  877365  877361  0  80   0 64104 648435 -     ?        00:00:00 httpd # 子进程4
S    48  877366  877361  0  80   0 64104 664819 -     ?        00:00:00 httpd # 子进程5

当发送大量HTTP请求并施加负载时,只有子进程3、4和5的RSS增加。

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 # 父进程
S    48  877362  877361  0  80   0 56164 88418 -      ?        00:00:00 httpd # 子进程1
S    48  877363  877361  0  80   0 56236 88762 -      ?        00:00:00 httpd # 子进程2
S    48  877364  877361  0  80   0 86996 713989 -     ?        00:00:02 httpd # 子进程3:RSS增加
S    48  877365  877361  0  80   0 83868 648435 -     ?        00:00:02 httpd # 子进程4:RSS增加
S    48  877366  877361  0  80   0 85908 664819 -     ?        00:00:02 httpd # 子进程5:RSS增加

Child1和Child2进程在做什么?

Child3、4和5的平均RSS:(86996KB+83868KB+85908KB)/ 3 ≈ 85MB

从上面的信息来看,当因大量访问而负载较高时,每个进程会使用25个线程进行处理,此时每个进程会消耗85MB。

10000/25*85MB = 34GB

这是否意味着我需要大约34GB的RAM才能在没有延迟的情况下响应10,000个并发请求?
(当然,这不是严格的,但一个粗略的值是可以的。并且假设内存是瓶颈,流量、RDBMS和其他资源如CPU都足够。)

提前感谢您。

英文:

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&#39;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:

&lt;IfModule mpm_event_module&gt;
    StartServers 3
    ServerLimit 3
    ThreadsPerChild 25
    MaxRequestWorkers 75
&lt;/IfModule&gt;

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.

  • reference : <https://stackoverflow.com/questions/18317735/how-to-know-the-number-of-core-and-ram-required>

答案1

得分: 0

以下网站已经让我确信我走在正确的道路上。

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

> 例子:假设你使用 worker,设置了 ThreadsPerChild 为 25 和 MaxClients 为 50,而两个子进程在满负荷下分别使用 128MB 的 RAM 和 5% 的 CPU。你大致可以期望 8 个子进程(MaxClients 200 = 25 x 8)在满负荷下使用 1GB 的 RAM 和 40% 的 CPU。

英文:

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.

huangapple
  • 本文由 发表于 2023年6月13日 13:46:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76461986.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定