In the previous blog I discussed transactions. In this blog I want to highlight the scalability and high availability features available in Redis.
RDBMS’s are designed to run on big boxes. Scaling is done virtually by throwing more hardware at the server. This is in complete contract to NoSQL databases which are designed to be distributed systems that scale horizontally using lots of smaller commodity hardware. Redis utilizes the following scalability and high availability features.
Clustering
Clustering is another term for Sharding data in the Redis context. It is a way to horizontally split data across master nodes where each node holds a subset of the entire data. Each master node has two slave nodes in order to cope with up to two server failures per node. Redis can handle up to 1000 nodes. If you only had a single master with two slaves then it behaves like the replication feature below.
So what’s the benefit?
- Used if you have more data than can fit in RAM.
- Improves write performance by spreading the load
You can get more information on setting up and using clustering here.
Replication
Redis has the concept of Master/Slave replication. Slave servers have an exact copy of the data that is on the master. When updates occur on the master, it will send the updates to its slaves. If there is a network loss or a slave goes down, when it is restarted the slave will continue where it left off. If there is data loss the slave will request a full snapshot of the master.
So what’s the benefit?
- You can turn off persistence on the master node which increases its performance knowing there are slaves to take over in the event of a master failure.
- Deliver High availability: If master node goes down, the slave can be immediately promoted, so you don’t experience any down time.
- Under extremely high load, you could balance the reads between the master and slave.
You can get more information on setting up and using replication here.
Sentinel
This is a High Availability monitoring solution for Redis replication configured above. It provides automated processes for monitoring and managing failovers.
You can get more information on setting up and using Sentinel here.
In the next blog I will show how a demo application uses Redis to cache searches sent to Twitter.