标题:
[分享]
使用WDCP的小内存VPS内存占用优化的一点经验
[打印本页]
作者:
dmcountry
时间:
2014-6-3 12:12
标题:
使用WDCP的小内存VPS内存占用优化的一点经验
本帖最后由 dmcountry 于 2014-6-3 12:14 编辑
使用wdcp好久了,刚开始的VPS是512MB内存,安装wdcp后并开通网站后发现内存占用会逐步升高,最后直至耗尽。设置mysql优化的参数为“小内存VPS(256-512mb)”后并没有出现改观。中间又换了其他几个免费控制面板,也不太好用。不过,经过一段时间折腾后,终于找到了解决方法。这个解决方法在安装wdcp面板的VPS上通过,方法分享出来,供参考:
调试方法:修改apache配置文件httpd.conf(不同的主机控制面板可能该配置文件所处的目录不同)
对于安装wdcp的VPS,修改的文件是/www/wdlinux/httpd-2.2.22/conf/httpd-wdl.conf
在
httpd-wdl.conf
中找到<IfModule
mpm_prefork_module
>,这里就是apache在prefork模式下的参数段。将该段各值修改为以下数值:
<IfModule mpm_prefork_module>
ServerLimit 256
StartServers 2
MinSpareServers 2
MaxSpareServers 5
MaxClients 256
MaxRequestsPerChild 50
</IfModule>
最重要的占用内存的参数是标红的几个。
经过上述设置之后,httpd子进程数保持在最小2个,多余的进程在处理请求超过50个后自动销毁释放内存(这个数值不要设为0,否则http进程会一直不销毁),从而保证在正常流量下内存得以及时释放。这些数值可以根据需要适当调整,以适应内存大小。修改后重启apache服务生效。
各字段含义:
ServerLimit 最大客户数
StartServers 服务器启动时建立的子进程数量
MinSpareServers 最小空闲子进程数
MaxSpareServers 最大空闲子进程数
MaxClients 同一时间客户端最大接入请求的数量
MaxRequestsPerChild
每个子进程在其生存期内允许伺服的最大请求数量
经验原文写在了本人网贴里:
小内存VPS httpd参数优化
作者:
andy0792
时间:
2014-6-8 18:09
哇,有好东西,松果耶,赶紧收藏一下,嘿嘿
作者:
姑苏公子
时间:
2014-6-25 11:21
做个标记
<IfModule mpm_prefork_module>
ServerLimit 512
StartServers 5
MinSpareServers 3
MaxSpareServers 10
MaxClients 384
MaxRequestsPerChild 10
</IfModule>
作者:
Corning
时间:
2014-8-12 21:20
做个标记
<IfModule mpm_prefork_module>
ServerLimit 1024
StartServers 5
MinSpareServers 3
MaxSpareServers 30
MaxClients 1024
MaxRequestsPerChild 0
</IfModule>
作者:
超帅
时间:
2015-3-20 10:33
<IfModule mpm_prefork_module>
ServerLimit 1024
StartServers 5
MinSpareServers 3
MaxSpareServers 30
MaxClients 1024
MaxRequestsPerChild 500
</IfModule>
作者:
冰城渔民
时间:
2015-10-10 21:14
# apache conf conf/httpd-wdl.conf
# Created by
http://www.wdlinux.cn
# Last Updated 2010.06.01
Timeout 30
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 5
UseCanonicalName Off
ServerTokens Prod
ServerSignature Off
HostnameLookups Off
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php index.htm
<IfModule mpm_worker_module>
ServerLimit 32
ThreadLimit 256
StartServers 12
MaxClients 2048
MinSpareThreads 50
MaxSpareThreads 256
ThreadsPerChild 256
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_prefork_module>
ServerLimit 1024
StartServers 5
MinSpareServers 3
MaxSpareServers 30
MaxClients 1024
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_itk_module>
ServerLimit 1024
StartServers 5
MinSpareServers 3
MaxSpareServers 30
MaxClients 1024
MaxRequestsPerChild 0
</IfModule>
作者:
diaifu
时间:
2016-3-31 10:29
mark一下
作者:
chnspy
时间:
2016-11-26 16:53
做个标记
<IfModule mpm_prefork_module>
ServerLimit 1024
StartServers 5
MinSpareServers 3
MaxSpareServers 30
MaxClients 1024
MaxRequestsPerChild
100
</IfModule>
欢迎光临 WDlinux官方论坛 (http://wdlinux.cn/bbs/)
Powered by Discuz! 7.2