Can I use APC AND memcached on the same server?

I use memcache to cache objects, but I would like to add, in addition, an opcode accelerator such as APC. Since they are both related to caching, I’m not sure that they will “attack each other”, i.e. I'm not sure that memcache is already an OP code accelerator.

Can someone clarify? I would like to use both of them - a bit for different things. memcache for caching my objects and APC for speeding up code

+7
php memcached apc
source share
2 answers

Yes, you can use them together at the same time.

+4
source share

Memcache has more to do with cache lines of distributed objects than with APC or XCache, which stores PHP bytecode in memory, so you don't need to parse it every time. Their main goals are different.

For example, if you had a very intense database query that people often requested, you can cache the resulting object in memcache and then reference it, rather than re-executing this query all the time.

APC and XCache have similar object caching features, but you are limited to the host machine. What if you want 10 different servers to have access to one object without having to repeat the request for each server? You just send them to your memcache server and leave. You still get the advantage if you have only one server, because using memcache will help you scale in the future if you need to branch out to more mailboxes.

The main thing to think about if you think your application needs to be scaled. Memcache has more overhead because you need to use a TCP connection to access it, not just a function call for shared APC / Xcache objects.

However, Memcache has the following advantages:

  • Faster than a restart request or restart request.
  • Scales to multiple servers.
  • It works with many languages, your objects are not blocked only in PHP + APC / Xcache.
  • All processes / languages ​​have access to the same objects, so you do not need to worry if your child PHP processes have an empty object cache or not. It may not be so much if you use PHP-FPM.

In most cases, I would recommend caching your objects in memcache, as this is not much more complicated and more flexible in the future.

Keep in mind that this is only relative to object caching. Memcache does NOT have any bytecode or PHP acceleration features, so I will run it side by side with APC or Xcache

+19
source share

All Articles