cd /news/ai-infrastructure/back-to-code-ep-13-event-driven-arch… · home topics ai-infrastructure article
[ARTICLE · art-14390] src=dev.to pub= topic=ai-infrastructure verified=true sentiment=· neutral

Back to Code | Ep 13: Event-Driven Architecture — Kafka and the Async World

LogiFlow experienced a cascade failure when its invoice service crashed due to a memory leak, taking down the routing, tracking, and customer portal services because AI had connected them with synchronous HTTP calls. The team replaced the synchronous REST architecture with event-driven communication using Apache Kafka, where services publish domain events like "RouteCalculated" and consume them independently. This change isolates failures — when the invoice service goes down, events queue in Kafka and are processed upon recovery, preventing the domino effect that caused the 2 AM outage.

read2 min publishedMay 26, 2026

The 15-week technical battle of LogiFlow — a company waking up from the illusion created by artificial intelligence and returning to real engineering.

When the "Invoice" service crashed, the "Routing" service also went down — because AI had connected them with synchronous HTTP (REST). Cascade Failure.

It was 2 AM when the pager went off. The invoice service had run out of memory — a memory leak in a PDF generation library. Within seconds, the routing service started timing out. Then the tracking service. Then the customer portal. One service's failure had cascaded through the entire system like dominoes.

"Why does the routing service care if invoicing is down?" Defne asked, already knowing the answer.

"Because AI made routing call invoicing synchronously after every route calculation," Emre admitted.

// Routing service (Producer)
await kafka.send({
  topic: 'routing.events',
  messages: [{
    key: truckId,
    value: JSON.stringify({
      type: 'RouteCalculated',
      truckId,
      eta,
      timestamp: Date.now()
    })
  }]
});

// Invoice service (Consumer) — Runs independently
consumer.run({
  eachMessage: async ({ message }) => {
    const event = JSON.parse(message.value);
    if (event.type === 'RouteCalculated') {
      await generateInvoice(event);
    }
  }
});

Microservices should talk through Domain Events, not HTTP.

When the invoice service goes down now, the routing service doesn't notice. The events queue up in Kafka. When invoicing recovers, it processes the backlog. No cascade. No domino effect. No 2 AM pages.

Synchronous (HTTP) Asynchronous (Events)
Caller waits for response Fire and forget
Failure cascades Failure is isolated
Tight coupling Loose coupling
Easy to reason about Requires event schema design
Simple for 2 services Essential for 10+ services

1. Loose Coupling: Services should not wait for each other.

2. Domain Events: 'RouteCalculated', 'InvoiceGenerated' — communicate through events.

3. Dead Letter Queue: Failed messages should not be lost — they should wait in a separate queue for investigation and replay.

This is Episode 13 of the "Back to Code" series. Next up: Episode 14 — Technical Debt Credit Score.

Series: back.to.code · 2026

── more in #ai-infrastructure 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/back-to-code-ep-13-e…] indexed:0 read:2min 2026-05-26 ·