Introducing Dragonfly Cloud! Learn More

Question: How can Redis Enterprise be scaled for large applications?

Answer

Scaling Redis Enterprise involves several methods, primarily:

  1. Vertical Scaling (Scaling Up) - This involves increasing the capacity of a single Redis database by adding more resources such as CPU, RAM etc. It's the easiest way to scale but has its limitations based on maximum available hardware specifications.

  2. Horizontal Scaling (Scaling Out) - This involves partitioning data across multiple Redis databases. Redis Enterprise supports automatic sharding that allows you to split your dataset across multiple shards.

Here's a brief example of how you might use Redis Enterprise to scale horizontally:

# Assuming 'r' is a redis.Redis instance r = redis.Redis(host='localhost', port=6379, db=0) # Create a new sharded Redis Enterprise database shard_count = 4 # number of shards depends on the size and needs of your application r.execute_command('FT.CREATE', 'myIndex', 'ON', 'HASH', 'PREFIX', '1', 'doc:', 'SCHEMA', 'field1', 'TEXT', 'SORTABLE', 'field2', 'NUMERIC', 'SORTABLE') # Now, when you add data, it will be automatically sharded across the specified number of shards. for i in range(10000): r.execute_command('FT.ADD', 'myIndex', f'doc:{i}', '1', 'FIELDS', 'field1', 'value1', 'field2', i)
  1. Replication - Redis Enterprise uses replication to provide high availability and data durability. You can configure the number of replicas per master shard.

  2. Auto-failover - In case a node fails, Redis Enterprise can automatically failover to a replica without human intervention.

  3. Persistence options - Redis Enterprise provides various options for persistence like AOF (Append Only File) every second, snapshotting, and backup to remote locations. These techniques can help to prevent data loss.

Remember, scaling always depends on specific application needs. It's recommended to monitor your application and adjust accordingly over time.

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.