Apache优化内存占用方法 (运维网)
编辑Apache\conf\httpd.conf 。。#
#
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进程也是要消耗资源的 这是一个平衡问题 。。
要根据你电脑的配置以及综合情况决定 。。。
页:
[1]