Kafka vs Temporal: When to Use Each, and When to Use Both
Kafka is a durable event stream; Temporal is a workflow orchestrator. Learn which solves your problem and why many teams use them together.
StripePragya MehtaProblem & solution
Stripe describes how its Document Database fleet previously handled degraded MongoDB shards with single-step, hard-coded plugins that struggled with combined failures, intermediate states, and more than 40 shard layouts. The replacement models shard topology and health as a directed graph, with infrastructure operations as edges and safety invariants defining valid states. A simulator uses breadth-first search to find minimum-operation recovery paths, while an abstraction over Temporal contexts lets the same remediation logic run in memory without real infrastructure calls; later, the system also uses Dijkstra's algorithm. The system reduced pager volume by 30%—about 200 pages annually—reclaimed 12 days of fleet health each year, and handled a new layout with zero code changes, according to the post.
The original auto-remediation system used hard-coded plugin ordering and layout-specific checks. Combined failures could create circular dependencies or states outside the plugins' preconditions, while onboarding each new shard layout took about one week and canceled workflows could leave shards requiring manual cleanup.
The system models shard state as a directed graph and operations as state transitions constrained by safety invariants. It searches simulated states with breadth-first search for minimum-step recovery paths, uses an in-memory context abstraction to avoid real I/O during exploration, and executes selected plans through durable Temporal workflows. The source also describes later use of Dijkstra's algorithm.
Breadth-first search prunes states that violate invariants such as unsafe vote counts, insufficient healthy voting nodes, or invalid priority and vote combinations.
A CommonContext abstraction allows remediation workflows to use either Temporal's production context or an in-memory simulation with simulated Source of Truth and Ground Reality providers.
Reported results include 30% fewer pages, approximately 200 fewer pages per year, 12 fewer days of degraded shard health annually, and zero code changes for a newly onboarded layout.
Summaries are generated from the original by a language model. Check the original before relying on it.
See the idea
Kafka is a durable event stream; Temporal is a workflow orchestrator. Learn which solves your problem and why many teams use them together.
Keep reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
One useful email. Unsubscribe anytime.