MSE Java agent performance overhead

更新时间:
复制 MD 格式

The MSE Microservices Governance Java agent instruments bytecode at runtime to enable governance capabilities such as canary releases and throttling. The following benchmark results measure the agent's impact on CPU, memory, and response time under realistic traffic loads.

Key findings

Under controlled stress testing, the MSE Java agent adds minimal overhead:

LoadCPU overheadMemory overheadResponse time (RT) increase per hop
250 queries per second (QPS) per instance+2.96% avg+0.19 GiB avg+0.2 ms
500 QPS per instance+6.37% avg+0.16 GiB avg+0.2 ms

At 250 QPS, average CPU usage rises from 6.30% to 9.25%. At 500 QPS, it rises from 12.24% to 18.60%. Memory consumption increases by roughly 160--190 MiB per service on average. End-to-end RT increases by less than 1 ms across the full call chain (four hops).

Note

Agent overhead scales with QPS. The percentages above are absolute increases, not multipliers. Actual overhead in your environment depends on hardware, JVM version, application architecture, and traffic patterns.

Test environment

ComponentConfiguration
Stress test toolPerformance Testing Service (PTS)
ClusterContainer Service for Kubernetes (ACK), single cluster
Node instance typeecs.g6.2xlarge
Operating systemAlibaba Cloud Linux 3.2104 LTS 64-bit (container-optimized)
Pod resources2 cores, 4 GB memory, 2 replicas per application
Agent versionAliyun JavaAgent 4.4.0
JVM parameters-Xms3500m -Xmx3500m -XX:MetaspaceSize=500m

All services (the Java application, MySQL, and Redis) run in the same ACK cluster.

Demo code: alibabacloud-microservice-demo (demo-pt branch)

Test architecture

The application uses Spring MVC with a four-service call chain:

Test architecture

Requests target ${gateway}/A/httpTest and ${gateway}/A/dubboTest. To isolate network effects, Redis and MySQL calls are simulated on the client side, though the agent instrumentation logic still runs.

Test procedure

Baseline measurement (no agent)

  1. Run three stress tests at 500 QPS and three at 1,000 QPS without the MSE Java agent installed.

  2. Before each test, warm up the application for 3 minutes at 100 QPS.

  3. Run each test for 20 minutes.

  4. Record CPU usage, memory usage, and RT as baseline metrics.

Agent measurement

  1. Install the MSE Java agent.

  2. Configure governance rules:

    • An end-to-end canary release traffic lane with a 50% traffic ratio.

    • A throttling rule with a 10,000 QPS threshold per interface.

  3. Repeat the same stress tests and warm-up procedure.

  4. Compare CPU, memory, and RT against the baseline.

Detailed results

Agent overhead by service

At 250 QPS per instance:

ServiceCPU overheadMemory overhead
Gateway+3.085%+0.167 GiB
A+4.055%+0.215 GiB
B+3.435%+0.193 GiB
C+1.255%+0.1935 GiB
Average+2.96%+0.192 GiB

At 500 QPS per instance:

ServiceCPU overheadMemory overhead
Gateway+7.11%+0.1655 GiB
A+6.40%+0.202 GiB
B+7.15%+0.1495 GiB
C+4.80%+0.1275 GiB
Average+6.37%+0.161 GiB

RT increase per hop: +0.2 ms at both 250 and 500 QPS.

Baseline metrics (no agent)

At 250 QPS per instance:

ServiceCPUMemoryRT (end-to-end)
Gateway4.25%1.323 GiB109 ms
A8.445%1.383 GiB
B6.15%1.424 GiB
C6.34%1.477 GiB

At 500 QPS per instance:

ServiceCPUMemoryRT (end-to-end)
Gateway7.74%1.354 GiB112 ms
A17.15%1.424 GiB
B12.65%1.4725 GiB
C11.40%1.509 GiB

Metrics with agent enabled

At 250 QPS per instance:

ServiceCPUMemoryRT (end-to-end)
Gateway7.335%1.490 GiB110 ms
A12.50%1.598 GiB
B9.585%1.617 GiB
C7.595%1.6705 GiB

At 500 QPS per instance:

ServiceCPUMemoryRT (end-to-end)
Gateway14.85%1.5195 GiB113 ms
A23.55%1.626 GiB
B19.80%1.622 GiB
C16.20%1.6365 GiB

Factors that affect overhead

Agent overhead varies by environment. The benchmark results above reflect a specific test setup and serve as reference data, not guarantees. Factors that may change your results include:

  • Hardware: CPU architecture, clock speed, available memory

  • Containerization: Resource limits, co-located workloads, node density

  • JVM configuration: JVM vendor and version, garbage collection settings, heap size

  • Application design: Call chain depth, number of instrumented frameworks, span volume

  • Traffic patterns: Request concurrency, payload size, error rate

Measure overhead in your environment

To obtain representative measurements for your own workload:

  1. Prepare the test environment. Use a configuration that resembles production. Isolate the application under test from other services and remove unnecessary system processes on the host.

  2. Warm up the JVM. Run a warm-up phase (for example, 3 minutes at moderate load) before collecting measurements. The JVM performs just-in-time (JIT) compilation and class loading optimizations during startup that can skew early results.

  3. Run multiple iterations. Repeat each test at least three times to account for variance.

  4. Change one variable at a time. Toggle the agent on or off, then compare. Avoid changing multiple factors between test runs.

Capacity planning

When deploying the MSE Java agent, account for the following resource increases per pod:

ResourceAdditional allocation
Memory+200 MiB
CPUApproximately +3% at 250 QPS, +6.4% at 500 QPS (scales with load)

These values are based on the test configuration described above (2-core, 4 GB pods running Aliyun JavaAgent 4.4.0). Adjust for your specific workload and instance size.

Usage notes

  • When a single instance exceeds 10,000 QPS, the agent automatically degrades certain capabilities to maintain stability. This may affect end-to-end canary release functionality. If your production workload reaches this threshold, submit a ticket for guidance.

  • The RT overhead (+0.2 ms per hop) is consistent across both tested QPS levels, indicating that latency impact does not scale significantly with load in this range.