Apache 持续利用更多内存
我有一个相当大的网站在centos服务器上运行。它执行大量 shell 命令并运行大量 MySQL 查询。一切看起来都很好。运行得很好。但与此同时,Apache 正在连续使用大量内存。据我所知,一旦脚本执行完成,Apache 使用的内存就应该被释放,但在我的例子中情况并非如此。
我的代码中是否存在某种问题,导致 Apache 使用更多内存,或者我还应该检查其他内容吗?
I have a quite large website running in centos server. It carries out a lot of shell commands and runs a lot of MySQL queries. Everything seems fine. Running quite well. But at the same moment Apache is utilizing a lot of memory continuously. As far as I know the memory utilized by Apache should be freed once the script execution is completed but it's not like that in my case.
Is this some kind of problem in my code that makes Apache utilize more memory or should I be checking other stuff also?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,Apache 进程不会返回 mod_php 使用的内存。您必须偶尔重新启动/回收 Apache 进程。查看配置值 MaxRequestsPerChild 它将自动为您执行此操作(如果我没记错的话,CentOS 上默认是关闭的)。
将其设置为较低的值,但不要太低,因为回收成本很高。几百个可能就可以了。
Unfortunately Apache processes won't return memory used by mod_php. You have to restart/recycle the Apache processes once in a while. Check out the configuration value MaxRequestsPerChild which will do this for you automatically (it's off by default on CentOS if I recall correctly).
Set it to something low, but not too low since recycling is expensive. A few hundreds will probably do.