test-suite/seata-benchmark-cli/README.md
A command-line benchmark tool for stress testing Seata transaction modes.
--branches 0): Pure Seata protocol overhead testing--branches N): Actual distributed transaction executioncd test-suite/seata-benchmark-cli
../../mvnw clean package
The executable JAR will be created at target/seata-benchmark-cli.jar
# AT mode benchmark (empty transaction)
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100 \
--duration 60
# TCC mode benchmark
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode TCC \
--tps 200 \
--threads 20 \
--duration 120
# SAGA mode benchmark (empty transaction)
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode SAGA \
--tps 100 \
--duration 60
# AT mode with real MySQL transactions (via Testcontainers)
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100 \
--duration 60 \
--branches 3
# SAGA mode with state machine engine
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode SAGA \
--tps 100 \
--duration 60 \
--branches 3 \
--rollback-percentage 5
The benchmark CLI supports two primary testing modes:
--threads)--tps 100000) to avoid rate limitingExample:
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--threads 50 \
--tps 100000 \
--duration 60
--tps)--threads 1)Example:
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 500 \
--threads 1 \
--duration 60
Note: Avoid using both fixed TPS and multiple threads simultaneously, as this leads to unclear test semantics. The benchmark will reject such configurations.
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100000 \
--threads 50 \
--duration 300 \
--warmup-duration 30 \
--rollback-percentage 2 \
--branches 3 \
--export-csv results.csv \
--application-id my-benchmark-app \
--tx-service-group my_tx_group
Usage: seata-benchmark [-hV] [--application-id=<applicationId>]
[-d=<duration>] [--export-csv=<exportCsv>]
[-m=<mode>] [-s=<server>] [-t=<targetTps>]
[--threads=<threads>] [--tx-service-group=<txServiceGroup>]
[--warmup-duration=<warmupDuration>]
[--rollback-percentage=<rollbackPercentage>]
[--branches=<branches>]
Options:
-s, --server=<server> Seata Server address (host:port)
-m, --mode=<mode> Transaction mode: AT, TCC, or SAGA
-t, --tps=<targetTps> Target TPS (default: 100)
--threads=<threads> Concurrent threads (default: 10)
-d, --duration=<duration> Duration in seconds (default: 60)
--warmup-duration=<warmupDuration>
Warmup duration in seconds (default: 0)
--rollback-percentage=<rollbackPercentage>
Rollback percentage for fault injection (0-100, default: 2)
--branches=<branches> Number of branch transactions
0 = empty mode (protocol overhead only)
>=1 = real mode (actual execution)
--export-csv=<exportCsv> Export metrics to CSV file
--application-id=<applicationId>
Seata application ID (default: benchmark-app)
--tx-service-group=<txServiceGroup>
Seata tx service group (default: default_tx_group)
-h, --help Show this help message
-V, --version Print version information
The benchmark tool supports YAML configuration files. Configuration priority (highest to lowest):
BENCHMARK_CONFIG_FILEbenchmark.config.filebenchmark.yaml# benchmark.yaml
server: 127.0.0.1:8091
mode: AT
targetTps: 100
threads: 10
duration: 60
warmupDuration: 10
rollbackPercentage: 2
branches: 0
applicationId: benchmark-app
txServiceGroup: default_tx_group
During execution, the tool displays progress every 10 seconds:
Starting benchmark...
[00:10] 1000 txns, 100.2 txns/sec, 99.0% success
[00:20] 2000 txns, 100.1 txns/sec, 99.2% success
[00:30] 3000 txns, 99.8 txns/sec, 99.5% success
...
When the benchmark completes, a final report is displayed:
===================================================
Seata Benchmark Final Report
===================================================
Total Transactions: 6,000
Success Count: 5,940
Failed Count: 60
Success Rate: 99.00%
Average TPS: 100.2
Elapsed Time: 60 seconds
Latency Statistics:
P50: 12 ms
P95: 45 ms
P99: 89 ms
Max: 230 ms
===================================================
Use --export-csv to export metrics:
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100 \
--duration 60 \
--export-csv results.csv
Output format:
Metric,Value
Total Transactions,6000
Success Count,5940
Failed Count,60
Success Rate (%),99.00
Average TPS,100.2
Elapsed Time (s),60
Latency P50 (ms),12
Latency P95 (ms),45
Latency P99 (ms),89
Latency Max (ms),230
Export Timestamp,2025-12-01 10:30:45
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100 \
--duration 60
# Requires Docker for Testcontainers MySQL
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100 \
--duration 60 \
--branches 3
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode SAGA \
--tps 100 \
--duration 60 \
--branches 3 \
--rollback-percentage 5
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode TCC \
--tps 500 \
--threads 50 \
--duration 300
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 200 \
--duration 120 \
--warmup-duration 30
| Mode | Empty Mode (branches=0) | Real Mode (branches>0) |
|---|---|---|
| AT | Pure protocol overhead | MySQL via Testcontainers (account transfer) |
| TCC | Mock implementation | Mock implementation |
| SAGA | Mock simulation | State machine engine with compensation |
For accurate benchmarking of Seata Server capacity, the tool executes empty transactions:
begin() and commit() operations, no SQL executionThis approach:
When --branches is set to a value greater than 0:
AT Mode:
SAGA Mode:
benchmarkSimpleSaga: For 1-2 branchesbenchmarkOrderSaga: For 3+ branches (order/inventory/payment)Use --rollback-percentage to simulate transaction failures:
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode SAGA \
--tps 100 \
--duration 60 \
--branches 3 \
--rollback-percentage 10 # 10% of transactions will trigger rollback/compensation
Use --warmup-duration to exclude JVM warmup period from final statistics:
java -jar seata-benchmark-cli.jar \
--server 127.0.0.1:8091 \
--mode AT \
--tps 100 \
--duration 120 \
--warmup-duration 30 # First 30 seconds excluded from final stats
To prevent OOM on large-scale tests, the tool samples latencies (inspired by Kafka ProducerPerformance):
If you see connection errors:
If TPS is lower than expected:
--threads)--branches 0) to isolate Seata overheadIf real mode fails:
Logs are written to seata-benchmark.log in the current directory.
v1.1 - Enhancement:
v2.0 - Advanced Features:
Licensed under the Apache License, Version 2.0