操作码缓存对内存使用的影响
谁能告诉我与 PHP 操作码缓存相关的内存使用开销是多少?
我看过很多关于操作码缓存的评论,但它们都只关注性能的提高。 我有一个小型入门级 VPS,并且内存限制是我关心的问题。
Can anyone tell me what is the memory usage overhead associated with PHP opcode cache?
I've seen a lot of reviews of opcode cache
but all of them only concentrate on the performance increase. I have a small entry level VPS and memory limits are a concern for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
大部分内存开销来自操作码缓存大小。 每个操作码缓存器都有自己的默认值(例如,APC 为 30MB),您可以通过配置文件进行更改。
除了缓存大小之外,缓存器本身的实际内存开销可以忽略不计。
Most of the memory overhead will come from the opcode cache size. Each opcode cacher has their own default(e.g. 30MB for APC) which you can change through the config file.
Other than the cache size, the actual memory overhead of the cacher itself is negligible.
在当今世界:这是可以忽略不计的。 我认为使用 eAccelerator 时的内存消耗大约比没有使用 eAccelerator 时大 50 MB,基准。
如果您确实需要速度,但确实为您的 RAM 可能不够而头痛:花 40 美元为您的服务器再购买 GIG 的 RAM ;)
In todays world: It's neglectible. I think memory consumption was about 50 MB bigger with eAccelerator then it was without when I did my benchmarks.
If you really need the speed but do have headaches that your RAM might be not enough: grab $40 and buy another GIG of RAM for your server ;)
您可以为
APC
的内存消耗设置限制
,但这可能会限制其有效性。如果您只是将其用于静默操作码缓存,那么应该没问题。 一旦内存分配已满,就不会缓存新文件,但一切都会按预期工作。 但是,如果没有可用内存,
apc_store()
和apc_fetch()
等用户空间缓存函数将默默且莫名其妙地失败。这可能很难捕获和调试,因为不会报告错误,也不会引发异常。
You can set a
limit
to memory consumption forAPC
, but that potentially limits its effectiveness.If you're just using it for silent opcode caching, then it should be fine. Once the memory allotment is full, no new files will be cached, but everything will work as expected. However, the user-space cache functions like
apc_store()
andapc_fetch()
will fail silently and inexplicably if there is no memory available.This can be tricky to catch and debug since no error is reported and no exception is thrown.