Kafka vs Redis Streams: Sizing an Event Backbone for SaaS

Architecture

Compare Kafka and Redis Streams for SaaS event backbones. Estimate retention, memory, consumer capacity, recovery time, and operating work using your workload.

TL;DR

  • Kafka is a replicated, partitioned log designed for retained history and independent consumer groups. Redis Streams is a stream data type stored in Redis with consumer groups, pending-entry tracking, and configurable trimming.
  • Kafka uses disk-backed logs and replication. Redis holds active data in memory and can persist through RDB snapshots and/or AOF. Retention, persistence, replicas, and restore time belong in the design.
  • There is no dependable rule like “Redis below 10,000 events per second, Kafka above it.” Size from event bytes, retention, groups, processing cost, and recovery objectives.
  • Choose the smallest service that meets replay and retention requirements. A transactional outbox in PostgreSQL can make publishing reliable whichever broker delivers the event.

Start with the delivery contract

Kafka vs Redis Streams is not just a throughput contest. Both can move events between producers and consumers. Their storage and consumption models lead to different tradeoffs for retention, independent replay, memory planning, recovery, ordering, and operations. The right choice follows from what your product needs when a consumer falls behind or an integration has to replay yesterday’s events.

Write down the contract first. How long must an event remain available? Can a new consumer start from the beginning of that history? Must several systems each receive every event? What happens when one consumer is offline for a day? Is ordering required for the whole topic, or only events for one account or object? Which effects can be safely repeated after a timeout?

Distinguish an internal work queue from an event log. A queue distributes a unit of work among competing workers. An event log supports consumers reading retained history, often at different positions and for different purposes. Some systems need both. Using a retained log as a job queue without defining acknowledgement, replay, and trimming can strand or repeat work.

Compare the managed service you would actually operate. Cloud offerings can change how much infrastructure your team owns, but feature sets, persistence, retention, availability guarantees, and limits vary. Verify those details for the selected provider and plan.

How Kafka and Redis Streams represent events

Kafka stores partitioned append-only logs

A Kafka topic is split into partitions. Records in one partition have a stable order, and a consumer group divides partition assignments among its active consumers. A record remains available under the topic retention and cleanup policy after a consumer reads it. The consumer can move its offset and replay retained records, while another group tracks its own position.

This is useful when multiple independent systems need the same event history, a consumer may recover after a long outage, or a new projection must be rebuilt. Kafka producers can use idempotence to prevent duplicates caused by producer retries within the Kafka protocol. Transactions support particular Kafka read-process-write flows. Neither guarantee atomically includes an unrelated payment provider or arbitrary application database. Apache Kafka design and delivery semantics · Kafka producer configuration

Partitioning creates a capacity and ordering decision. A key directs related records to a partition, preserving their partition order and shaping load distribution. A hot key can concentrate traffic on one partition even when the rest of the topic is quiet. More partitions can raise possible consumer parallelism but add replication and operational costs. A consumer group cannot process more partitions concurrently than it has partitions assigned, though extra consumers can remain idle.

Redis Streams keeps entries in a Redis data structure

A Redis Stream is an append-oriented data structure with generated entry IDs. Consumer groups coordinate delivery among consumers. Reading through a group creates pending entries that stay associated with a consumer until acknowledged. If a consumer fails, another can inspect and claim stale pending work. Acknowledgement updates group state. It does not prove that a separate database transaction committed.

Redis supports persistence through RDB snapshots, the Append Only File (AOF), or both. Recovery point, write latency, disk cost, replication, and restore time depend on selected settings. A Redis stream also shares the memory and eviction environment of its Redis deployment. Retention must be bounded deliberately. Trimming interacts with pending consumer-group references, so choose a strategy that matches the Redis version and recovery policy. Redis Streams consumer groups, pending entries, and trimming · Redis persistence options

Redis Streams can fit a team already operating Redis for latency-sensitive data that needs a modest durable stream alongside it. That changes when the event history outgrows the memory budget, persistence cannot meet the recovery objective, or long-term replay becomes important.

Translate requirements into a sizing model

Start with measured production or representative staging values. Record average and high-percentile serialized event size, peak and sustained events per second, retention duration, consumer groups, active consumers per group, and CPU or external-service time per event. Include headers, IDs, indexes, and representation overhead. A 1 KiB JSON payload in an application request does not necessarily occupy 1 KiB in a broker.

