Skip to content

Instantly share code, notes, and snippets.

@afifmohammed
Last active May 8, 2025 06:10
Show Gist options
  • Save afifmohammed/3b3dc55b122a4c0c1cced148fb97bcba to your computer and use it in GitHub Desktop.
Save afifmohammed/3b3dc55b122a4c0c1cced148fb97bcba to your computer and use it in GitHub Desktop.
Why EventHub over Service bus for Eventing

AzureServiceBus vs. EventHub

ASB has been around for a while and is a familiar tool for inter service eventing using publish subscribe. This document outlines

  1. Where ASB is good at.
  2. What are the primary constraints it introduces.
  3. How EH addresses this by design and how to address the trade-offs with EH.

And draws the conclusion to what scenarios are best suited to EH vs ASB.


Where ASB Excels

  1. Single‑message commit – one message, one outcome—simple and fast.
  2. Ephemeral delivery – messages vanish once acknowledged, perfect for transient notifications.
  3. Massive fan‑out – four nodes × eight cores = 64 parallel consumers.

ASB pain points

ASB pain point EH cure
Replay gap – no native “send it again.” Offset rewind – redeploy the fix, reset the offset, self‑heal.
Slow‑consumer risk – one laggard drags others down. Isolated lag – each consumer owns its position.
No selective start – can’t backfill “from last Monday.” Time‑travel starts – pick an offset (“‑2 h”, “midnight UTC”).

EH primary trade-off

With EH your throughput is capped by your number of partitions. For uses cases that don't require sequential processing, and work at per message transactions, increasing throughput by throwing more compute and per message retries/DLQ is quite useful.

Solution: Queue‑in‑Front of EH Consumer

Need both replay semantics and per‑message commit speed? Put an ASB queue in front of the consuming logic:

Producer → Event Hub (immutable stream) → ASB queue → Consumer

The stream remains your source of truth; the queue fans work out across as many workers as you like for the given Consumer.


Bottom Line

  • Cross‑service events ➜ EventHub streams.
  • Inside‑service tasks ➜ ServiceBus queues.
  • Need both? Stream it from producers, queue it behind consumers.

Pick the transport that fits the burden—and layer when required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment