当 PHP APC 缓存完全填满时,如何防止 Apache 挂起?

发布于 2024-10-18 01:18:24 字数 198 浏览 6 评论 0原文

当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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

又爬满兰若 2024-10-25 01:18:24

我发现设置 ttl 会在缓存已满时更改 APC 的行为。默认情况下,如果 ttl 为 0,APC 必须在缓存满时清空缓存。从手册:

如果缓存耗尽
可用内存,缓存将是
如果 ttl 等于则完全删除
0.否则,如果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:

In the event of a cache running out of
available memory,the cache will be
completely expunged if ttl is equal to
0. Otherwise, if the ttl is greater than 0, APC will attempt to remove
expired entries.

微凉徒眸意 2024-10-25 01:18:24

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.

清眉祭 2024-10-25 01:18:24

您可以尝试在经常执行的脚本中添加一行,以检查缓存是否接近满,如果是,则处理它。
此类脚本的示例可以是建立与数据库的连接的脚本。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文