tikv / raft-engine

A persistent storage engine for Multi-Raft log
Apache License 2.0
565 stars 88 forks source link

Add stress test #84

Closed tabokie closed 3 years ago

tabokie commented 3 years ago

Signed-off-by: tabokie xy.tao@outlook.com

Build:

cargo build --release --workspace

Help output:

➜  raft-engine git:(benches) ✗ ./target/debug/stress --help
Engine Stress (stress) 
A stress test tool for Raft Engine

USAGE:
    stress [OPTIONS] --path <path>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --compression-threshold <size>     Compress log batch bigger than this threshold [default: 8KB]
        --compact-count <n>                Compact log entries exceeding this threshold [default: 0]
        --compact-ttl <ttl[ms]>            Compact log entries older than TTL [default: 0]
        --entry-size <size>                Set the average size of log entry [default: 1024]
        --force-compact-factor <factor>    Factor to shrink raft log during force compact [default: 0.5]
        --path <path>                      Set the data path for Raft Engine
        --purge-interval <interval[ms]>    Set the interval to purge obsolete log files [default: 10000]
        --purge-threshold <size>           Purge if log files are greater than this threshold [default: 10GB]
        --read-ops-per-thread <ops>        Set the per-thread OPS for read entry requests [default: 0]
        --read-threads <threads>           Set the thread count for reading logs [default: 0]
        --regions <regions>                Set the region count [default: 1]
        --target-file-size <size>          Target log file size for Raft Engine [default: 128MB]
        --time <time[s]>                   Set the stress test time [default: 60]
        --write-entry-count <count>        Set the average number of written entries of a region in a log batch [default: 4]
        --write-ops-per-thread <ops>       Set the per-thread OPS for writing logs [default: 0]
        --write-region-count <count>       Set the average number of written regions in a log batch [default: 4]
        --write-sync <sync>                Whether to sync write raft logs [default: true]
        --write-threads <write_threads>    Set the thread count for writing logs [default: 1]

Benchmark output:

➜  raft-engine git:(benches) ✗ ./target/debug/stress --path ./tmp --time 10 --regions 10 --write-threads 2 --read-threads 1 --read-ops-per-thread 100
[write summary]
Throughput(qps) = 6469.11
Latency(us) min = 119, avg = 273.03, p50 = 257, p90 = 363, p95 = 406, p99 = 490, p99.9 = 745, max = 2271
Fairness = 96.8%
[read summary]
Throughput(qps) = 98.88
Latency(us) min = 23, avg = 186.19, p50 = 180, p90 = 274, p95 = 288, p99 = 325, p99.9 = 609, max = 609
Fairness = 100.0%