Back to blog

Redis Architecture Diagram: Caching, Pub/Sub, Cluster & Sentinel Patterns (2026)

How to create Redis architecture diagrams for caching, session storage, pub/sub messaging, and distributed locking. Covers standalone, Sentinel, Cluster, and Redis Stack — with AI prompt templates.

R
Ryan·Senior AI Engineer
·

Redis architecture diagrams appear in nearly every production system — as a cache sitting in front of a database, a session store behind an API, a pub/sub broker between services, or a distributed lock manager coordinating workers. Redis's simplicity hides genuine architectural complexity: the topology changes significantly between standalone, Sentinel, and Cluster modes, and the correct diagram depends on which guarantees matter — availability, partition tolerance, or latency. This guide covers the key Redis deployment patterns, what to show in each, and AI prompt templates for generating accurate diagrams.

Redis deployment topologies

  • Standalone (single node): A single Redis primary with no replication. Appropriate for development, ephemeral caching where data loss is acceptable, or very low-throughput use cases. Show your application service pointing directly to one Redis node with no failover path — make the single-point-of-failure explicit in the diagram.
  • Primary/replica replication: One primary handles all writes; one or more replicas serve reads and can be promoted in a failover. Replication is asynchronous by default. Show the replication stream from primary to replicas, annotate whether reads are distributed across replicas, and mark the async replication lag risk.
  • Redis Sentinel: Adds automated failover to primary/replica setup. Three or more Sentinel processes form a quorum that monitors the primary; on failure, Sentinels elect a new primary and update clients. Clients connect to Sentinels to discover the current primary address. Show: Sentinel nodes (typically 3), primary, replicas, and the quorum election flow. The “split brain” prevention via odd quorum count is worth annotating.
  • Redis Cluster: Horizontal sharding across multiple primary nodes. The keyspace is divided into 16,384 hash slots distributed across N primaries. Each primary can have its own replicas. Clients use cluster-aware libraries and are redirected via MOVED/ASK responses. Show: all primary nodes, their hash slot ranges, their replicas, the gossip protocol between nodes, and how a client gets redirected on a MOVED response.
  • Managed Redis (Elasticache, Upstash, Redis Cloud): Cloud-managed deployments abstract Sentinel or Cluster internals. Show the managed cluster as a logical unit, annotate the VPC endpoint or private link, and show your application's connection pooling layer (typically via a library like ioredis or lettuce with connection pooling configured).

Common Redis usage patterns to diagram

  • Cache-aside (lazy loading): Application checks Redis first; on cache miss, fetches from the primary database, writes to Redis with a TTL, and returns the result. Show the read path (Redis hit), the miss path (DB read → Redis write → return), and annotate the TTL and eviction policy (LRU, LFU).
  • Write-through cache: Application writes to Redis and the primary DB atomically (or via a cache-writing layer). Keeps cache consistent with DB at write time. Show the dual-write path and any rollback logic on partial failure.
  • Session store: Stateless API servers store session tokens in Redis (keyed by session ID). Show multiple API instances all pointing to the same Redis cluster, annotate key structure (e.g., session:{id}), TTL, and any session renewal logic.
  • Pub/sub messaging: Publisher services write to channels; subscriber services receive messages. Show publishers, the Redis pub/sub channel topology, subscribers, and note that pub/sub in Redis is at-most-once (no persistence) — useful for real-time events where missed messages are tolerable.
  • Redis Streams: Persistent, consumer-group-based message streaming. Unlike pub/sub, Streams persist messages and support consumer groups with at-least-once delivery. Show producers, the stream (named key), consumer groups, consumers, and the acknowledgment flow. Contrast with Kafka for smaller-scale use cases.
  • Distributed lock (Redlock): Acquiring a lock across 2N+1 independent Redis nodes. Show the lock acquisition flow (SET key value NX PX TTL), the quorum majority check (N+1 nodes must respond), and the lock release flow. Annotate the clock drift risk and why Redlock requires independent nodes.
  • Rate limiting: Using Redis INCR + EXPIRE (or a sliding window with sorted sets) to enforce per-user or per-IP rate limits at the API gateway or middleware layer. Show where in the request path the Redis rate-limit check occurs and the fallback on Redis unavailability.

Prompt examples for Redis architecture diagrams

Redis Sentinel with cache-aside pattern

"Redis Sentinel setup for a Node.js API. One Redis primary (r6g.large, 6GB) and two replicas, all in separate availability zones (us-east-1a, 1b, 1c). Three Sentinel nodes monitor the primary with quorum of 2. API servers use ioredis with Sentinel auto-discovery — clients connect to Sentinel endpoints, not the primary directly. Cache-aside pattern for user profile reads: check Redis key 'user:{id}' (TTL 300s), on miss fetch from RDS PostgreSQL and populate cache. On cache write, pipeline SET + EXPIRE. Eviction policy: allkeys-lru. Show primary, replicas, Sentinels, API instances, RDS, and the read/miss paths. Label async replication between primary and replicas."

Redis Cluster for horizontal scaling

"Redis Cluster with 3 primary shards and 3 replicas (one replica per primary), deployed on AWS ElastiCache. Shard 1: hash slots 0–5460 (us-east-1a), Shard 2: slots 5461–10922 (us-east-1b), Shard 3: slots 10923–16383 (us-east-1c). Each shard has a replica in a different AZ for HA. Application connects via cluster-aware ioredis client. Show how a key lookup is routed to the correct shard via hash slot calculation, the MOVED redirect on slot migration, and the replica promotion flow on primary failure. Annotate the ElastiCache cluster endpoint vs. the individual node endpoints."

Redis Streams as a lightweight Kafka alternative

"Redis Streams for an order processing pipeline. Three producer services (checkout, mobile app, API) publish order events to a 'orders' stream using XADD. Two consumer groups: 'fulfillment' (3 consumers, each processing separate orders) and 'analytics' (1 consumer). Each consumer uses XREADGROUP to claim messages and XACK after processing. A redelivery worker uses XAUTOCLAIM to retry messages that have been pending for more than 30 seconds (consumer crashed without ACKing). Stream max length: 100,000 entries (MAXLEN with ~). Show all producers, the stream, both consumer groups, pending entry lists, and the redelivery path. Compare with Kafka Consumers in a table."

Multi-layer caching with Redis

"Three-tier caching architecture for a high-traffic product catalog API. Layer 1: in-process LRU cache (Node.js lru-cache, 500 items, TTL 30s) on each API instance. Layer 2: Redis Cluster (shared across all API instances, TTL 300s, allkeys-lru eviction, 8GB). Layer 3: PostgreSQL primary with read replicas. Cache population on miss: L1 miss → check L2 → if L2 miss → query PostgreSQL read replica → populate L2 (SET with PEXPIRE) → populate L1 → return. Cache invalidation on write: write to PostgreSQL → publish invalidation event to Redis pub/sub channel 'cache-invalidate' → all API instances subscribe and clear their L1 cache for affected keys → delete L2 keys. Show all three cache layers, the read and miss paths, and the invalidation event flow."

Redis vs other caching and messaging solutions

SystemPrimary use casePersistenceBest for
RedisCache, session, pub/sub, streamsOptional (RDB/AOF)Low-latency, flexible data structures
MemcachedPure caching onlyNoneSimple string cache, multi-threaded
Apache KafkaEvent streaming, CDCDurable, configurable retentionHigh-throughput, long retention, replay
DragonflyRedis-compatible, multi-threadedOptionalHigher throughput on multi-core hardware
ValkeyRedis-compatible OSS forkOptional (RDB/AOF)License-free Redis drop-in (Linux Foundation)

What to annotate on a Redis diagram

  • Persistence mode: Whether RDB snapshots, AOF (append-only file), or no persistence is configured. This determines data recovery behavior on restart.
  • Eviction policy: The configured maxmemory-policy (noeviction, allkeys-lru, volatile-lru, etc.) and maxmemory limit. Critical for understanding behavior under memory pressure.
  • Connection pooling: Show the connection pool configuration in your client libraries (min/max pool size). Redis is single-threaded — unbounded connections degrade performance.
  • TLS and authentication: Whether TLS is enabled for client connections (critical for production) and the authentication method (requirepass, ACL users for Redis 6+).
  • Key naming conventions: Annotate the key namespace pattern (e.g., app:env:type:id) on the diagram — prevents key collisions when multiple teams share a cluster.

Related guides: Kafka architecture diagrams, WebSocket architecture diagrams, microservice architecture patterns, and streaming data architecture.

Ready to try it yourself?

Start Creating - Free