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

APCu vs Memcache?

Discussion in 'Server Configuration and Hosting' started by |Jordan|, Feb 17, 2015.

  1. |Jordan|

    |Jordan| Active Member

    Which offers better performance for Xenforo?
    Last edited: Feb 17, 2015
  2. Moscato

    Moscato Active Member

    apcu theoretically should be faster under more scenarios as a datastore, however...
    "We do not recommend writing sessions to the cache if you are using APC as your cache back-end."

    "Note that some versions of APC may be susceptible to cache-slam issues, so if you do enable APC caching of data (in addition to the PHP opcode cache that it maintains automatically without requiring any configuration), you should monitor your server carefully for a time to ensure that it is running smoothly."

    What that actually means, I don't know
  3. RoldanLT

    RoldanLT Well-Known Member

    Because with APC, when you write sessions into it there are login issues.
    Most likely login issues on admin panel.
  4. Moscato

    Moscato Active Member

    @RoldanLT why is apc different with it than memcached?

    Right now, I'm just using filecache with tmpfs as my forum is relatively new
  5. RoldanLT

    RoldanLT Well-Known Member

    I'm not the kind of person that can answer your question :D
    All I can say is APC is only good for PHP 5.4 and lower versions.
    Not for PHP 5.5 and up.
  6. Moscato

    Moscato Active Member


    I have 5.5, so I'll just stick with my file tmpfs cache
  7. Marcus

    Marcus Well-Known Member

    Apcu is faster yet more unreliable. From my understanding apc stores data as-is. Whereas all other caching solutions first modify data before storing it.
  8. Kuma

    Kuma Active Member

    If you are only running a single server environment and not using memcached for anything else I would opt for APCu over memcached.
    If you are already running memcached for other applications, or are in a multiple-frontend-webserver environment, I would go with mecached.
  9. Moscato

    Moscato Active Member

    If that's the case, then wouldn't file cache have the same issue?
  10. Marcus

    Marcus Well-Known Member

    From what I read memcache, redis etc. all transform data when they store and retreive it, while APC was programmed only for php so they just used pure php data. I unfortunately don't know how the file cache works. To be totally on the safe side, just use memcache on your local server. And if you even want to reduce the tcp overhead, you could use a socket. And yes, APCu did gave me a huge (10% ?) performance improvement but I now stay with memcache.

    Memcache is like a Mercedes, and APCu like a car you tune at home in your garage. Sure the APCu is faster, but for reliability there are better options.

    Redis is very powerful and is doing less to store data, meaning it should be faster overall. Redis is not supperted by the ZEND Framework 1 xenForo currently uses. There is an addon available for Redis in the Resource Manager.
  11. Xon

    Xon Well-Known Member

    I wrote that addon, it has an issue with [db] Widget Framework with its more advanced features that I haven't had time to solve yet.

    It is being used by SpaceBattles, and is working quite well, with SB's peak load of ~2000-2200 users online in 15 minutes.

    I've got some future plans for getting the underlying ZEND Framework 1 part to support Redis Clustering, but I'm massively busy with other projects unless someone breaks out a checkbook.
  12. |Jordan|

    |Jordan| Active Member

    Is there any way to disable pipelining in your addon (so it works with Widget framework) or would that break it enough that its not worth running without it?

    Thanks for the info everyone.
  13. Xon

    Xon Well-Known Member

    You can use it without pipelining, just need to not add the following into your config.php
    In that configuration, you are just using Redis as a memcache replacement. Biggest bonus is being able to inspect the contents of the cache, and selectively remove keys. Being able to save & load also means restarting doesn't purge the cache.
  14. |Jordan|

    |Jordan| Active Member

    Attached Files:

    Last edited: Feb 21, 2015
    Xon likes this.
  15. Nicky Vermeersch

    Nicky Vermeersch Active Member

    Also, the reason why it's not needed for 5.5 or more recent is because that PHP finally have their own opcode cache solution!
    Personally I use APC which gave me enough results to speed up the website. APC is non-shared, so if you are the only user on your system. Memcache is only useful if you like do load-balancing across different machines, where the state has to be 'synchronous' across all the machines.
  16. Marcus

    Marcus Well-Known Member

    Actually there are always two caches:

    1. One cache is for making the application faster. Maybe you could say this cache is "executing .php files faster". This is called the opcache. And PHP now has its own integrated opcache solution, when you have one of the latest PHP releases, it's just working.

    2. The other cache is for user data. Whenever a user visits a forum, some data is created to identify this user for the time of his stay on that forum. This is the session cache. Even some more data can be stored by this kind of "backend cache". For this you still have to use an additional cache, this is not covered by PHPs new opcache.

    APC was doing both jobs. When PHP promoted its former commercial opcache to be included in any PHP release for free, most people used the new official opcache. But there was still need for the user data cache. And this is what APCu is for: It is APC without the opcache: APCu"sercache". So when using "APC" on a single server system my guess is that the best approach would be to just install APCu.

    More reliable for handling user data cache is memcache. It is slower than APCu, but it won't make you any headaches.
  17. Xon

    Xon Well-Known Member

    I finally had time to look into what was going wrong. My Addon didn't support 'automatic_serialization' properly, as this results in XenForo double serializing things.

    I've only just implemented a fix for it.

Share This Page