How Upgrading to JDK 17 and ZGC Supercharged Meituan’s Security Services

Meituan’s security team upgraded core services from JDK 8 to JDK 17 with ZGC, achieving up to 30% performance gains, a 10% reduction in machine cost, and improved stability while addressing compatibility and AI SDK requirements.

High Availability Architecture
High Availability Architecture
High Availability Architecture
How Upgrading to JDK 17 and ZGC Supercharged Meituan’s Security Services

JDK 17 Main Features

JDK 17 introduces language enhancements such as local‑variable type inference ( var), sealed classes, record types, switch expressions, text blocks, and new APIs like HttpClient, jpackage, and ProcessHandle. It also adds extensive NIO improvements, module‑system refinements, and better support for AI SDKs that require at least JDK 17.

Performance Optimizations and Bug Fixes

ZGC garbage collector supports TB‑scale memory, pauses under 10 ms, and less than 15% throughput impact.

NIO now supports Unix‑Domain sockets, file‑channel mapping, and zero‑copy.

Java SDK modularization reduces startup memory and improves security.

Java 8 Attach socket bug fixed in JDK 17.

JDK 17+ZGC in Security Domain

Meituan’s security services primarily run on JDK 8; after migrating to JDK 17 with ZGC, CPU busy time dropped from 47.86% to 41.49%, GC pause impact on high‑QPS requests decreased dramatically, and long‑running JVM stability improved.

Case Study 1: Intelligent Decision System

TP9999 latency reduced by 18%–74% (220‑380 ms) and service failure rate fell from a peak of 6000 errors to 349 after the upgrade.

Case Study 2: Content‑Security Core Service

Switching from CMS to ZGC cut GC‑induced request latency, lowered JVM Metaspace usage, and stabilized CPU usage during peak loads.

Upgrade Process

The migration consists of three phases: installation, compatibility resolution, and performance testing.

Compatibility Issues

Modules introduced in JDK 9 restrict reflective access. The following JVM options open required packages:

--add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.io=ALL-UNNAMED \
--add-opens java.base/java.util.concurrent.locks=ALL-UNNAMED \
... (other packages)

Performance Testing

Benchmarks compare JDK 8+CMS (baseline) with JDK 17+ZGC, measuring peak CPU, TP9999 latency, error count, GC time, heap and metaspace usage.

JVM Parameters

-Xmx12g -Xms12g -XX:+UseZGC -XX:ConcGCThreads=3 -XX:ParallelGCThreads=8 \
-XX:ZCollectionInterval=130 -XX:ZAllocationSpikeTolerance=1 \
-XX:+HeapDumpOnOutOfMemoryError -Xlog:safepoint,classhisto*=trace,age*,gc*=info:file=/opt/logs/gc-%t.log:time,tid,tags:filecount=5,filesize=50m

Conclusion

ZGC delivers low‑pause, high‑throughput garbage collection, reducing machine cost and improving performance.

Upgrading to JDK 17 enables use of modern AI SDKs.

Direct migration from JDK 8 to JDK 17 may require extensive compatibility work; a step‑wise upgrade via JDK 11 can ease the transition.

AI models can assist in troubleshooting migration challenges.

Performance comparison chart
Performance comparison chart
JavaPerformanceOptimizationzgcJDK17
High Availability Architecture
Written by

High Availability Architecture

Official account for High Availability Architecture.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.