0

I am developing an application using the Yii framework. Application will have a multiple server configuration. I read about Memcache and APC.

Can you tell me what works better with Yii between APC and Memcache?

4

4 回答 4

3

Although both APC and Memcache are used for different purpose, you should use both. Since you have multiple servers, memcache will help in caching and maintaining user data state across servers and APC will help in speed up script execution time.

APC compiles the plain PHP code into machine code and saves it so in all future requests, compilation time can be saved. Here's the link which can give you some idea on how to use it with Yii - http://www.yiiframework.com/wiki/312/getting-the-most-out-of-apc-for-yii/

于 2013-06-06T06:39:26.773 回答
2

As others have said, APC is used for 2 purposes: OpCode Cache and User Variables Cache. Since PHP 5.5, the OpCache is enabled by default which is more optimized than APC; hence, the OpCache will be used for the OpCode cache. If you want to use the APC for applications using PHP 5.5, you should use APCu only for User Variables Cache.

MemCache is used for Variable Caching just like APC, but the advantage comes when you are planning to scale your application. If you want to deploy more than 1 PHP Application Servers [Horizontal Scaling], and if you are not using the database for PHP Session Management, then if you use the APC for cache, there will be lots of problems as you don't know in which APC server your code is present. Whereas MemCache is the distributed Caching engine, ie even if you deploy more than one MemCache Servers, yet MemCache figures it out as where the Cached data is.

于 2015-05-12T18:57:29.310 回答
1

APC is used for opcode, but Memcache is just used for application cache, e.g. caching a database.

于 2013-06-06T06:13:17.997 回答
0

APCu Does not share the cache with other servers but is faster.

Memcached Can be shared with other servers and is slower.

Memcached is a distributed caching system, whereas APC is non-distributed - and mainly an opcode cache.

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.

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

If you have 2 or more web servers (apache/nginx) for the same Drupal site you'll want Memcached. If you are running on a single machine then APCu will be the quickest. You'll want OPcache turned on no matter what.

See:

Memcached vs APC which one should I choose? https://drupal.stackexchange.com/questions/117932/difference-between-apc-memcached-and-how-both-can-be-used-for-cache-bins

于 2017-05-30T13:58:52.663 回答