This is high level description of Redis HA Implementation Options.
There are couple of ways to setup Redis in HA mode as per business requirements. Main concern in Redis HA is how we are going to distribute Writes and Reads. Sometimes RedisHA is handled at Application level as well.
Option 1: Manual
This is the easiest way to achieve HA in AWS behind ELB. However it is suitable for specific requirements such as it should serve request faster with lowest response time such as for Ad Serving. Redis will pull data from RDBMS server and application server will contact Redis to serve requests.
– Multiple servers will have Redis installed and will be behind ELB.
– There will be one bash script installed on all Redis servers which pull data from RDBMS server and load in Redis. This script will be executed after Fix regular interval and will update data in Redis.
– Application server will contact ELB on port 6379 and get data.
– This script should get executed on all server at same time using cron schedulers
– We may use replication in this as well but there are chances of microseconds delay in response.
Option 2: Using Sentinel, EIP failover / DNS failover
– Redis and Sentinel to be installed on multiple servers.
– There will be one master and other as slave. Replication will be configured.
– Robust Sentinel deployment requires minimum 3 instances.
– Sentinel will take care of Failover
– Elastic IP will be configured on Master server.
– If Master server fails our script will assigned this Elastic IP to new master server like keepalived.
– In AWS ElasticIP Failover needs to be configured differently. Have a look at this link: http://neeleshgurjar.co.in/techidnyan/configure-elastic-ip-failover-between-ec2-instances-in-aws-2/
– Route53 DNS also can be used to failover of domain name than ElasticIp failover.
– There may be delay in switching process.
Option 3: Using HAProxy, Sentinel
– 2 HAProxy instances will run behind ELB in 2 different AZ.
– Robust Sentinel deployment requires minimum 3 instances. We can install Sentinel on 3 separate instances or it can be installed on 2 HAProxy instances and one sentinel will be on separate instance in 3rd AZ.
– There will be 2 Redis Servers, one master and other as slave.
– Sentinel will take care of Failover from Master to Slave.
– Both HAproxies will detect new master automatically and start serving.
– If any of the HAProxy instance fails then ELB will make it out of service.