Estimate uncompressed daily payload bytes with:

daily_payload_bytes = events_per_second
                    * measured_stored_bytes_per_event
                    * 86,400

For Kafka, approximate retained disk as stored bytes per second times retention seconds and replication factor, then add headroom for indexes, segment overhead, bursts, skew, and recovery. Compression can reduce disk use, but measure representative producer batches. Plan broker disk headroom and replica recovery bandwidth separately.

For Redis, measure memory with representative entries and group state, then multiply by peak retained volume and the groups and pending work you will maintain. Leave capacity for other keys, allocator fragmentation, replication buffers, persistence rewrite work, failover, and growth. Entries and consumer-group metadata are not free. Test trimming, restore, and pending-entry recovery with the exact Redis version and data shape.

To estimate consumer drain time, measure service rate per worker under the real bottleneck. If incoming rate is λ and aggregate service rate is μ, a backlog only shrinks while μ > λ. A rough estimate is:

drain_seconds ≈ backlog_events / (aggregate_events_per_second - incoming_events_per_second)

This assumes a steady service rate and similar message cost. Real workloads have payload variance, retries, hot keys, dependency throttling, and rebalances. Use the estimate to frame a load test, not to promise a recovery time.

Consumer groups, replay, and recovery

Kafka consumer groups track offsets by partition. A group can replay by resetting offsets while records remain retained, and separate groups advance independently. This makes it natural to add an analytical or search projection later. A slow group can still fall behind the retention window and lose older records unless retention is extended or events are archived elsewhere.

Redis consumer groups track delivered but unacknowledged entries in a Pending Entries List (PEL). A recovery process can inspect pending work and claim entries from a consumer that stopped. The application needs a policy for the idle threshold, retry count, and poison events. Trimming an entry while a group still references it changes the recovery story. Redis documentation describes trimming options for preserving references, deleting references, or trimming only acknowledged entries, depending on version. Redis Streams pending-entry recovery and trimming

Crashes create ambiguity in either system. A consumer can finish a database update, then die before committing its offset or acknowledgement. The event may be delivered again. Use an inbox table with a unique event ID or make each business operation idempotent. Acknowledging before the business transaction risks losing work. Acknowledging after it risks duplicate execution. A transaction that applies the business change and inserts the deduplication key can make redelivery safe within one database.

A dead-letter queue is not a complete failure policy. Preserve the original event ID, source, attempt count, last error, and replay owner. When replaying, decide whether to run current application code, preserve the original schema version, or transform the message first.

Choose based on workload shape

RequirementKafka is a strong fit whenRedis Streams is a strong fit when
Independent replayMany groups need separate offsets over retained history.Consumer groups and a bounded replay window meet the requirement.
Retention scaleLong retention and high aggregate volume justify replicated disk logs.Retained entries fit the Redis memory and persistence envelope.
OperationsThe team can operate Kafka or a managed Kafka service and needs its ecosystem.The team already operates Redis and can own trimming, persistence, and PEL recovery.
OrderingOrdering per key or partition maps to the domain.Stream order and group delivery fit, with application rules for concurrent effects.
Adjacent capabilitiesKafka Connect or stream processing reduces integration work.Low-latency Redis operations and a simpler work stream are sufficient.

This is a decision aid, not a benchmark result. Redis has persistence modes and Kafka has configurable retention, compression, and replication. Footprint depends on version, payload, traffic, consumer state, and managed-service settings.

Do not use a 10,000 events-per-second cutoff as a universal rule. At that rate, tiny events with short retention can be easier than large payloads with replaying groups. One Redis deployment may have ample memory, while another shares capacity with a latency-critical cache. Kafka may be self-managed or a service. Run a workload-shaped comparison instead.

Account for Kafka’s current operating model

Older comparisons often show ZooKeeper as a required Kafka component. Apache Kafka 4.0 removed ZooKeeper mode and operates with KRaft metadata quorum. That simplifies part of the infrastructure footprint, but Kafka still needs broker capacity, replication planning, storage monitoring, upgrades, security, and partition operations when self-managed. Use current release notes rather than applying an old cluster diagram to a new deployment. Apache Kafka upgrade notes: Kafka 4 uses KRaft

Managed Kafka moves some cluster operations to a provider, but the team still owns topic design, retention, quotas, schemas, producer behavior, and consumer recovery. Compare it against managed Redis using the boundaries your team actually maintains.

Run a benchmark that answers failure questions

Build representative producers and consumers for both candidates. Use real payload sizes, key distribution, compression, group count, persistence settings, and target retention. Measure producer p50 and p99 latency, throughput, CPU, memory or disk, replication lag, consumer lag, pending-entry growth, and recovery time after a worker restart. Include the managed service network path and availability-zone layout if production will use that deployment.

Exercise failure cases:

  • Stop a consumer during a database transaction and confirm deduplication prevents repeated side effects.
  • Pause a group for the expected outage window and check retained history.
  • Restart a Redis primary or Kafka broker under the chosen persistence and replication settings, then inspect the recovered event range.
  • Send one hot key and uneven payload mix to expose skew hidden by aggregate throughput.
  • Run a consumer slower than the producer and calculate whether the backlog drains within the recovery objective.
  • Test poison messages, malformed schemas, duplicate callbacks, and dead-letter replay.

Use an open-loop load test so offered load does not fall automatically as latency rises. A closed-loop test that waits for each response can make overload look stable. Record exact product version, persistence policy, topic or stream configuration, and instance size with each result.

Keep database publication atomic with an outbox

If an application writes an order to PostgreSQL and then publishes to Kafka or Redis, a crash between those actions can leave the database and broker disagreeing. Put the event in an outbox row inside the same PostgreSQL transaction as the business update. A publisher reads pending rows, delivers them, and records delivery state. Consumers deduplicate by stable event ID. The publisher can target either broker without changing the transaction boundary.

The outbox makes event intent atomic with the application write. It does not remove duplicate delivery or guarantee the destination is available. Retry with backoff, alert on the age of the oldest undelivered row, and decide whether the outbox is polled or streamed through change data capture. For a deeper example, see our PostgreSQL ledger guide and our guide to queues and durable workflows.

For a few bounded jobs, PostgreSQL-backed workers may avoid a separate event backbone. See how to control worker fairness across tenants. Add a broker when its independent delivery, retention, or scaling solves a demonstrated need.

Frequently asked questions

Should I choose Redis Streams below 10,000 events per second?

There is no universal events-per-second cutoff. Payload size, retention, consumer count, processing cost, persistence settings, and recovery objectives change resource requirements. Benchmark representative records and failure cases, then compare operating cost against service requirements.

Can Redis Streams be used as a durable event log?

Redis Streams can persist entries and consumer group state with Redis persistence, but durability depends on configured persistence and replication. Bound stream growth and test restore and failover. Kafka is generally a better fit when long retention and independent replay are central requirements.

How many Kafka partitions should a topic have?

Choose partitions from required consumer parallelism, per-partition throughput, key distribution, broker capacity, and growth. Partitions enable concurrency but add replication, file, recovery, and metadata work. Measure the workload and align ordering requirements with the key and partition strategy.

Do Kafka or Redis Streams guarantee exactly-once business processing?

Neither broker guarantees exactly-once side effects in an unrelated database or external API by itself. Kafka offers idempotent producers and transactions for supported Kafka read-process-write flows. Redis Streams supports acknowledgements and pending-entry recovery. Consumers still need idempotency and reconciliation around external effects.

Make the event contract drive the broker

Choose Kafka when retained replay, independent consumer groups, and a durable partitioned log are central, and the team can operate it or a managed service. Choose Redis Streams when the required stream and recovery window fit Redis’s memory and persistence model, and integration with existing Redis operations matters more than a large retained log. Compare the actual services you intend to run.

Before committing, measure representative traffic and test consumer recovery, retention, replay, and duplicate side effects. Size from payload bytes and backlog behavior rather than a throughput slogan. If you are planning an event backbone or replacing a brittle delivery path, talk to our engineering team about outbox boundaries, broker selection, and recovery objectives.

Dumb Potato Editorial

Putting this into practice?

Share the problem you’re solving and the tradeoffs you’re weighing with our engineering team.

See how we help with web applications

Discuss your project