php Memcached 与 APC 我应该选择哪一个?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/815041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Memcached vs APC which one should I choose?
提问by Thomaschaaf
I read this article: http://www.mysqlperformanceblog.com/2006/09/27/apc-or-memcached/from way back when.. I want to get the best caching engine available so that my application is really fast. Of course I don't want to over-cache but I want to at least choose the best thing out there. In that article it says Memcached is slow and apc is fast so why is everyone choosing memcached?
我读了这篇文章:http: //www.mysqlperformanceblog.com/2006/09/27/apc-or-memcached/从前.. 我想获得最好的缓存引擎,以便我的应用程序非常快。当然,我不想过度缓存,但我想至少选择最好的东西。在那篇文章中它说 Memcached 很慢而 apc 很快,那么为什么每个人都选择memcached呢?
http://framework.zend.com/manual/en/zend.cache.backends.html#zend.cache.backends.twolevelshere is says "use a fast one (but limited) like Apc, Memcache... and a "slow" one like File, Sqlite..." do you think using Apc as the fast and Memcache as the slow is a good idea?
http://framework.zend.com/manual/en/zend.cache.backends.html#zend.cache.backends.twolevels这里是说“使用一个快速的(但有限的)像 Apc、Memcache ...... “慢”一个像文件,Sqlite ......“你认为使用 Apc 作为快速和 Memcache 作为慢速是一个好主意吗?
回答by Karsten
Memcached is a distributed caching system, whereas APC is non-distributed - and mainly an opcode cache.
Memcached 是一个分布式缓存系统,而 APC 是非分布式的——主要是一个操作码缓存。
If (and only if) you have a web application which has to live on different webservers (loadbalancing), you have to use memcache for distributed caching. If not, just stick to APC and its cache.
如果(且仅当)您的 Web 应用程序必须存在于不同的 Web 服务器上(负载平衡),则必须使用 memcache 进行分布式缓存。如果没有,只需坚持使用 APC 及其缓存。
You should always use an opcode cache, which APC is (also APC will get integrated into php6 iirc, so why not start using it now).
您应该始终使用操作码缓存,即 APC(APC 也将集成到 php6 iirc 中,所以为什么不现在开始使用它)。
You can/should use both for different purposes.
您可以/应该将两者用于不同的目的。
回答by xkcd150
Memcached if you need to preserve state across several web servers (if you're load balanced and it's important that what's in the cache is the same for all servers).
Memcached 如果您需要在多个 Web 服务器之间保留状态(如果您是负载平衡的,并且所有服务器的缓存中的内容都相同很重要)。
APC if you just need access to quick memory to read (& write) on a (or each) server.
APC,如果您只需要访问快速内存以在(或每个)服务器上读取(和写入)。
Remember APC can also compile and speed up your script execution time. So you could for example be using APC for increased execution performance, while using memcached for cache storage.
请记住,APC 还可以编译并加快您的脚本执行时间。例如,您可以使用 APC 来提高执行性能,同时使用 memcached 进行缓存存储。
回答by Hieu Vo
The main advatage of APC is opcode cache. Since PHP 5.5 integrated OpCache to its core and APC for PHP 5.4 is still flagged as beta, it's not official annoucement, but the development of APC would be dropped in near future.
APC 的主要优点是操作码缓存。由于 PHP 5.5 将 OpCache 集成到其核心,并且 PHP 5.4 的 APC 仍被标记为测试版,因此这不是官方公告,但在不久的将来 APC 的开发将被放弃。
So I would recommend you to choose Memcached.
所以我建议你选择 Memcached。
回答by Saimon Lovell
I use both one for speed and the other to sync all my servers. If you do use memcache then please do keep in mind of the open ports which you will need to block with iptables.
我使用一个来提高速度,另一个来同步我的所有服务器。如果您确实使用了 memcache,那么请记住您需要使用 iptables 阻止的开放端口。
回答by Nir Levy
Hey Thomaschaaf, I hope this is not tool late for you but please note that APC has some issues related to "user-cache". To make a long story short, when you set time-outs for cache entries, or if your apache crashes inside internal APC code (timeout, for example), then you may suffer some problems.
嘿 Thomaschaaf,我希望这对你来说不是迟到的工具,但请注意 APC 有一些与“用户缓存”相关的问题。长话短说,当您为缓存条目设置超时时,或者如果您的 apache 在内部 APC 代码中崩溃(例如超时),那么您可能会遇到一些问题。
I have an entry about the issue here: http://nirlevy.blogspot.com/2009/06/apc-futexwait-lockdown-make-your-apache.html, and you should also read http://t3.dotgnu.info/blog/php/user-cache-timebomb.html(from one of the APC developers i think)
我对这里的问题的条目:http://nirlevy.blogspot.com/2009/06/apc-futexwait-lockdown-make-your-apache.html,你也应该阅读的http://t3.dotgnu。 info/blog/php/user-cache-timebomb.html(我认为来自一位 APC 开发人员)
回答by Thomas Decaux
I use only APC since APC is a code cache and acts like memcache ! Only 1 config file instead of 2.
我只使用 APC,因为 APC 是一个代码缓存,就像 memcache 一样!只有 1 个配置文件而不是 2 个。
And only 1 place to monitor both cache.....
并且只有 1 个地方可以监控两个缓存.....
回答by fred
It depends on what you are doing but for my drupal websites running on a VPS I find APC works great! If you are running CentOS 6 it is available as a yum update so dead simple to install and no config as the defaults are reasonable. A no brainer imho.
这取决于你在做什么,但对于我在 VPS 上运行的 Drupal 网站,我发现 APC 效果很好!如果您运行的是 CentOS 6,它可以作为 yum 更新使用,安装非常简单,而且没有配置,因为默认值是合理的。一个没有道理的恕我直言。

