Skip to content

Redis vs Kafka — When to Use Which

First PublishedByAtif Alam

One concrete application of when to introduce what: when do you add Redis, when do you add Kafka, and when do you use both?

Decision signalChoose Redis when…Choose Kafka when…
Primary problemYou need faster reads / shared quick stateYou need async workflows / decoupling
Data natureCurrent state (latest value matters)Event history (sequence matters)
Typical useCache, session store, rate limiting, locks, countersEvent bus, audit log, fan-out to many consumers
Latency goalSub-ms to a few ms for lookupsLow ms but not “cache-fast”; throughput-focused
DurabilityNice-to-have; can tolerate cache loss (or persist separately)Often required; events must survive restarts/outages
Fan-outLimited (pub/sub exists but not replay-friendly)Built for many consumer groups independently
Replay / backfillNot a replay systemCore feature: replay, reprocess, backfill
OrderingNot a core guarantee across distributed usageOrdering per partition is a core concept
BackpressureNot the main strengthBuilt-in via consumer lag + offsets
Scale patternMemory-bound; scale by sharding/clusterDisk + network-bound; scale via partitions + brokers
Failure mode if wrong toolCache turns into a fragile “mini-database”Kafka becomes overkill for simple caching/state
Quick rule”Make reads cheap""Make work async + scalable”

Very typical pattern:

  • Kafka = source of truth for events
  • Redis = serving layer for fast reads / counters / rate limits / derived state

One-liner: Redis is for fast access to shared state to reduce latency and offload databases.

Use cases: Caching hot reads, sessions, rate limiting, distributed locks, counters, leaderboards.

Key properties: In-memory, very low latency, supports TTL, simple data structures, optional persistence.

Tradeoffs / pitfalls: Cache invalidation, memory cost, data loss risk if treated as source-of-truth, hotkey issues.

Scaling lever: Sharding/cluster, TTL tuning, avoid large values, mitigate hot keys.

When to add it: DB is the bottleneck for reads or you need fast shared state (sessions/limits).

One-liner: Kafka is for reliable event-driven systems: decouple services, scale consumers, and enable replay.

Use cases: Async processing, event bus, CDC pipelines, analytics streams, audit logs, fan-out to many teams.

Key properties: Durable log, partitions + offsets, consumer groups, replay, high throughput.

Tradeoffs / pitfalls: Operational complexity, partitioning strategy, schema evolution, exactly-once complexity, lag management.

Scaling lever: More partitions (parallelism), more brokers, tune batch size, manage consumer lag, right retention.

When to add it: Multiple consumers need the same stream, background workflows grow, or replay/backfill becomes a requirement.

Use these for fast justification in design discussions or docs:

  • Redis if the problem is latency / read amplification.
  • Kafka if the problem is coupling / throughput / fan-out / replay.
  • Kafka for history, Redis for state.
  • Kafka moves work off the request path; Redis speeds up the request path.

Back to Optimization Quick Reference or Infrastructure building blocks.