WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
[resolved] For page-caching - which is better - APC or Disk? (12 posts)

  1. rahul286
    Member
    Posted 3 years ago #

    Hi All.

    First let me clear that I am talking about PHP running as FastCGI or using PHP-FPM i.e. webserver and php-interpreter are differently loaded in memory and static files can be served without any putting any load on php-interpreter.
    Also nginx is my webserver whose memory footprint is 10-20 times smaller than php-interpreter.

    For page-caching module, we have been given so many options to choose from.
    I am bit concerned about which one is better - APC or Disk-based?

    APC stores cached content in RAM and RAM is faster than hard-disk.
    But if we take close look, in APC mode, page requests reaches php-interpreter whereas hard-disk based requests are served alone by web-server reducing load on php-interpreter completely.

    Another thing to notice is that as APC is enabled, with page-cache, opcode cache is also there, which mean CPU is less loaded in serving requests to php-interpreter.

    Now, I am confused as which will be more scalable (in terms of Digg-like traffic spike)

    APC Caching...
    +1 Cached pages are stored in RAM
    -1 php-interpreter is involved in serving requests

    Disk-based Caching...
    +1 Zero load on php-interpreter if page is already cached
    -1 Disk is slower than RAM

    I hope I am able to convey my question in detail.
    If anyone needs more details, please ask. I really want to dig deeper into this topic.

    Thanks,
    -Rahul

  2. remotay
    Member
    Posted 3 years ago #

    Based on what Fredrick said before Disk Enhanced is the fastest for page cache.

  3. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    For typical environments, disk enhanced is best. You can always test various methods; it also depends what kind of stress you're trying to optimize your server for.

  4. rahul286
    Member
    Posted 3 years ago #

    @remotay and @Fredrick
    Thanks for answers. :-)

    Digging into more details, I also noticed that its much more "economical" to start additional number of nginx workers than their php-fpm counterpart processes.

    In size of one php-fpm process, we can easily fork out 5-10 additional nginx workers!
    Also serving request alone by nginx will reduce interprocess communication overhead.

    By the way, this case must be unique as it contradicts basic assumption that serving something from RAM is always faster than hard-disk!

    Also, with time I am also exploring possibility to have disk-cache "preloaded" or "buffered" in RAM by "some method". That will give us best of both worlds as during my APC cache usage I have noticed only 20-30 MB data is stored in APC for page as well as mysql query cache. This is pleasantly surprising as number of entires in cache are around 2000.

    Sorry for dumping lots of info here Fredrick, but I really feel we can go much further in terms of performance gain starting with w3 total cache. :-)

    Thanks again for all the great work! :-)

  5. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    You're welcome. The development version has a cache preloader as well.

  6. rahul286
    Member
    Posted 3 years ago #

    @Fredrick
    Glad to know that.
    I hope following is right place to get development version. :-)

    http://svn.wp-plugins.org/w3-total-cache/trunk/

  7. Greg Rickaby
    Member
    Posted 3 years ago #

    Or you can download the Development ZIP: http://downloads.wordpress.org/plugin/w3-total-cache.zip

  8. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    Right.

  9. rahul286
    Member
    Posted 3 years ago #

    Thanks gregrickaby. :-)

  10. Greg Rickaby
    Member
    Posted 3 years ago #

    You're welcome. Also, I find what works best (APC vs. Disk Enhanced) is really trial and error. Rather than think of APC vs. Disk Enhanced, I used them together.

    I use APC to cache everything except pages.

    From what I understand APC will assemble the pages out of it's cache (using RAM), then save the files onto the disk. Then the server will serve the page from disk, not requiring APC to work again. (I might be completely wrong in this assumption)

    ....but...from what I experience....once a page/post is assembled and put into disk cache I find subsequent loads are lightning fast.

  11. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    @gregrickaby, that's not actually true. You should test and measure using the various tools in the FAQ to verify your conclusions. Some web servers, hardware and theme combinations can behave differently.

  12. rahul286
    Member
    Posted 3 years ago #

    @gregrickaby

    From what I understand APC will assemble the pages out of it's cache (using RAM), then save the files onto the disk. Then the server will serve the page from disk, not requiring APC to work again. (I might be completely wrong in this assumption)

    I am sure once data is present in APC cache, it will not be written to disk unless cache get full.
    Assembling is not require.
    I am sure because, like disk cache, APC stores complete pages in one single variable in memory.

    I strongly feel disk v/s RAM difference will be much smaller than overhead involved in serving a request with php v/s without php parser.

    I will still explore and keep this thread updated with my findings. :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic