All skills
redis avatar

/redis-clustering

@9d76cea official
by redisredis/agent-skills163 stars
30

Redis Cluster and replication guidance covering hash tags for multi-key operations, avoiding CROSSSLOT errors, and reading from replicas to scale read-heavy workloads. Use when designing keys for a sharded Redis Cluster, debugging CROSSSLOT errors on MGET / SDIFF / pipelines, configuring a multi-key transaction in a cluster, or routing reads to replicas for caches, analytics, or dashboards.

Use this Skill: https://skilld.dev/gh/redis/agent-skills/redis-clustering

This session only. Nothing lands on disk.

referencesread-replicas.md

≈297 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Use Read Replicas for Read-Heavy Workloads

For read-heavy workloads, distribute reads across replicas to reduce load on primaries.

Correct: Configure replica reads in Redis Cluster.

from redis.cluster import RedisCluster

rc = RedisCluster(
    host='localhost',
    port=6379,
    read_from_replicas=True  # Distribute reads to replicas
)

# Writes go to primary
rc.set("key", "value")

# Reads can be served by replicas (eventually consistent)
value = rc.get("key")

Correct: Use replica reads in standalone replication setup.

from redis import Redis

# Connect to primary for writes
primary = Redis(host='primary-host', port=6379)

# Connect to replica for reads
replica = Redis(host='replica-host', port=6379)

# Write to primary
primary.set("key", "value")

# Read from replica (eventually consistent)
value = replica.get("key")

Considerations:

  • Replica reads are eventually consistent
  • Don't read from replicas for data that was just written
  • Use for read-heavy, slightly-stale-OK workloads (caches, analytics, dashboards)

Reference: Redis Replication

Source: SKILL.md on GitHub

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    This skill provides educational guidance and code examples for working with Redis Clusters, focusing on hash tags for multi-key operations and scaling reads using replicas. It contains only documentation and standard library usage examples.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at 9d76cea. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 4 months ago
metadata
{
  "author": "Redis, Inc.",
  "version": "0.1.0"
}
  • redis
  • clustering
  • hash-tags
  • crossslot
  • replication
  • read-replicas
  • sharding
  • transactions

README badge

README badge for redis/agent-skills/redis-clustering

Fixes CROSSSLOT errors and scaling bottlenecks in sharded Redis Cluster by using hash tags to co-locate multi-key operations and routing reads to replicas. Targets deployments using MGET, transactions, pipelines, or Lua scripts across multiple keys, and read-heavy workloads that need to offload primary shards.

Generated from the current SKILL.md.

How do I fix a CROSSSLOT error on MGET or pipeline operations in Redis Cluster?
Use hash tags to force multi-key operations onto the same slot. Wrap the entity identifier in curly braces, e.g. `{user:1001}:profile` and `{user:1001}:settings`, so both keys hash to the same slot.
Can I route reads to replicas to reduce primary load?
Yes. In Redis Cluster, set `read_from_replicas=True` on the client. In standalone replication, point read operations to the replica node directly. Replicas are eventually consistent, so only use this for non-critical reads like caches or dashboards.
What happens if I hash-tag unrelated namespaces together?
They will collide on the same slot, creating a hotspot that defeats the purpose of sharding. Use a tag scoped to a single meaningful entity (e.g. `{user:1001}`) rather than a bare identifier.
Do I need to hash-tag every key in my application?
No. Only tag keys when you actually need them in multi-key operations (transactions, pipelines, Lua scripts). Single-key commands work fine without tags, and universal tagging creates unnecessary hotspots.

Generated from the current SKILL.md. These answers refresh after source changes.