The moment someone says “event streaming” in a design review, half the room writes down Kafka. It is the reflex answer, and it is usually wrong for the team asking the question. A Kafka cluster you can trust in production is not a dependency, it is a project. You need a quorum of brokers, you need to think about partition counts you cannot easily change later, you need ZooKeeper or KRaft, you need rebalancing you do not fully control, and you need at least two or three engineers who understand all of it well enough to be paged at 3am. For a team pushing a few thousand events per second between a handful of services, that is a lot of machinery to stand up so an order-created event can reach the email service.

I have run both. For most of the systems I have shipped, Redis Streams did the job on infrastructure that was already running for caching and rate limiting. It gives you an append-only log, consumer groups with per-message acknowledgment, pending-message tracking you can turn into a dead letter queue, and replay from any point in the stream. That is the actual feature list people reach for Kafka to get. This post walks the naive version first, shows where it breaks, then builds the production pattern, and ends with the honest line where you should stop and go buy Kafka.

The naive version: a Redis list as a queue

Before streams existed, the standard Redis “queue” was a list with LPUSH and BRPOP.

import redis
r = redis.Redis()

# producer
r.lpush("orders", order_json)

# consumer
while True:
    _, payload = r.brpop("orders")
    process(payload)

This works until you think about failure for ten seconds. BRPOP removes the element from the list the instant it hands it to you. If your worker crashes between popping and finishing process(), that event is gone. There is no acknowledgment, so Redis has no idea the work did not complete. There is no way for a second worker to pick up what the dead one dropped.

It is also a point-to-point queue, not a log. Once one consumer pops an item, no one else sees it. If you later add a fraud service that also cares about orders, you cannot. And there is no history: you cannot replay yesterday’s events because they were deleted as they were read.

Lists are fine for a best-effort background job queue. They are not event streaming. The two properties that matter for streaming, durable fan-out and recoverable consumption, are exactly the two lists do not have.

Streams: an append-only log with IDs

A Redis Stream is an append-only, ordered log. You append with XADD and every entry gets an ID that is <millisecond-timestamp>-<sequence>, which is monotonically increasing and doubles as a cursor.

# producer: append an event, let Redis assign the ID with "*"
event_id = r.xadd("orders", {
    "order_id": "9a3f",
    "user_id": "1021",
    "amount": "4999",
    "event": "order.created",
})
# returns something like b'1733270400123-0'

Unlike the list, XADD does not remove anything on read. The entry stays in the log. Multiple independent readers can consume the same stream at their own pace, and you can re-read old entries by ID. That already fixes fan-out and history.

Reading directly with XREAD lets you tail the stream from any point:

# read everything after a given ID, block up to 5s for new entries
resp = r.xread({"orders": last_id}, count=100, block=5000)

XREAD alone is enough for a single consumer that tracks its own last-seen ID. But if you want multiple workers to split the load, with each message going to exactly one worker and with crash recovery, you want consumer groups. That is the part that makes this a real alternative to Kafka.

Consumer groups: the actual workhorse

A consumer group is a named cursor shared by several workers. Redis hands each new message to exactly one consumer in the group and remembers which messages it handed out but has not yet seen acknowledged. That pending set is the whole trick.

# create the group once, starting from the end of the stream ("$")
# mkstream creates the stream if it does not exist yet
try:
    r.xgroup_create("orders", "fulfillment", id="$", mkstream=True)
except redis.ResponseError:
    pass  # BUSYGROUP: group already exists

Now each worker reads as a named consumer inside that group. The special ID > means “give me messages never delivered to anyone in this group.”

def worker(name):
    while True:
        resp = r.xreadgroup(
            groupname="fulfillment",
            consumername=name,
            streams={"orders": ">"},
            count=10,
            block=5000,
        )
        if not resp:
            continue
        for _stream, messages in resp:
            for msg_id, fields in messages:
                try:
                    process(fields)
                    r.xack("orders", "fulfillment", msg_id)
                except Exception:
                    # do NOT ack; it stays pending for retry
                    log.exception("failed %s", msg_id)

