Skip to main content

Standard Configuration file for Redis

In my earlier post i have covered how to run multiple instances of redis also showed through a video how it can done.

In this post, I am going to cover best suitable redis (recently i come across this beautiful blog simplifying the concept of redis and its uses in real world) configuration file structure to have to minimize confusion to identify which ports belong to which cache.

for example if you are having several ports configured for redis, how you will determine which port is associated with which redis cache.So in our case i.e redis with Magento, we normally used 3 types of cache
  • Cache (magneto configuration files cache) 
  • Full Page Cache
  • Session Cache 

So, to avoid confusion among the ports and its associated cache, i would recommend to use following data in your redis configuration for each port respectively as shown.

  For Freelance Work & Queries Contact me by Email Id

1) Create a file with name redis-base.conf under /etc/ and put the below content in it.

vi /etc/redis-base.conf   

daemonize yes
timeout 0
tcp-keepalive 0
loglevel warning
databases 2
stop-writes-on-bgsave-error yes
rdbcompression no
maxmemory-policy volatile-lru
appendonly no  (disabling Append Only File) used for persistence
appendfsync everysec   OR always ?
no-appendfsync-on-rewrite no
slowlog-log-slower-than 10000
slowlog-max-len 1024
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
slave-serve-stale-data yes
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
tcp-backlog 511
tcp-keepalive 0
repl-disable-tcp-nodelay no

above parameters will be common for all redis instances we are going to use for Cache, Full Page Cache and Session cache.

2)  Configuration file for Full Page cache

vi /etc/redis-fpc.conf

include /etc/redis/redis-base.conf
port 6381
pidfile /var/run/redis/
logfile /var/log/redis/fpc.log
dir /var/lib/redis/fpc
maxmemory 1gb

3)  Configuration file for Session file

vi /etc/redis-ses.conf

include /etc/redis/redis-base.conf
port 6380
pidfile /var/run/redis/
logfile /var/log/redis/ses.log
dir /var/lib/redis/ses
maxmemory 1gb
save 900 1
save 300 10
save 60 10000

4) Configuration file for Cache

vi /etc/redis-obj.conf

include /etc/redis/redis-base.conf
port 6379
pidfile /var/run/redis/
logfile /var/log/redis/obj.log
dir /var/lib/redis/obj
maxmemory 3gb

We are including the base file /etc/redis/redis-base.conf within every configuration files as the base file is having common variables which would be require for cache/full_page_cache and session cache.

Let me know if you have any queries on above post, you can reach to me anytime.


  1. I love it whenever people come together and share thoughts.
    Great site, continue the good work!

  2. Valuable info. Lucky me I found your web
    site by accident, and I am stunned why this coincidence didn't took place in advance!
    I bookmarked it.


Post a Comment

Popular posts from this blog

Solution and Step to fix CVE-2019-5736 Vulnerability - Docker

Recently a new vulnerability has been discovered in the the internet market having target to Docker services. What is this Vulnerability: In short, Docker service uses another service called as runc which is container run time to spawn and run containers. which simply means if docker task is to create docker images then runc task would be running them and attaching a process to container. So as per the recent discovery by the maintainers of runc, the code of this service was having some bug which can be used by attackers to gain the root level of access of the host machine on which docker containers are running. How it can be Exploited: This vulnerability can be exploited in two ways (1) if the docker images are in use is vulnerable making the containers build from it vulnerable also (2) if somehow attacker got the access of containers and then trying to exploit using the bug present in runc and trying to get root privileges. Solution to Fix Vulnerability: Ce

How to Generate CSR using Openssl in Linux

Before Generating CSR ,let see what is Openssl. It is nothing but a core library ,which is used for general purpose in cryptography,it is an open source product which work towards the implementation of SSL and TLS protocols. Talking about openssl, some people called the certificates generated from openssl as "self signed certificate". lets go towards now,creating CSR and private key using openssl command, Just log in to any of your Linux box and run following command as  root user  replacing the required information as per your need . [root@SVR home]#   openssl req -new -newkey  rsa:2048 -nodes -sha256 -out domain_name.csr -keyout domain_name.key -subj "/C=US/ST=state/L=locality/O=organization/OU=organization unit Dept/"  You will get output like : Then check whether ,all the information we have entered ,while creating CSR is proper ,by decoding the CSR from some online tool. First do the cat to the csr file [root@SVR home]#  cat

Multiple instances of redis

In the last post I have covered how to install redis server on Centos/Rhel using rpm method and yum method and some troubleshooting skills. In this post i am going to cover how to install and configure redis to run with multiple ports.                                                                           But why we need more ports ? If you have read my earlier post , you already know that by default redis runs on single port 6379, which any one can use it for small website to cache the data. But for heavy website like magento we need to use additional ports along with 6379 to serve different cache from different ports. Like in Magento there is simple cache which is normally stored under /var/cache directory. Then there is Full Page Cache which is stored under /var/full_page_cache and session cache which is stored under /var/session_cache. Note : Discussion about cache/full page cache/session is not under the scope for this document.