Please enable Javascript to view the contents

AGFS 文件系统性能测试

 ·  ☕ 3 分钟

1. 安装 wrk

1
apt-get install -y wrk

2. localfs 性能测试

2.1 1KB 小文件测试

  • 写文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
cat > put-1k.lua <<"EOF"
wrk.method = "PUT"
wrk.body = string.rep("a", 1024)
wrk.headers["Content-Type"] = "text/plain"
counter = 0
local WRAP = 500000
request = function()
    counter = counter + 1
    local n = ((counter - 1) % WRAP) + 1
    local filename = "/local/perf-1k/test_" .. n .. ".txt"
    local path = "/api/v1/files?path=" .. filename
    return wrk.format(nil, path)
end
EOF
1
curl -X POST "http://127.0.0.1:8080/api/v1/directories?path=/local/perf-1k"
1
wrk -t4 -c40 -d30s -s put-1k.lua "http://127.0.0.1:8080"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     3.12ms    3.50ms  84.69ms   93.89%
    Req/Sec     3.72k     1.02k    5.72k    73.92%
  443823 requests in 30.01s, 59.68MB read
Requests/sec:  14791.48
Transfer/sec:      1.99MB
  • 读文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cat > get-1k.lua <<"EOF"
wrk.method = "GET"
counter = 0
local WRAP = 10000
request = function()
    counter = counter + 1
    local n = ((counter - 1) % WRAP) + 1
    local filename = "/local/perf-1k/test_" .. n .. ".txt"
    local path = "/api/v1/files?path=" .. filename
    return wrk.format(nil, path)
end
EOF
1
wrk -t4 -c40 -d30s -s get-1k.lua "http://127.0.0.1:8080"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   738.85us    1.30ms  26.79ms   89.12%
    Req/Sec    31.47k     3.02k   43.39k    68.42%
  3756234 requests in 30.01s, 4.00GB read
Requests/sec: 125169.00
Transfer/sec:    136.32MB
  • 列目录
1
wrk -t4 -c40 -d30s "http://127.0.0.1:8080/api/v1/directories?path=/local/perf-1k"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080/api/v1/directories?path=/local/perf-1k
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   925.62ms  106.94ms   1.51s    78.75%
    Req/Sec    13.39      8.78    50.00     80.42%
  1275 requests in 30.04s, 21.39GB read
Requests/sec:     42.44
Transfer/sec:    729.28MB

2.2 4KB 小文件测试

  • 写文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
cat > put-4k.lua <<"EOF"
wrk.method = "PUT"
wrk.body = string.rep("a", 4096)
wrk.headers["Content-Type"] = "text/plain"
counter = 0
local WRAP = 500000
request = function()
    counter = counter + 1
    local n = ((counter - 1) % WRAP) + 1
    local filename = "/local/perf-4k/test_" .. n .. ".txt"
    local path = "/api/v1/files?path=" .. filename
    return wrk.format(nil, path)
end
EOF
1
curl -X POST "http://127.0.0.1:8080/api/v1/directories?path=/local/perf-4k"
1
wrk -t4 -c40 -d30s -s put-4k.lua "http://127.0.0.1:8080"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.91ms    2.01ms  40.08ms   89.01%
    Req/Sec     3.69k   695.58     5.41k    76.67%
  441076 requests in 30.01s, 59.31MB read
Requests/sec:  14698.37
Transfer/sec:      1.98MB
  • 读文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cat > get-4k.lua <<"EOF"
wrk.method = "GET"
counter = 0
local WRAP = 10000
request = function()
    counter = counter + 1
    local n = ((counter - 1) % WRAP) + 1
    local filename = "/local/perf-4k/test_" .. n .. ".txt"
    local path = "/api/v1/files?path=" .. filename
    return wrk.format(nil, path)
end
EOF
1
wrk -t4 -c40 -d30s -s get-4k.lua "http://127.0.0.1:8080"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   636.01us    0.94ms  21.45ms   87.28%
    Req/Sec    23.76k     2.11k   29.46k    70.33%
  2836971 requests in 30.02s, 11.18GB read
