Question: Is Redis scalable?


Yes, Redis is highly scalable. It provides various mechanisms that can be used to scale the system and meet different application demands.

  1. Vertical Scaling (Scaling Up): You can use a more powerful machine with more processors, memory, and disk capacity. However, there is a limit to how much you can scale up.
# Start Redis Server redis-server --maxmemory 10gb
  1. Horizontal Scaling (Scaling Out): Redis supports horizontal scalability through its sharding mechanism. Sharding means splitting your data into smaller parts and storing them on different Redis nodes.

There are two primary ways you can do this:

  • Client Side Sharding: Here, the client decides how the data is distributed. The user must manually decide which shard to write or read.
import redis pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool) r.set('key', 'value')
  • Redis Cluster: This is an automated sharding solution provided by Redis where it automatically splits the dataset among multiple nodes, providing operations with linear scalability.
# Creating a Redis Cluster redis-cli --cluster create \ \ --cluster-replicas 1

Remember, while sharding allows for horizontal scaling and improves overall performance, it does increase complexity as data consistency becomes more challenging to manage.

  1. Replication: Redis offers data replication to enhance read performance. It allows you to create copies of your master node's data onto one or multiple slave nodes. Read operations can then be divided among these nodes, reducing the load on the master node.
# In the slave node configuration file, add: slaveof <masterip> <masterport>

However, replication is not designed to provide additional write scalability. Writes still have to go to the master node, and the slaves synchronize data from the master.

Please remember that each scaling method comes with its own trade-offs, so you should choose what suits your needs best.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.