立即注册 登录
德国开元华人社区 开元周游 返回首页

taohui的个人空间 https://www.kaiyuan.info/?23661 [收藏] [复制] [分享] [RSS]

日志

Apache优化内存占用的方法

已有 799 次阅读29.3.2010 13:15 |个人分类:软件技术

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 50

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 10
 

KeepAliveTimeout 这个参数决定一个http进程在什么都不做之前能够等待多长时间,而一个apache进程完成了一个任务,并有了一定的内存占用(渐进模式)并不会马上退 出,而是等待一个keepalivetimeout时间。

若用户的链接请求持续不断的到来 则积累起来的无用的apache进程就会相当多,直到 timeout 这些进程才会被杀死。

但是 keepalive 对于静态的文件,比如图像文件的传送是很有效的,所以 keepalive 要设置为on,但是keepalvietimeout要设置得小些,比如10。

MaxRequestsPerChild 这个参数是表示,apache进程在处理了多少个请求之后必须退出,重新开始,以免在处理中的内存问题。

对于php脚本来说 把这个参数设置的小一些是有好处的,可以避免程序使用的内存持续增长对apache带来的压力。

让这个参数定期释放内存,因为php是在脚 本执行完毕后,自动释放只用的资源(内存)的,比如设置为50。如果太小的话,重新产生一个apache进程也是要消耗资源的,这是一个平衡问题。

要 根据你电脑的配置以及综合情况决定。

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

站点信息

站点统计| 举报| Archiver| 手机版| 小黑屋

Powered by Discuz! X3.2 © 2001-2014 Comsenz Inc.

GMT+1, 29.3.2024 00:25

关于我们|Apps

() 开元网

返回顶部