首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为设置MaxClients找到单个Apache进程的平均大小

为设置MaxClients找到单个Apache进程的平均大小
EN

Server Fault用户
提问于 2012-01-26 12:05:32
回答 2查看 27.3K关注 0票数 7

我在运行Apache的ubuntu10.4上尝试了pmap pgrep apache2 \grep,o/p如下所示:

共计47768 K

共计48048 K

共计48048 K

共计48048 K

共计48048 K

共计48048 K

这是否意味着每个子进程需要48 MB的RAM.Can,您可以帮助我找到每个process.Expecting的确切内存使用情况--一个答复。

EN

回答 2

Server Fault用户

发布于 2012-01-26 15:31:33

你真的不想知道计算出实际的内存占用是多么的复杂。

试着绘图

代码语言:javascript
运行
复制
ps -ef | grep httpd | wc -l

( httpd进程数)

中的第一个数字

代码语言:javascript
运行
复制
free | grep 'buffers/cache'

(使用的内存数量)。

对于不同的负载级别。

请记住,缓存很重要--如果您的the服务器执行任何I/O操作,那么缓存越少,它就会运行得越慢。作为一个粗略的经验规则,您希望将maxclient设置为小于80%内存用完的值。

票数 0
EN

Server Fault用户

发布于 2013-08-16 11:44:13

我复制了一个粘贴的家伙,

代码语言:javascript
运行
复制
<IfModule mpm_prefork_module>
StartServers 2
MinSpareServers 2
MaxSpareServers 5
MaxClients 200 #must be customized
ServerLimit 200 #must be customized
MaxRequestsPerChild 100
</IfModule>

KeepAlive Off

以下是一些解释:

代码语言:javascript
运行
复制
StartServers – this is how many apache instances should start at the very beginning when apache is started. I set it to 2, and it works fine for me.



MinSpareServers – minimum number of spare servers that should be running waiting for potential requests. MinSpareServers=2 worked fine for me too.



MaxSpareServers – maximum number of spare servers that should be running waiting for potential requests, obviously >= MinSpareServers. In my working example MaxSpareServers=5.



MaxClients & ServerLimit. You can use this shell script to determine an average amount of memory consumed by one Apache process. In addition to that it’ll show total amount of memory consumed by all Apache processes. Just unzip and execute as follows:

    wget http://cloudinservice.com/wp-content/uploads/2011/03/ap.sh.zip

    unzip ap.sh.zip

    sh ap.sh

The output will be something like that:

    Apache Memory Usage (MB): 1372.6
    Average Proccess Size (MB): 54.9041

Try to execute it several times to compare the numbers; good results will be shown when server is under a heavy load. Now when you know average amount of memory consumed by Apache and total amount of memory of your server, it is possible to calculate value to be used for MaxClients setting. For example, if in average one your Apache process consumes 50MB RAM and server RAM is 2GB, and you want to leave 512MB for the rest processes, then:
MaxClients = (2GB – 512MB)/50MB = 30.72 ~ 30.
ServerLimit is, as I understand, the same thing, but while MaxClient setting can be changed on the go without a need to restart Apache, for new ServerLimit value to take effect Apache restart is required. MaxClients should always be <= ServerLimit. To make it easy, I set ServerLimit = MaxClients calculated by above formula.

我感谢在她的网站上发布这条信息的女孩。果酱

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/353828

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档