Introducing Dragonfly Cloud! Learn More

Question: What is the difference between horizontal and vertical scaling in Redis?


Redis supports both horizontal and vertical scaling, but they are used for different purposes and have different implications.

Vertical Scaling (Scaling Up): This involves adding more resources to a single node in a system. For Redis, this could mean increasing the CPU power, memory, or disk capacity of the server where your Redis instance is running. Vertical scaling can improve the performance of a single Redis instance by allowing it to process more data quickly.

# Example: Increasing the size of an AWS EC2 instance hosting Redis aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --instance-type m5.large

However, there are limitations to vertical scaling, such as the maximum capacity of a single machine and increased costs with high-end servers.

Horizontal Scaling (Scaling Out): This involves adding more nodes to a system. In the case of Redis, this could mean setting up multiple Redis instances and distributing the data among them. Redis offers built-in support for horizontal scaling through sharding with Redis Cluster. Each shard in a Redis Cluster handles a subset of the total hash slot, effectively partitioning the data across multiple nodes.

# Example: Creating a new Redis cluster with 3 master nodes redis-cli --cluster create --cluster-replicas 1

Horizontal scaling can provide higher availability and fault tolerance, but it also introduces complexity in terms of data distribution, consistency, and application design.

In conclusion, both vertical and horizontal scaling have their pros and cons. The choice between them depends on your specific use case, budget, performance needs, and the complexity you're willing to manage.

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.