PayPay Event-Driven Architecture: Kafka at Scale

Prerequisite: Familiarity with the concepts introduced in Part 1 — Microservices Gitops. Review it first if the terminology in this part is unfamiliar. Answer-first: Managing transaction surges during PayPay’s massive marketing campaigns requires event-driven architecture powered by Apache Kafka. Partition key tuning, Go consumer worker pools, and channel-based backpressure prevent message loss during peak traffic spikes. Answer-first: PayPay builds a decoupled microservices network by streaming transactions asynchronously via Apache Kafka. To ensure financial safety, consumers process events using idempotency keys tracked in distributed caches, preventing duplicate ledger entries or double-spend occurrences in the event of retries or network partition splits. ...

May 5, 2026 · 8 min · Lê Tuấn Anh

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

Golang Goroutine Pool Patterns: errgroup & Worker Pools

Golang Goroutine Pool Patterns: errgroup & Backpressure Preventing goroutine leaks in high-concurrency worker pools using errgroup. Writing robust worker pools that propagate context cancellation to all active goroutines. Every Go engineer eventually writes the same mistake: a loop that launches goroutines unconditionally. In a demo with 10 items, this works beautifully. In production with 50,000 incoming webhook events, it spawns 50,000 goroutines simultaneously, exhausts memory, and triggers the OOM killer. Kubernetes restarts the pod. The on-call engineer gets paged at 3 AM. ...

June 1, 2026 · 14 min · Lê Tuấn Anh