How Perfect Diary Scaled Its E‑commerce Platform for Double‑11: Backend Lessons
During Double‑11 2022, Perfect Diary built a micro‑service e‑commerce platform in four months, confronting distributed transactions, database overload, cache pressure, and traffic spikes, and then applied cloud‑native optimizations, rate‑limiting, and pressure testing to achieve record‑breaking sales performance.
Background
During Double‑11 2022, Perfect Diary’s e‑commerce platform generated sales in 28 minutes that surpassed the entire 2018 Double‑11 sales, becoming the first domestic brand to top Tmall’s cosmetics list. The team built the platform in four months and faced several technical challenges.
Key Challenges
1. Distributed Transactions
Fast rollout required creating orders that deduct inventory from the product service, leading to the use of distributed transactions to prevent overselling, which introduced performance overhead.
2. Database Pressure
Real‑time statistics queried the business database directly during peak traffic, causing heavy load without caching. The production environment uses PolarDB with cluster architecture and read‑write separation, but read‑only transactions had to be explicitly marked.
@Transactional(readOnly = true)3. Cache Pressure
Some services performed fuzzy key queries in Redis, causing CPU spikes. A bug also omitted the expiration unit when setting a key, leading to malformed entries.
redisTemplate.opsForValue().set(key, value, offset)4. Traffic Surge
During a promotion, front‑end event‑reporting overwhelmed the statistics service, and a 60‑second timeout caused request backlogs and CPU spikes.
Optimization Strategies
Identify slow and high‑frequency SQL from slow‑query logs and optimize them.
Introduce caching where possible and adjust indexes using Alibaba Cloud analysis tools.
Use AHAS for interface and SQL rate limiting, and leverage its CPU/Load protection.
Separate TP and AP workloads to keep analytical queries away from the business database.
Replace Java request handling with OpenResty (NGINX + Lua) and forward events to Kafka for asynchronous processing.
Process Kafka data in HDFS and use Spark for offline analytics.
Shorten backend interface timeouts and isolate API rate limiting.
Iteration and Testing
Because the promotion was imminent, code changes were risky. The team performed pressure testing using Alibaba Cloud PTS, importing JMeter scripts, modeling user paths, and simulating traffic with ECS‑based JMeter clusters. They monitored server load, adjusted memory, and tuned PolarDB performance.
Rate Limiting with AHAS
Integration required upgrading Spring Cloud Alibaba dependencies, adding Sentinel SDK for gateway rate limiting, and fixing compatibility issues with MyBatis‑Plus for SQL limiting. AHAS also provided CPU/Load throttling to protect servers during spikes.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
