Aerospike C 客戶端內建 benchmarks 工具,支援自定義讀寫比例、併發線程、延遲分布統計,是效能基準測試、容量規劃的利器。本文詳細說明編譯、運行參數、實戰範例與結果解讀。
# 1. 安裝開發包依賴 (含 C 客戶端庫、頭文件)
# Ubuntu: apt-get install aerospike-client-c-dev
# CentOS: yum install aerospike-client-c-devel
# 2. 進入源碼目錄編譯
cd /path/to/aerospike-client-c/benchmarks
make
# 3. 執行檔位置
./target/benchmarks
| 參數 | 說明 | 預設值 |
|---|---|---|
| -h, --host | 種子節點主機名/IP | 127.0.0.1 |
| -p, --port | 服務埠 | 3000 |
| -n, --namespace | 命名空間 | test |
| -s, --set | Set 名稱 | testset |
| -k, --keys | 鍵值總數 (基數) | 1000000 |
| -o, --object-spec | Bin 值規範: I(int), S:N(string 長度N), B:N(bytes 長度N) | int 隨機值 |
| -w, --workload | 負載模式: R(讀), W(寫), RU(讀/更新), 比例如 RU,90 90%讀 | R,50 / W,50 |
| -z, --threads | 客戶端併發線程數 | 16 |
| -g, --max-throughput | 最大吞吐限制 (TPS) | 無限制 |
| -L, --latency | 延遲分布統計欄位: 閾值1,閾值2... (如 4,3 表示 ≤1ms, >1ms, >8ms, >64ms) | 關閉 |
| -r, --read-replica | 讀副本策略: master, any, random | master |
| -c, --consistency-level | 讀一致性: one, all | one |
| -C, --commit-level | 寫提交級別: all, master | all |
# 1億鍵值,整數值,90%讀/10%更新,20線程
./target/benchmarks -h 127.0.0.1 -p 3000 -n test -k 100000000 -o I -w RU,90 -z 20
# 100萬鍵,1400字節字符串,80%讀/20%寫,8線程,限流2500 TPS,延遲分布
./target/benchmarks -h 127.0.0.1 -p 3000 -n test -s demoset -k 1000000 -o S:1400 -w RU,80 -z 8 -g 2500 -L 4,3
2014-11-06 11:43:30 INFO write(tps=10847 timeouts=0 errors=0) read(tps=10772 timeouts=0 errors=0) total(tps=21619 timeouts=0 errors=0)
2014-11-06 11:43:31 INFO write(tps=11477 timeouts=0 errors=0) read(tps=11271 timeouts=0 errors=0) total(tps=22748 timeouts=0 errors=0)
(threads, workload, object-size) 組合,繪製效能曲面。./target/benchmarks -u