1

There are various problems when using php_apc with symfony,

If the boost is not so significant,I'm going to replace apc with memcached.

user198729
  • 61,774
  • 108
  • 250
  • 348

2 Answers2

8

APC and memcached are not the same things :


Fisrt of all, APC has two roles :

  • It's an opcode cache (which means each PHP page will generally require less CPU, as it remove the "compilation" part ; the first time we enabled APC as an opcode cache, CPU load on our webservers went from something like 80% to something like 40-50%)
  • It's also a non-distributed data cache
    • which means, if you have several servers, that each one of your servers has a local copy of the cache
    • which also means there is a pretty low limit on the amount of data you can store in cache


And for memcached :

  • It's only a data-cache
  • It's distributed
    • i.e. no limit on the number of servers in a memcached cluster
    • i.e. no limit on the amount of cache you can have


You can use either APC or memcached, or both, as a data-cache (that's what we are doing on the project I'm currently working on : some data are cached in APC, and some others using memcached).

But, if you want some opcode cache, you'll have to go with APC (or eAccelerator ; but not sure it's well maintained).

Pascal MARTIN
  • 395,085
  • 80
  • 655
  • 663
  • What's the version of PHP and apc respectively? – user198729 Feb 19 '10 at 05:54
  • Almost last "stable" version of PHP 5.2 *(i.e. something like 5.2.9 or 5.2.10)*, and last "stable" version of APC *(i.e. 3.0.19)* – Pascal MARTIN Feb 19 '10 at 05:55
  • I've heard apc is stable with PHP5.2,but I'm already using PHP5.3,and the apc version is 3.1.3.0,which seems buggy – user198729 Feb 19 '10 at 05:57
  • Considering APC 3.1.x is still in beta, it might ; did you check its bug tracker ( http://pecl.php.net/bugs/search.php?cmd=display&status=Open&package_name[]=APC ) ? Did you try getting the last version from SVN ( http://svn.php.net/viewvc/pecl/apc/ ) -- not sure it'll help, but who knows ? – Pascal MARTIN Feb 19 '10 at 05:59
4

See this please :)

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

You can/should use both for different purposes.

Community
  • 1
  • 1
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
  • @user198729: then you should go for memecache :) by the way there are big apps already using apc. – Sarfraz Feb 19 '10 at 05:47
  • @user198729 Could you document your comment ? Because almost every php server out there use APC as an opcode caching system without problems. (And yes I know you posted that in feb 2010 but i'm using it for a long time). – Shadok Mar 20 '12 at 11:23