Skip to content

FAQ: Installation: Redis Server

Marko Vasiljevic edited this page Feb 24, 2021 · 2 revisions

Installation Instructions

Summary:

This document will walk through the setup and configuration of enabling Redis in your Wordpress environment.

Redis Setup

Redis is a very performant solution to give your site a quick speed boost and doesn't require much effort.

Enabling Redis cache support

  • Make sure that the redis server is accessible from the web application servers
    • Redis installation instructions: https://redis.io/topics/quickstart
    • If installing redis on a dedicated server, make sure that the web application servers have access to TCP Port 6379
    • Add the following at the end of your /etc/redis/redis.conf config file
      maxmemory 2048mb  # This should be 50% of your available RAM in the node 
      maxmemory-policy allkeys-lru
      
  • Add the following in the db-config.php file in the ini directory of the w3-total-cache plugin directory
    //
    // redis config cache
    //
    define( 'W3TC_CONFIG_CACHE_ENGINE', 'redis');
    define( 'W3TC_CONFIG_CACHE_REDIS_SERVERS', 'redis_hostname::6379' );
    
    // optional redis settings
    define( 'W3TC_CONFIG_CACHE_REDIS_PERSISTENT', true );
    define( 'W3TC_CONFIG_CACHE_REDIS_DBID', 0 );
    define( 'W3TC_CONFIG_CACHE_REDIS_PASSWORD', '' );
    
  • Enable the following in the Performance menu in the WP Admin
    • General > Page Cache > Redis -- This provides the most bang for the buck
    • General > Database Cache > Redis
    • General > Object Cache > Redis

Performance Testing results

Environment Setup

  • docker
  • php-fpm 7.2
  • nginx
  • mariadb 10.1
  • redis 4.0
  • siege
  • WP Plugin: Export All Posts
  • wptest.io sample content
  • MacOS High Sierra
  • 512GB SSD w/ 16GB RAM
  • IntelliJ 2017.03

Object and Database Cache enabled 5 minute run:

Transactions:		        1441 hits
Availability:		      100.00 %
Elapsed time:		      250.83 secs
Data transferred:	       87.08 MB
Response time:		        2.12 secs
Transaction rate:	        5.74 trans/sec
Throughput:		        0.35 MB/sec
Concurrency:		       12.19
Successful transactions:        1362
Failed transactions:	           0
Longest transaction:	        5.93
Shortest transaction:	        0.49

Page, Object and Database Cache enabled for 10 minute run:

Transactions:		       13862 hits
Availability:		      100.00 %
Elapsed time:		      563.31 secs
Data transferred:	      291.82 MB
Response time:		        0.11 secs
Transaction rate:	       24.61 trans/sec
Throughput:		        0.52 MB/sec
Concurrency:		        2.73
Successful transactions:       13107
Failed transactions:	           0
Longest transaction:	        1.03
Shortest transaction:	        0.06

Redis Socket Support

W3 Total Cache supports Redis Unix socket. All you need to replace the default hostname with a Redis Unix socket (usually /var/run/redis/redis.sock or /var/run/redis/redis.sock:0) as shown in the example below (Please note that the screenshot shows Memcached, however, the procedure is same) Redis socket