The flow in one picture:

producers ---XADD---> [ orders stream (append-only log) ]
                               |
                   consumer group "fulfillment"
                      /          |           \
                 worker-A     worker-B     worker-C
                    |            |             |
                 XACK on      (crash!)      XACK on
                 success    msg stays      success
                            PENDING -> reclaimed by A/C

When process() succeeds you call XACK, which removes the message from the group’s pending list. When it fails you do nothing, and the message sits in the pending entries list (PEL) tied to that consumer. It is delivered-but-not-acknowledged. This is at-least-once delivery, the same guarantee a normal Kafka consumer gives you, which means your handlers must be idempotent either way.

Failover: reclaiming work from a dead worker

Here is the scenario Kafka people assume Redis cannot handle. Worker-B reads ten messages, acknowledges three, then the pod gets OOM-killed. Seven messages are stuck in B’s pending list forever, because B is never coming back to acknowledge or retry them.

Redis exposes the pending list so another worker can take over. XPENDING inspects it and XCLAIM (or the newer XAUTOCLAIM) transfers ownership of messages idle longer than some threshold.

def reclaim(name, min_idle_ms=60000):
    # hand over any message idle > 60s to this consumer, in batches
    cursor = "0-0"
    while True:
        cursor, claimed, _ = r.xautoclaim(
            "orders", "fulfillment", name,
            min_idle_time=min_idle_ms,
            start_id=cursor, count=50,
        )
        for msg_id, fields in claimed:
            try:
                process(fields)
                r.xack("orders", "fulfillment", msg_id)
            except Exception:
                log.exception("reclaim failed %s", msg_id)
        if cursor == "0-0":
            break

Run this periodically in every worker. A message idle for more than the threshold means its owner is dead or wedged, so a healthy worker claims it and retries. That is consumer-group failover, done with two commands and no coordinator.

The one thing Redis does not do for you is decide a message is poison. XCLAIM increments a delivery counter, and you read it from XPENDING. Past some count you stop retrying and route the message out.

Dead letter queue from the delivery count

def drain_dead_letters(threshold=5):
    pending = r.xpending_range("orders", "fulfillment",
                               min="-", max="+", count=100)
    for item in pending:
        if item["times_delivered"] >= threshold:
            msg_id = item["message_id"]
            # fetch the body, copy it to a dead-letter stream, then ack it off
            entry = r.xrange("orders", min=msg_id, max=msg_id)
            if entry:
                _, fields = entry[0]
                r.xadd("orders.dlq", fields)
            r.xack("orders", "fulfillment", msg_id)

A dead letter stream is just another stream. You alert on its length and inspect it by hand. Nothing exotic, and you can replay from it later by reading it back and re-adding to the main stream.

Retention: the mistake that fills your RAM

This is the footgun, and it is the one thing you must configure or Redis Streams will quietly hurt you. Streams are append-only and XACK does not delete anything. The log grows forever by default. Because Redis is in-memory, an unbounded stream is an out-of-memory incident with your name on it. Kafka spills to disk and the cost of forgetting retention is a full disk days later. Redis punishes you in hours.

You cap the stream at XADD time. Use the approximate trimming form with ~, which lets Redis trim on macro-node boundaries and is far cheaper than exact trimming.

# keep roughly the last 1,000,000 entries
r.xadd("orders", fields, maxlen=1_000_000, approximate=True)

# or cap by age: keep roughly the last 24h (minid = now - 24h in ms)
cutoff = int((time.time() - 86400) * 1000)
r.xadd("orders", fields, minid=cutoff, approximate=True)
OptionKeepsUse when
MAXLEN ~ Nabout N most recent entriesthroughput is steady, you reason in message counts
MINID ~ tsentries newer than a timestampyou reason in time, “replayable for 24h”
no trimeverythingnever in production without a separate reaper

