Learn about Centmin Mod LEMP Stack today
Become a Member

Wordpress Using: Redis as a front-end cacher instead of using a caching plugin - MUCH faster

Discussion in 'Blogs & CMS usage' started by Matt Williams, Apr 8, 2015.

  1. Matt Williams

    Matt Williams WordPress Fanatic

    537
    104
    43
    Nov 22, 2014
    Virginia, USA
    Ratings:
    +157
    Local Time:
    11:37 PM
    latest
    10
    For the last several hours, I've been working with Redis as a front-end cacher for WordPress. Within my own testing, Using it this way works VERY well. Putting up 2 blogs, exact same theme, plugins - one has Redis and the other had WP Super Cache. Redis was faster by about 100+ms in page loading on each test. PageSpeed was not effected by it and still continued to work well with it. However, using a CDN was affected by it so I had to rename the upload path to /wp-content/uploads/ to my CDN URL to the images would at least load on the CDN. PageSpeed can handle the CSS and JS which I like it better that way anyway.

    I installed Redis from source:
    Code:
    mkdir /tmp/redis
    cd /tmp/redis
    wget http://download.redis.io/releases/redis-3.0.0.tar.gz
    tar xzf redis-*
    cd redis-*
    Next step is to compile with make utility and install:
    Code:
    make
    make install clean
    Create config:
    Code:
    mkdir /etc/redis
    cp redis.conf /etc/redis/redis.conf
    By default redis-server will install in /usr/local/bin/redis-server. Check it whith whereis command:
    Code:
    whereis redis-server
    #redis-server: /usr/local/bin/redis-server
    Start server
    Code:
    redis-server /etc/redis/redis.conf 
    After the install, I followed these instructions:
    Once everything was installed and working, I uninstalled the caching plugin and looked in the corner of my WP site to see if the cache was working and it was!


    It works and works well. Reminds me allot of Varnish which this is a good substitute for Varnish.
     
  2. eva2000

    eva2000 Administrator Staff Member

    55,223
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:37 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    very nice.. and expected as redis out of box is memory cache with disk persistence at specified intervals so would be expected to be faster than static file caching in WP Super Cache.

    2yrs ago I did do old siege benchmark tests with redis 2.6.x vs fastcgi_cache for Wordpress only and fastcgi_cache was 4x times faster than redis 2.6 but redis was just out of box defaults.

    fyi, you can get redis 2.8 series via YUM so would be interesting to see how that compares to redis 3.x which I have yet to try

    Code:
    yum list redis --disableplugin=priorities --enablerepo=remi -q
    Available Packages
    redis.x86_64    2.8.19-1.el6.remi         remi
    and redis 3.x is in remi-test repo
    Code:
    yum list redis --disableplugin=priorities --enablerepo=remi-test -q
    Available Packages
    redis.x86_64    3.0.0-1.el6.remi           remi-test
     
  3. Matt Williams

    Matt Williams WordPress Fanatic

    537
    104
    43
    Nov 22, 2014
    Virginia, USA
    Ratings:
    +157
    Local Time:
    11:37 PM
    latest
    10
    I knew about the Redis 2.8 and I did install the 2.8 on a few VPS's but when I came across the 3.0.0, I was like hmmmm lol!

    I always like to run Siege that comes with Centmin Mod to do a preliminary load test. All those other tests like blitz.io are so expensive but I don't know how reliable Siege really is but I did a few test on my VPS's with Resis Front-End Cache...

    using: siege -c100 -d10 -t3M
    Code:
    Transactions:                   3459 hits
    Availability:                 100.00 %
    Elapsed time:                 179.36 secs
    Data transferred:              49.51 MB
    Response time:                  0.03 secs
    Transaction rate:              19.29 trans/sec
    Throughput:                     0.28 MB/sec
    Concurrency:                    0.54
    Successful transactions:        3459
    Failed transactions:               0
    Longest transaction:            0.19
    Shortest transaction:           0.01
    
    Using: siege -c500 -d10 -t3M
    Code:
    Transactions:                  17622 hits
    Availability:                 100.00 %
    Elapsed time:                 179.41 secs
    Data transferred:             252.22 MB
    Response time:                  0.05 secs
    Transaction rate:              98.22 trans/sec
    Throughput:                     1.41 MB/sec
    Concurrency:                    5.28
    Successful transactions:       17622
    Failed transactions:               0
    Longest transaction:            0.73
    Shortest transaction:           0.01
    
    Using: siege -b -t600S
    Code:
    Transactions:                  83401 hits
    Availability:                 100.00 %
    Elapsed time:                 599.32 secs
    Data transferred:            1193.69 MB
    Response time:                  0.11 secs
    Transaction rate:             139.16 trans/sec
    Throughput:                     1.99 MB/sec
    Concurrency:                   14.97
    Successful transactions:       83401
    Failed transactions:               0
    Longest transaction:            5.16
    Shortest transaction:           0.04
    
    If these are accurate tests, then that's pretty good for a OpenVZ Container considering their configuration limitation compared to XEN or KVM
     
  4. eva2000

    eva2000 Administrator Staff Member

    55,223
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:37 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah hence why Centmin Mod installed Siege benchmark tool by default - comes in handy for tests. Ideally, you want to run siege from a remote server in close proximity geographically to the target wordpress server as siege has it's own resource overhead which can interfere with results.
     
  5. jeffwidman

    jeffwidman Active Member

    152
    27
    28
    Dec 3, 2014
    Ratings:
    +51
    Local Time:
    8:37 PM
    FYI for anyone who stumbles across this in the future, and like me is wondering what the latest is.

    The reason this is so fast is because 1) Nginx never hits PHP, and 2) Nginx never hits the disk. All requests go straight from Nginx to Redis (RAM), which is very fast. But you have to install the custom redis script to intercept traffic ahead of wordpress and things start to feel a bit hacky.

    A new alternative that provides the same speed is WP-FPPC now supports Nginx's Memcache module as an option. If you choose this, requests go straight Nginx--> Memcache (RAM) which is pretty much the same speed. And it ties in better with Wordpress to handle cache expiration etc.

    However, using WP-FPPC with a different backend, for example the PHP Memcache modules is slower, then you're going Nginx --> PHP --> Memcache. In that case, you can get nearly equivalent speed by setting up the much simpler WP-Supercache, where you just go Nginx--> Static files on disk. Disk is slower, but so is spawning PHP processes.
     
  6. eva2000

    eva2000 Administrator Staff Member

    55,223
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:37 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Last edited: Sep 25, 2015
  7. JarylW

    JarylW Active Member

    216
    41
    28
    Jun 19, 2014
    Singapore
    Ratings:
    +103
    Local Time:
    11:37 AM
    Interesting.. rtcamp was wonky for me. Both times i did a clean install and first time i was getting proper cache hits and 2nd install was all miss and bypass.

    Would be interesting to see once php 7 has redis module
     
  8. eva2000

    eva2000 Administrator Staff Member

    55,223
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:37 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    you mean their redis wordpress cache at nginx level or you mean their wp super cache setup ?
     
  9. JarylW

    JarylW Active Member

    216
    41
    28
    Jun 19, 2014
    Singapore
    Ratings:
    +103
    Local Time:
    11:37 AM
    Redis wordpress cache at nginx level. The good thing about RTCamp for wordpress users is that its geared towards only wordpress users and installation is easier and file structure is neater for that purpose. I think it was just passing --wpredis to install it iirc.
     
  10. eva2000

    eva2000 Administrator Staff Member

    55,223
    12,253
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,831
    Local Time:
    1:37 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah they do focus and specialise in wordpress..

    yeah waiting on PHP 7 supported Redis PHP extension support ! branch is there phpredis/phpredis at php7 ยท GitHub just needs work