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

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

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

问题

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

我正在使用以下版本的Apache:

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

我有以下设置:

  1. <IfModule mpm_event_module>
  2. StartServers 3
  3. ServerLimit 3
  4. ThreadsPerChild 25
  5. MaxRequestWorkers 75
  6. </IfModule>

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

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

  1. ps -ylC httpd
  2. S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
  3. S 0 877361 1 1 80 0 62512 85183 - ? 00:00:00 httpd # 父进程
  4. S 48 877362 877361 0 80 0 56156 88418 - ? 00:00:00 httpd # 子进程1
  5. S 48 877363 877361 0 80 0 56228 88762 - ? 00:00:00 httpd # 子进程2
  6. S 48 877364 877361 0 80 0 66152 713989 - ? 00:00:00 httpd # 子进程3
  7. S 48 877365 877361 0 80 0 64104 648435 - ? 00:00:00 httpd # 子进程4
  8. S 48 877366 877361 0 80 0 64104 664819 - ? 00:00:00 httpd # 子进程5

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

  1. ps -ylC httpd
  2. S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
  3. S 0 877361 1 0 80 0 62512 85183 - ? 00:00:00 httpd # 父进程
  4. S 48 877362 877361 0 80 0 56164 88418 - ? 00:00:00 httpd # 子进程1
  5. S 48 877363 877361 0 80 0 56236 88762 - ? 00:00:00 httpd # 子进程2
  6. S 48 877364 877361 0 80 0 86996 713989 - ? 00:00:02 httpd # 子进程3:RSS增加
  7. S 48 877365 877361 0 80 0 83868 648435 - ? 00:00:02 httpd # 子进程4:RSS增加
  8. 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:

  1. httpd -V
  2. Server version: Apache/2.4.37 (Red Hat Enterprise Linux)
  3. Server built: Jun 15 2022 08:27:14
  4. Server&#39;s Module Magic Number: xxxxxxxx:xx
  5. Server loaded: APR 1.6.3, APR-UTIL 1.6.1
  6. Compiled using: APR 1.6.3, APR-UTIL 1.6.1
  7. Architecture: 64-bit
  8. Server MPM: event
  9. threaded: yes (fixed thread count)
  10. forked: yes (variable process count)

I have the following settings:

  1. &lt;IfModule mpm_event_module&gt;
  2. StartServers 3
  3. ServerLimit 3
  4. ThreadsPerChild 25
  5. MaxRequestWorkers 75
  6. &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.

  1. ps -ylC httpd
  2. S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
  3. S 0 877361 1 1 80 0 62512 85183 - ? 00:00:00 httpd # Parent
  4. S 48 877362 877361 0 80 0 56156 88418 - ? 00:00:00 httpd # Child1
  5. S 48 877363 877361 0 80 0 56228 88762 - ? 00:00:00 httpd # Child2
  6. S 48 877364 877361 0 80 0 66152 713989 - ? 00:00:00 httpd # Child3
  7. S 48 877365 877361 0 80 0 64104 648435 - ? 00:00:00 httpd # Child4
  8. 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.

  1. ps -ylC httpd
  2. S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
  3. S 0 877361 1 0 80 0 62512 85183 - ? 00:00:00 httpd # Parent
  4. S 48 877362 877361 0 80 0 56164 88418 - ? 00:00:00 httpd # Child1
  5. S 48 877363 877361 0 80 0 56236 88762 - ? 00:00:00 httpd # Child2
  6. S 48 877364 877361 0 80 0 86996 713989 - ? 00:00:02 httpd # Child3 : RSS increased
  7. S 48 877365 877361 0 80 0 83868 648435 - ? 00:00:02 httpd # Child4 : RSS increased
  8. 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:

确定