• Resolved Rahul Bansal

    (@rahul286)


    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

Viewing 11 replies - 1 through 11 (of 11 total)
  • Based on what Fredrick said before Disk Enhanced is the fastest for page cache.

    Plugin Contributor Frederick Townes

    (@fredericktownes)

    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.

    Thread Starter Rahul Bansal

    (@rahul286)

    @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! 🙂

    Plugin Contributor Frederick Townes

    (@fredericktownes)

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

    Thread Starter Rahul Bansal

    (@rahul286)

    @fredrick
    Glad to know that.
    I hope following is right place to get development version. 🙂

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

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

    Plugin Contributor Frederick Townes

    (@fredericktownes)

    Right.

    Thread Starter Rahul Bansal

    (@rahul286)

    Thanks gregrickaby. 🙂

    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.

    Plugin Contributor Frederick Townes

    (@fredericktownes)

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

    Thread Starter Rahul Bansal

    (@rahul286)

    @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. 🙂

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: W3 Total Cache] For page-caching – which is better – APC or Disk?’ is closed to new replies.