1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

APC / Memcached / Both?

Discussion in 'XenForo Questions and Support' started by James, Feb 8, 2011.

  1. James

    James Well-Known Member

    So I'm not an expert (or even an amateur or novice) in the areas of caching but I'm trying to learn 'cause every little helps.
    (rambles with myself in the hope that someone will correct my nonsense)
    From what I've been reading, APC is non-distributed and is an opcode cache. Opcode caching means that the compiled PHP script is cached so that the script isn't being compiled on each request for it, it can just be read from the cache.

    Memcached is a distributed caching mechanism and is used if your site is running on different servers (loadbalancing comes to mind) so the cache is available across all servers and not just the server that it's cached on (in layman's terms, it's like a shared cache - right?)

    Now, once I've finished rambling I've come to the conclusion that memcached should only be used if I'm utilising multiple servers for my site, and APC should be used no matter what because it is caching scripts to save resources.

    So, (on a single server installation) would I be best off just sticking to APC, or utilising memcached too for XenForo (if this is even possible)?
  2. Deebs

    Deebs Well-Known Member

    There is no point using memcached in a single server environment considering that it is only a data cache which APC is also. Stick APC on, ensure the opcode and data caches are big enough to hold your compiled scripts and data and away you go. Plus you have no overhead of network latency when talking to APC on the same server. Memcached can be called via sockets but the developers recommend using the network transport to access it.
  3. Kier

    Kier XenForo Developer Staff Member

    FWIW, on this site we use APC alone, and we don't have any cache setup in our config.php.
    James likes this.
  4. James

    James Well-Known Member

    So you run APC at the server level and cache everything with APC rather than initiating it at software level with config.php?

    P.S: Were my explanations right? :D
  5. Deebs

    Deebs Well-Known Member


    the config.php changes will only activate APC for data caching, not opcode caching, that is mostly automatic depending on file size limits.
  6. Wuebit

    Wuebit Well-Known Member

    With muilt sites would it be best to add "XCache" which ive just installed this second to the config.php?
    How can i do this sir? am very new to APC in fact only today i was asking about them

  7. Deebs

    Deebs Well-Known Member

    XCache is another good opcode cache product but for me development seems to have slowed down, another plus for APC is that it is now going to be included in the core of PHP6 so will receive a lot of developer attention over time. Personally I used to use XCache and a copy of memcached on another server but since I rebuilt my platforms have decided on APC. I didn't use the version of APC included in the distro as that often lags behind the current release so I use it directly from PECL.
    Darkimmortal likes this.
  8. Kier

    Kier XenForo Developer Staff Member

    No, we use APC for its OpCode cache only. We do not run any other caching here on XenForo.com at present.
    James likes this.
  9. Deebs

    Deebs Well-Known Member

    Ok, after a slight hiccup, during which webmin decided to uninstall 72 packages as they were not needed, Vodkaholic is now running APC.
    Vodkaholic likes this.

Share This Page