当 PHP APC 缓存完全填满时,如何防止 Apache 挂起?
当APC缓存已满时,它会挂起Apache。 Apache 响应请求,但永远等待 APC 缓存释放一些资源,但这永远不会发生。
我使用自己的小 expunge 脚本每 10 分钟运行一次 CRON 作业,该脚本会从 APC 中删除过期条目。好的,我可以向 APC 添加更多内存和/或者可以更频繁地运行删除脚本。但这不是真正的解决方案,我正在寻找一些新的方法来处理问题。
When APC cache is full, it hangs Apache. Apache responds to requests, however waits forever for APC cache to free some resources, but this will never happen.
I run every 10 minutes CRON job with my own small expunge script, which deletes expired entries from APC. Ok, I could add more memory to APC and/or I could run the expunge script more often. But that's not real solution, I am looking for some new way how to deal with issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现设置 ttl 会在缓存已满时更改 APC 的行为。默认情况下,如果 ttl 为 0,APC 必须在缓存满时清空缓存。从手册:
I find that setting a ttl changes APC's behavior when cache is full. By default, if the ttl is 0, APC has to empty the cache when it gets full. From the manual:
这并不是真正的最终解决方案,但我写了一个小 PHP APC expunge script< /a> 我在我的问题中提出的。该脚本由 CRON 每 10 分钟运行一次,并手动删除过期的项目。这还不是完美的解决方案,但至少有很大帮助。
我仍在寻找最终解决方案。
It's not really the final solution, but I have written small PHP APC expunge script that I had proposed in my question. This script is run by CRON every 10 minutes and it manually removes expired items. It's far not perfect solution, but at least it helps a lot.
I am though still looking for final solution.
您可以尝试在经常执行的脚本中添加一行,以检查缓存是否接近满,如果是,则处理它。
此类脚本的示例可以是建立与数据库的连接的脚本。
You could try to add a line to a script that is executed often to check wether the cache is nearly full and if it is, deal with it.
An example of such script could be a script that establishes the connection to a database.