Memcached vs APC,我该选哪个呢?

时间:2023-02-12 19:17:55

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.twolevels here 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?

这里有两个级别:“使用一个快速的(但受限的)像Apc, Memcache……”和一个“慢”的文件,Sqlite…“你认为使用Apc作为快,Memcache作为慢是一个好主意吗?

7 个解决方案

#1


257  

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.

您可以/应该将两者用于不同的目的。

#2


41  

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).

如果需要跨多个web服务器保持状态(如果负载均衡,并且缓存中的内容对所有服务器都是相同的,那么Memcached很重要)。

APC if you just need access to quick memory to read (& write) on a (or each) server.

如果您只需要访问快速内存,就可以在(或每个)服务器上进行读写操作。

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作为缓存存储。

#3


16  

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仍然被标记为beta,这并不是正式的通告,但是APC的开发将在不久的将来停止。

So I would recommend you to choose Memcached.

所以我建议你选择Memcached。

#4


9  

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阻塞的开放端口。

#5


6  

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.

嘿,托马斯查夫,我希望这对你来说不是工具迟了,但是请注意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- futexwaityour-apache.html,您还应该阅读http://t3.dotgnu.info/blog/php/user-cache-timebomb.html(我认为是APC开发人员之一)

#6


1  

I use only APC since APC is a code cache and acts like memcache ! Only 1 config file instead of 2.

我只使用APC,因为APC是一个代码缓存,就像memcache一样!只有一个配置文件而不是2。

And only 1 place to monitor both cache.....

只有一个地方可以监控这两个……

#7


1  

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更新来使用,非常容易安装,没有默认的配置是合理的。无脑的清规戒律。

#1


257  

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.

您可以/应该将两者用于不同的目的。

#2


41  

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).

如果需要跨多个web服务器保持状态(如果负载均衡,并且缓存中的内容对所有服务器都是相同的,那么Memcached很重要)。

APC if you just need access to quick memory to read (& write) on a (or each) server.

如果您只需要访问快速内存,就可以在(或每个)服务器上进行读写操作。

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作为缓存存储。

#3


16  

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仍然被标记为beta,这并不是正式的通告,但是APC的开发将在不久的将来停止。

So I would recommend you to choose Memcached.

所以我建议你选择Memcached。

#4


9  

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阻塞的开放端口。

#5


6  

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.

嘿,托马斯查夫,我希望这对你来说不是工具迟了,但是请注意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- futexwaityour-apache.html,您还应该阅读http://t3.dotgnu.info/blog/php/user-cache-timebomb.html(我认为是APC开发人员之一)

#6


1  

I use only APC since APC is a code cache and acts like memcache ! Only 1 config file instead of 2.

我只使用APC,因为APC是一个代码缓存,就像memcache一样!只有一个配置文件而不是2。

And only 1 place to monitor both cache.....

只有一个地方可以监控这两个……

#7


1  

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更新来使用,非常容易安装,没有默认的配置是合理的。无脑的清规戒律。