#01 1. What a Flash Sale Really Is, and Its Four Fatal Flaws
The defining challenge of a flash sale is extreme, instantaneous read/write skew. In the few seconds after the sale opens, millions of users fire order requests concurrently, all hammering a single database row.
Send that straight at MySQL and, connection pool or not, database CPU pegs at 100% within 50ms, connections are exhausted, and every service on the site cascades into failure.
#02 2. A Seven-Layer Traffic Funnel
We filter and reject in layers:
- Client layer: a greyed-out button with a countdown, debounce control, and staggered CAPTCHA;
- CDN edge nodes: fully cached static pages, blocking 90% of page traffic from ever reaching origin;
- API gateway (Kong / Envoy): IP/token allowlists and denylists plus sliding-window rate limiting;
- Distributed cache (Redis Cluster): atomic Lua deduction, letting only valid requests through;
- Async message queue (RocketMQ): writes to MySQL asynchronously at a steady rate.