Comprehensive Performance Optimization Strategies and Real-World Cases
The article presents a comprehensive set of performance‑optimization strategies—from code‑level refactoring, SQL tuning, and caching patterns to asynchronous processing, NoSQL selection, JVM and multithreading tuning—alongside real‑world cases that cut job runtimes from over 50 minutes to under 15 minutes and dramatically reduce database load.
This article summarizes a collection of practical performance‑optimization techniques and case studies gathered from internal sharing within Meituan‑Dianping’s technical team.
1. Code‑level Optimizations – Emphasizes that the first step is to analyze the actual code to locate bottlenecks (e.g., excessive loops, redundant condition checks). Simple code fixes can often resolve performance issues.
2. Database Optimizations – Covers three layers: SQL tuning (using MySQL slow‑query logs, EXPLAIN, profiling), architectural tuning (read/write splitting, sharding, load balancing) and connection‑pool tuning (adjusting pool parameters based on monitoring data).
3. Caching Strategies – Discusses local cache vs. cache services, usage scenarios, selection criteria, design points (update reliability, cache‑full handling, data loss tolerance, cache‑penetration protection). A concrete mutex‑based solution for cache‑stampede is provided:
public String get(key) {
String value = redis.get(key);
if (value == null) { // cache expired
// set a 3‑minute lock to avoid repeated DB loads
if (redis.setnx(key_mutex, 1, 3 * 60) == 1) { // lock acquired
value = db.get(key);
redis.set(key, value, expire_secs);
redis.del(key_mutex);
} else { // another thread already refreshed the cache
sleep(50);
get(key); // retry
}
} else {
return value;
}
}4. Asynchronous Processing – Highlights scenarios where background work can be off‑loaded to separate threads, thread pools, blocking queues, or message‑queue middleware (MQ) to reduce request latency and avoid thread‑pool exhaustion.
5. NoSQL vs. Cache – Clarifies that NoSQL is used as a primary data store (e.g., HBase) when relational features are unnecessary, and outlines when to choose NoSQL over traditional databases.
6. JVM Tuning – Provides guidance on when to tune (based on GC time, CPU load, thread count) and how to adjust young‑generation size, GC algorithms, and detect memory leaks using tools like jmap and MAT.
7. Multithreading & Distributed Execution – Advises using single‑machine multithreading when sufficient, otherwise adopting a distributed scheduler + workers model, with attention to RPC, heartbeats, and thread‑pool configuration.
8. Metrics & Monitoring System – Describes the key workflow (define metrics, collect data, compute/store, visualize) and the essential indicators for interface performance and node health.
Real‑World Cases
Case 1 – A hourly job that refreshes merchant‑zone relationships. Optimizations included replacing naïve loops with an R‑tree spatial index and caching merchant data via mget, reducing runtime from >50 min to <15 min.
Case 2 – POI cache design using Tair, later enhanced with LinkedIn’s Databus to achieve near‑real‑time consistency without expiration, dramatically cutting DB read traffic.
Case 3 – Performance tuning of several backend admin pages (welcome, organization chart, order‑building). Solutions involved batch RPC calls, pre‑computed results cached in Redis, SQL consolidation, and month‑partitioned secondary indexes, yielding noticeable latency reductions.
The article also mentions additional optimization areas such as front‑end, distributed file systems, CDN, full‑text and spatial indexes, which will be covered in future posts.
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.
Meituan Technology Team
Over 10,000 engineers powering China’s leading lifestyle services e‑commerce platform. Supporting hundreds of millions of consumers, millions of merchants across 2,000+ industries. This is the public channel for the tech teams behind Meituan, Dianping, Meituan Waimai, Meituan Select, and related services.
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.