Pick a window that comfortably covers your worst realistic consumer outage plus the replay window you actually promise. If consumers can be down for an hour and you want a day of replay, size for a day, then multiply by your peak rate and your average event size and confirm the number fits in RAM with headroom. Do that arithmetic before you ship, not during the incident.

One subtlety: trimming by MAXLEN can drop entries that some slow consumer group has not read yet. There is no built-in “do not trim past the slowest group.” If you have a lagging consumer, trimming will skip its unread messages. Size retention against your slowest consumer, not your fastest.

Persistence and what you actually lose

Redis is in-memory, so the fair question is what happens on a crash. The answer depends on your persistence config, and you should set it deliberately.

  • With AOF (append-only file) at everysec, you lose at most about one second of writes on a hard crash. This is the sane default for a stream you care about.
  • With RDB snapshots only, you lose everything since the last snapshot, which can be minutes. Do not run a durable stream this way.
  • With a replica plus AOF, a primary failure fails over to the replica with a small window of possibly unreplicated writes.

Kafka’s replication-to-disk model is genuinely more durable out of the box. If losing one second of events on a rare hard crash is unacceptable, that is a real argument, and it is one of the few that actually points at Kafka rather than at habit.

Where Redis Streams stops and Kafka starts

I am not telling you Kafka is bad. I am telling you it is a specific tool for a specific scale, and most teams are not at that scale. Here is the honest decision matrix.

DimensionRedis StreamsKafka
Throughput ceilingtens of thousands/sec per instance, comfortably to ~100kmillions/sec across partitions
Retention sizebounded by RAMbounded by disk, cheap TB-scale
DurabilityAOF everysec, ~1s windowreplicated to disk, stronger
Ops burdenthe Redis you already runa cluster and people to run it
Partitioned parallelismone stream, consumer group splits loadpartitions give ordered parallelism
Ecosystemyou write the glueConnect, Streams, Schema Registry, ksqlDB
Replay horizonhours to a day, practicallyweeks to months

The threshold is not a single number, but these are the signals that you have outgrown Redis Streams:

  • Sustained throughput above roughly 100k events per second, or events large enough that RAM retention becomes expensive before it becomes useful.
  • You need to retain weeks or months of events for reprocessing, analytics backfills, or compliance. That is disk’s job, not RAM’s.
  • You need many independent teams and connectors reading the same firehose with strong per-key ordering across a large partition space.
  • You are building on the Kafka ecosystem specifically: Connect sink/source plugins, stream processing with ksqlDB or Flink, a schema registry enforcing contracts. Rebuilding that on Redis is more work than running Kafka.

If none of those are true today and none are clearly true in the next year, a Kafka cluster is cost you are paying for a scale you do not have.

Honest assessment

What works: for a team under roughly 100k events per second, Redis Streams delivers the real event-streaming primitives, consumer groups, acknowledgment, failover, dead lettering, and replay, on infrastructure you already run and already know how to operate. You add a few helper functions, not a cluster and a rotation. For the service-to-service event plumbing most backends actually need, it is the right call and it is less to break.

What does not work: retention is a loaded gun. Unbounded streams become OOM incidents, and MAXLEN trimming does not respect a lagging consumer, so you have to size the window against your slowest reader and do the RAM math up front. Durability is one second softer than Kafka under a hard crash. And you are writing the glue Kafka’s ecosystem gives you for free, which is fine at small scale and painful at large scale.

What to actually do: start with Redis Streams if you are already running Redis. Use XADD with MAXLEN ~ from the very first line of code, build XAUTOCLAIM-based reclaim and a delivery-count dead letter stream before you call it production, and turn on AOF at everysec. Write down the throughput and retention numbers that would push you to Kafka, put them on a dashboard, and migrate when you actually cross them, not when someone in a review says the word “streaming” out of habit.