Requests/sec:  94511.49
Transfer/sec:    381.53MB
  • 列目录
1
wrk -t4 -c40 -d30s "http://127.0.0.1:8080/api/v1/directories?path=/local/perf-4k"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080/api/v1/directories?path=/local/perf-4k
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   942.52ms  101.78ms   1.39s    76.91%
    Req/Sec    13.16      9.05    70.00     80.40%
  1256 requests in 30.06s, 20.91GB read
Requests/sec:     41.79
Transfer/sec:    712.24MB

2.3 512KB 大文件测试

  • 写文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
cat > put-512k.lua <<"EOF"
wrk.method = "PUT"
wrk.body = string.rep("a", 512 * 1024)
wrk.headers["Content-Type"] = "text/plain"
counter = 0
local WRAP = 500000
request = function()
    counter = counter + 1
    local n = ((counter - 1) % WRAP) + 1
    local filename = "/local/perf-512k/test_" .. n .. ".txt"
    local path = "/api/v1/files?path=" .. filename
    return wrk.format(nil, path)
end
EOF
1
curl -X POST "http://127.0.0.1:8080/api/v1/directories?path=/local/perf-512k"
1
wrk -t4 -c40 -d30s -s put-512k.lua "http://127.0.0.1:8080"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    24.56ms    4.42ms  61.28ms   78.08%
    Req/Sec   402.50     38.55   525.00     68.42%
  48111 requests in 30.02s, 6.56MB read
Requests/sec:   1602.42
Transfer/sec:    223.78KB
  • 读文件
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cat > get-512k.lua <<"EOF"
wrk.method = "GET"
counter = 0
local WRAP = 10000
request = function()
    counter = counter + 1
    local n = ((counter - 1) % WRAP) + 1
    local filename = "/local/perf-512k/test_" .. n .. ".txt"
    local path = "/api/v1/files?path=" .. filename
    return wrk.format(nil, path)
end
EOF
1
wrk -t4 -c40 -d30s -s get-512k.lua "http://127.0.0.1:8080"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.33ms    1.33ms  23.09ms   78.83%
    Req/Sec     3.37k   231.83     3.95k    70.50%
  403535 requests in 30.08s, 197.09GB read
Requests/sec:  13415.50
Transfer/sec:      6.55GB
  • 列目录
1
wrk -t4 -c40 -d30s "http://127.0.0.1:8080/api/v1/directories?path=/local/perf-512k"
1
2
3
4
5
6
7
8
Running 30s test @ http://127.0.0.1:8080/api/v1/directories?path=/local/perf-512k
  4 threads and 40 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    93.34ms   11.21ms 143.77ms   68.84%
    Req/Sec   107.37     13.03   151.00     75.81%
  12837 requests in 30.03s, 23.49GB read
Requests/sec:    427.46
Transfer/sec:    800.87MB

3. 总结

40 并发、4 线程、持续 30 秒测试

  • 1k 小文件测试
插件场景Requests/sec平均延迟传输速率非 2xx 比例
localfs写文件14791.483.12ms1.99MB0%
localfs读文件125169.00738.85us136.32MB0%
localfs列目录42.44925.62ms729.28MB0%
  • 4k 小文件测试
插件场景Requests/sec平均延迟传输速率非 2xx 比例
localfs写文件14698.372.91ms1.98MB0%
localfs读文件94511.49636.01us381.53MB0%
localfs列目录41.79942.52ms712.24MB0%
  • 512KB 大文件测试
插件场景Requests/sec平均延迟传输速率非 2xx 比例
localfs写文件1602.4224.56ms223.78KB0%
localfs读文件13415.502.33ms6.55GB0%
localfs列目录427.4693.34ms800.87MB0%

512KB 下列目录的文件数量少,因此性能更好。

整体来看,localfs 的性能还是不错的。

4. 参考


微信公众号
作者
微信公众号