Chapter 1: Shopee Microservices — Golang, gRPC & API Gateway Foundation

Multi-Language Edition: This chapter is also available in Vietnamese at 📖 Bản tiếng Việt (Vietnamese Edition). Series Hub: Shopee Architecture Masterclass | Next Chapter: Chapter 2 — Flash Sale Engine & Zero Overselling Answer-First: Shopee replaced its monolithic Python/Django backend with high-throughput Golang microservices communicating over ByteDance Kitex / gRPC to eliminate Global Interpreter Lock (GIL) contention and slash memory overhead. By implementing zero-copy Protobuf serialization (vtprotobuf), partitioned Consul service discovery with local agent DNS caching, and bounded worker pools with HTTP/2 and QUIC multiplexing at the API Gateway, Shopee reduced container CPU consumption by 7x while delivering sub-3ms p99 internal RPC latency under 500,000 requests per second. ...

Chapter 2: Shopee Flash Sale Engine — Redis Lua & Zero Overselling

Multi-Language Edition: This chapter is also available in Vietnamese at 📖 Bản tiếng Việt (Vietnamese Edition). Previous Chapter: Chapter 1 — Microservices Foundation | Series Hub | Next Chapter: Chapter 3 — Traffic Shield: Kafka Peak Shaving Answer-First: Shopee prevents inventory overselling during high-concurrency flash sales by combining local memory caching, Redis inventory sub-key sharding, and atomic Lua script decrements. This multi-tier architecture isolates hot keys in Redis memory shards and evaluates stock availability in sub-milliseconds without acquiring relational database locks. Adopting this pattern guarantees sub-10ms P99 latency bounds, zero-allocation memory optimization, and mathematically verified zero overselling across hundreds of thousands of concurrent checkouts. ...

Chapter 3: Shopee Traffic Shield — Kafka Peak Shaving & Circuit Breaking in Go

Multi-Language Edition: This chapter is also available in Vietnamese at 📖 Bản tiếng Việt (Vietnamese Edition). Previous Chapter: Chapter 2 — Flash Sale Engine & Zero Overselling | Series Hub | Next Chapter: Chapter 4 — Database Scalability: From MySQL to TiDB Answer-First: Shopee utilizes Apache Kafka queues for asynchronous peak shaving during 11.11 mega-campaigns. Decoupling user order submission from relational database persistence guarantees sub-50ms API responses while downstream consumer workers insert orders at a flat, controlled rate. Combined with Alibaba Sentinel adaptive load shedding, virtual waiting rooms, and strict Dead Letter Queue (DLQ) isolation, this traffic shield absorbs 10x traffic surges without database connection pool exhaustion or cascaded outages. ...

Chapter 4: Scaling Storage from MySQL Shards to TiDB Multi-Raft Architecture

Multi-Language Edition: This chapter is also available in Vietnamese at 📖 Bản tiếng Việt (Vietnamese Edition). Previous Chapter: Chapter 3 — Traffic Shield & Peak Shaving | Series Hub | Next Chapter: Chapter 5 — Full-Stack Observability Answer-First: Traditional MySQL sharding collapses under hyper-scale e-commerce growth due to manual resharding overhead, cross-shard joins, and high 2-Phase Commit (2PC) latency penalties. Shopee transitioned its massive order and inventory backbones to TiDB and TiKV, a cloud-native NewSQL distributed database. By decoupling stateless SQL compute (TiDB) from distributed transactional storage (TiKV) coordinated via Placement Driver (PD) and Multi-Raft consensus across 96MB continuous key Regions, TiDB delivers horizontal elastic scalability, zero-downtime auto-rebalancing, and real-time HTAP analytics without impacting write-heavy OLTP workloads. ...

Chapter 5: Full-Stack Observability — Vector, ClickHouse, and Distributed Tracing at Scale

Multi-Language Edition: This chapter is also available in Vietnamese at 📖 Bản tiếng Việt (Vietnamese Edition). Previous Chapter: Chapter 4 — Database Scalability: From MySQL to TiDB | Series Hub Answer-First: Operating thousands of microservices generating billions of daily transactions makes naive logging (Elasticsearch/ELK) financially prohibitive and computationally unsustainable. Shopee adopted a next-generation observability stack: Rust-based Vector edge daemons parsing telemetry with SIMD acceleration, Apache Kafka buffering ingestion bursts, ClickHouse columnar storage compressing petabyte-scale logs by 12x with sparse indexing, OpenTelemetry (OTel) collectors executing tail-based adaptive sampling (retaining 100% of errors and p99 latency anomalies while discarding 99% of normal traces), and eBPF continuous profiling diagnosing production CPU/memory bottlenecks with sub-1% runtime overhead. ...

Shopee Architecture Masterclass: Flash Sale Scaling in Go

Multi-Language Edition: This Masterclass is also published in Vietnamese at 📖 Bản tiếng Việt (Vietnamese Edition). Answer-First: The Shopee Architecture series details how Go microservices, Redis Lua inventory reservation, Apache Kafka peak shaving, TiDB distributed SQL, and OpenTelemetry/ClickHouse observability handle 10M+ QPS and millions of concurrent buyers during 11.11 flash sales without overselling or database connection starvation. Masterclass Overview: The Southeast Asian E-Commerce Engine Shopee is the leading e-commerce platform in Southeast Asia and Taiwan, operating across Singapore, Indonesia, Vietnam, Thailand, Philippines, and Malaysia. During annual shopping festivals (9.9, 11.11, 12.12), platform traffic surges by more than 10x within seconds at midnight, creating catastrophic load spikes that break traditional web architectures. ...