Kafka Worker Pool in Go — Backpressure & Exactly-Once

Prerequisite: Part 5 of the System Design Masterclass. Read Part 4: Database Scaling first. Kafka Worker Pool in Go — Backpressure & Exactly-Once Answer-first: High-throughput event streaming in Go leverages Kafka zero-copy sendfile() kernel transfers combined with bounded goroutine worker pools. Natural backpressure is achieved using buffered Go channels, while partition-pinned workers preserve message ordering without distributed locks. Key Takeaways: Zero-Copy Performance: Kafka bypasses user-space buffer copies via sendfile(), routing data directly from Linux page cache to network socket buffers. Channel Backpressure: Bounded Go channels automatically throttle poll loops when downstream workers reach memory capacity limits. Partition-Aware Ordering: Pinning specific Kafka partition IDs to dedicated worker goroutines maintains strict message sequence guarantees. What You’ll Learn Kernel-Level sendfile() Mechanics: How zero-copy I/O bypasses the context switches between user and kernel space, preventing CPU cache invalidation. Worker Pool Partition Pinning: Why mapping partitions to specific workers is the only way to maintain order processing sequences without locking. Offset Commit Transaction Math: Implementing transactional offset commits inside Go consumers to guarantee idempotency under broker rebalances. Kafka vs RabbitMQ — When to Use Each? Key Concept: Kafka is a distributed commit log — messages are retained indefinitely, consumers manage their own offsets, and replay is possible. RabbitMQ is a message broker — messages are deleted after acknowledgment, the broker handles routing complexity, push-based delivery. They solve different problems. ...

June 18, 2026 · 8 min · Lê Tuấn Anh

Mastering Event-Driven Architecture with Dapr Pub/Sub

Mastering Event-Driven Architecture with Dapr Pub/Sub in Go In my previous post, we explored how abandoning monolithic architecture in favor of strict Domain-Driven Design (DDD) bounded contexts allowed an e-commerce platform to scale beyond 10,000+ orders per day. However, splitting one big database into 20+ isolated Postgres databases introduces a terrifying new problem: How do we maintain data consistency across disconnected services? The answer is Event-Driven Architecture (EDA). Rather than chaining blocking synchronous HTTP calls across the network — which guarantees a cascading failure if a single service is down — each microservice independently broadcasts out-of-band “Events” through a centralized broker. Services are decoupled from each other’s availability. A brief outage in the Notification service does not cause a checkout failure. ...

April 12, 2026 · 16 min · Lê Tuấn Anh