[转帖]用sysbench压测mysql、postgresql(蟑螂db)对比

sysbench,mysql,postgresql,蟑螂,db,对比 · 浏览次数 : 0

小编点评

归纳总结以上内容,生成内容时需要带简单的排版。 1. **排版标题** 标题应简单明快,便于用户快速找到相关信息。 2. **排版内容** 内容应清晰简洁,并以排版方式排列。 3. **排版字体** 字体应清晰易读,并以排版方式排列。 4. **排版格式** 格式应清晰易读,并以排版方式排列。 5. **排版图片** 图片应清晰易读,并以排版方式排列。 6. **排版格式** 格式应清晰易读,并以排版方式排列。 7. **排版代码** 代码应清晰易读,并以排版方式排列。

正文

mysql:

准备创建表和数据:
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_read_write --db-ps-mode=disable prepare

测试数据库的综合读写TPS,使用的是oltp_read_write模式(大家看命令中最后不是prepare,是run了,就是运行压测):
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_read_write --db-ps-mode=disable run

[ 1s ] thds: 10 tps: 299.82 qps: 6067.15 (r/w/o: 4258.26/1199.29/609.60) lat (ms,95%): 36.89 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 10 tps: 77.04 qps: 1644.77 (r/w/o: 1146.54/344.16/154.07) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 10 tps: 133.00 qps: 2617.95 (r/w/o: 1851.97/499.99/266.00) lat (ms,95%): 219.36 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 10 tps: 94.03 qps: 1842.57 (r/w/o: 1274.39/380.12/188.06) lat (ms,95%): 363.18 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 10 tps: 170.95 qps: 3514.04 (r/w/o: 2456.33/715.81/341.91) lat (ms,95%): 369.77 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 10 tps: 80.02 qps: 1576.31 (r/w/o: 1120.22/296.06/160.03) lat (ms,95%): 376.49 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 10 tps: 136.95 qps: 2738.95 (r/w/o: 1909.27/555.79/273.89) lat (ms,95%): 308.84 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 10 tps: 114.96 qps: 2310.16 (r/w/o: 1608.42/471.83/229.92) lat (ms,95%): 530.08 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 10 tps: 91.03 qps: 1817.58 (r/w/o: 1271.41/364.12/182.06) lat (ms,95%): 200.47 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 10 tps: 142.97 qps: 2873.46 (r/w/o: 2013.62/573.89/285.95) lat (ms,95%): 211.60 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 18928
write: 5408
other: 2704
total: 27040
transactions: 1352 (134.86 per sec.)
queries: 27040 (2697.25 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 10.0217s
total number of events: 1352

Latency (ms):
min: 23.04
avg: 74.04
max: 803.40
95th percentile: 303.33
sum: 100106.79

Threads fairness:
events (avg/stddev): 135.2000/4.33
execution time (avg/stddev): 10.0107/0.01

测试数据库的只读性能,使用的是oltp_read_only模式(大家看命令中的oltp_read_write已经变为oltp_read_only了):
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_read_only --db-ps-mode=disable run

[ 1s ] thds: 10 tps: 895.83 qps: 14420.90 (r/w/o: 12619.29/0.00/1801.62) lat (ms,95%): 14.46 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 10 tps: 841.11 qps: 13436.76 (r/w/o: 11754.54/0.00/1682.22) lat (ms,95%): 17.63 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 10 tps: 875.01 qps: 14035.08 (r/w/o: 12285.07/0.00/1750.01) lat (ms,95%): 14.73 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 10 tps: 874.00 qps: 13997.99 (r/w/o: 12249.99/0.00/1748.00) lat (ms,95%): 12.75 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 10 tps: 890.93 qps: 14247.83 (r/w/o: 12465.97/0.00/1781.85) lat (ms,95%): 12.08 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 10 tps: 859.01 qps: 13736.23 (r/w/o: 12018.20/0.00/1718.03) lat (ms,95%): 15.83 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 10 tps: 673.98 qps: 10796.65 (r/w/o: 9448.69/0.00/1347.96) lat (ms,95%): 23.95 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 10 tps: 799.13 qps: 12775.15 (r/w/o: 11176.88/0.00/1598.27) lat (ms,95%): 12.75 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 10 tps: 932.92 qps: 14911.71 (r/w/o: 13045.87/0.00/1865.84) lat (ms,95%): 11.65 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 10 tps: 844.42 qps: 13532.65 (r/w/o: 11843.82/0.00/1688.83) lat (ms,95%): 11.65 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 119000
write: 0
other: 17000
total: 136000
transactions: 8500 (848.90 per sec.)
queries: 136000 (13582.34 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 10.0098s
total number of events: 8500

Latency (ms):
min: 6.46
avg: 11.76
max: 225.84
95th percentile: 15.00
sum: 99998.45

Threads fairness:
events (avg/stddev): 850.0000/30.34
execution time (avg/stddev): 9.9998/0.00

测试数据库的删除性能,使用的是oltp_delete模式:
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_delete --db-ps-mode=disable run

[ 1s ] thds: 10 tps: 372.54 qps: 372.54 (r/w/o: 0.00/370.55/1.99) lat (ms,95%): 47.47 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 10 tps: 331.17 qps: 331.17 (r/w/o: 0.00/323.17/8.00) lat (ms,95%): 38.25 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 10 tps: 405.98 qps: 405.98 (r/w/o: 0.00/379.98/26.00) lat (ms,95%): 31.94 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 10 tps: 388.00 qps: 388.00 (r/w/o: 0.00/354.00/34.00) lat (ms,95%): 36.24 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 10 tps: 420.98 qps: 420.98 (r/w/o: 0.00/365.98/55.00) lat (ms,95%): 51.94 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 10 tps: 403.03 qps: 403.03 (r/w/o: 0.00/348.02/55.00) lat (ms,95%): 41.10 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 10 tps: 390.96 qps: 390.96 (r/w/o: 0.00/321.97/68.99) lat (ms,95%): 44.98 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 10 tps: 394.05 qps: 394.05 (r/w/o: 0.00/318.04/76.01) lat (ms,95%): 55.82 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 10 tps: 514.96 qps: 514.96 (r/w/o: 0.00/397.97/116.99) lat (ms,95%): 27.66 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 10 tps: 460.99 qps: 460.99 (r/w/o: 0.00/355.99/105.00) lat (ms,95%): 43.39 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 0
write: 3547
other: 547
total: 4094
transactions: 4094 (408.64 per sec.)
queries: 4094 (408.64 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 10.0153s
total number of events: 4094

Latency (ms):
min: 0.23
avg: 24.44
max: 155.87
95th percentile: 42.61
sum: 100069.06

Threads fairness:
events (avg/stddev): 409.4000/8.06
execution time (avg/stddev): 10.0069/0.01

测试数据库的更新索引字段的性能,使用的是oltp_update_index模式:
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_update_index --db-ps-mode=disable run

[ 1s ] thds: 10 tps: 280.27 qps: 280.27 (r/w/o: 0.00/199.48/80.79) lat (ms,95%): 167.44 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 10 tps: 404.66 qps: 404.66 (r/w/o: 0.00/299.75/104.91) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 10 tps: 468.02 qps: 468.02 (r/w/o: 0.00/324.02/144.01) lat (ms,95%): 32.53 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 10 tps: 393.98 qps: 395.98 (r/w/o: 0.00/310.99/85.00) lat (ms,95%): 42.61 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 10 tps: 410.03 qps: 408.03 (r/w/o: 0.00/309.02/99.01) lat (ms,95%): 54.83 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 10 tps: 374.66 qps: 374.66 (r/w/o: 0.00/291.73/82.92) lat (ms,95%): 55.82 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 10 tps: 384.28 qps: 384.28 (r/w/o: 0.00/289.21/95.07) lat (ms,95%): 54.83 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 10 tps: 320.05 qps: 320.05 (r/w/o: 0.00/249.04/71.01) lat (ms,95%): 139.85 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 10 tps: 308.96 qps: 308.96 (r/w/o: 0.00/220.97/87.99) lat (ms,95%): 134.90 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 10 tps: 364.03 qps: 364.03 (r/w/o: 0.00/273.02/91.01) lat (ms,95%): 87.56 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 0
write: 2778
other: 942
total: 3720
transactions: 3720 (365.72 per sec.)
queries: 3720 (365.72 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 10.1683s
total number of events: 3720

Latency (ms):
min: 0.25
avg: 27.02
max: 306.75
95th percentile: 59.99
sum: 100508.20

Threads fairness:
events (avg/stddev): 372.0000/10.76
execution time (avg/stddev): 10.0508/0.04

测试数据库的更新非索引字段的性能,使用的是oltp_update_non_index模式:
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_update_non_index --db-ps-mode=disable run

[ 1s ] thds: 10 tps: 405.47 qps: 405.47 (r/w/o: 0.00/307.84/97.63) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 10 tps: 418.16 qps: 418.16 (r/w/o: 0.00/305.12/113.04) lat (ms,95%): 54.83 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 10 tps: 438.01 qps: 438.01 (r/w/o: 0.00/319.01/119.00) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 10 tps: 465.97 qps: 465.97 (r/w/o: 0.00/358.98/106.99) lat (ms,95%): 28.16 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 10 tps: 512.99 qps: 512.99 (r/w/o: 0.00/373.99/139.00) lat (ms,95%): 37.56 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 10 tps: 521.00 qps: 521.00 (r/w/o: 0.00/363.00/158.00) lat (ms,95%): 31.94 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 10 tps: 517.00 qps: 517.00 (r/w/o: 0.00/390.00/127.00) lat (ms,95%): 28.67 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 10 tps: 543.04 qps: 543.04 (r/w/o: 0.00/382.02/161.01) lat (ms,95%): 28.16 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 10 tps: 535.01 qps: 535.01 (r/w/o: 0.00/404.01/131.00) lat (ms,95%): 27.66 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 10 tps: 510.97 qps: 510.97 (r/w/o: 0.00/382.97/127.99) lat (ms,95%): 35.59 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 0
write: 3598
other: 1281
total: 4879
transactions: 4879 (486.54 per sec.)
queries: 4879 (486.54 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 10.0247s
total number of events: 4879

Latency (ms):
min: 0.24
avg: 20.53
max: 135.30
95th percentile: 35.59
sum: 100174.61

Threads fairness:
events (avg/stddev): 487.9000/12.06
execution time (avg/stddev): 10.0175/0.01

测试数据库的插入性能,使用的是oltp_insert模式:
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_insert --db-ps-mode=disable run

[ 1s ] thds: 10 tps: 361.59 qps: 361.59 (r/w/o: 0.00/361.59/0.00) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 10 tps: 348.18 qps: 348.18 (r/w/o: 0.00/348.18/0.00) lat (ms,95%): 48.34 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 10 tps: 280.33 qps: 280.33 (r/w/o: 0.00/280.33/0.00) lat (ms,95%): 80.03 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 10 tps: 293.65 qps: 293.65 (r/w/o: 0.00/293.65/0.00) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 10 tps: 301.00 qps: 301.00 (r/w/o: 0.00/301.00/0.00) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 10 tps: 353.99 qps: 353.99 (r/w/o: 0.00/353.99/0.00) lat (ms,95%): 40.37 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 10 tps: 356.02 qps: 356.02 (r/w/o: 0.00/356.02/0.00) lat (ms,95%): 38.94 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 10 tps: 371.98 qps: 371.98 (r/w/o: 0.00/371.98/0.00) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 10 tps: 374.03 qps: 374.03 (r/w/o: 0.00/374.03/0.00) lat (ms,95%): 44.17 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 10 tps: 372.86 qps: 372.86 (r/w/o: 0.00/372.86/0.00) lat (ms,95%): 47.47 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 0
write: 3425
other: 0
total: 3425
transactions: 3425 (341.78 per sec.)
queries: 3425 (341.78 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 10.0177s
total number of events: 3425

Latency (ms):
min: 12.48
avg: 29.22
max: 155.54
95th percentile: 44.17
sum: 100065.87

Threads fairness:
events (avg/stddev): 342.5000/1.50
execution time (avg/stddev): 10.0066/0.01

测试数据库的写入性能,使用的是oltp_write_only模式:
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_write_only --db-ps-mode=disable run

[ 1s ] thds: 10 tps: 193.21 qps: 1179.18 (r/w/o: 0.00/625.44/553.74) lat (ms,95%): 59.99 err/s: 0.00 reconn/s: 0.00
[ 2s ] thds: 10 tps: 123.07 qps: 746.44 (r/w/o: 0.00/401.24/345.20) lat (ms,95%): 331.91 err/s: 0.00 reconn/s: 0.00
[ 3s ] thds: 10 tps: 186.01 qps: 1112.07 (r/w/o: 0.00/602.04/510.03) lat (ms,95%): 337.94 err/s: 0.00 reconn/s: 0.00
[ 4s ] thds: 10 tps: 90.99 qps: 571.96 (r/w/o: 0.00/314.98/256.98) lat (ms,95%): 320.17 err/s: 0.00 reconn/s: 0.00
[ 5s ] thds: 10 tps: 71.00 qps: 417.99 (r/w/o: 0.00/229.99/188.00) lat (ms,95%): 303.33 err/s: 0.00 reconn/s: 0.00
[ 6s ] thds: 10 tps: 133.00 qps: 775.00 (r/w/o: 0.00/418.00/357.00) lat (ms,95%): 320.17 err/s: 0.00 reconn/s: 0.00
[ 7s ] thds: 10 tps: 68.00 qps: 398.99 (r/w/o: 0.00/209.99/188.99) lat (ms,95%): 369.77 err/s: 0.00 reconn/s: 0.00
[ 8s ] thds: 10 tps: 60.00 qps: 399.02 (r/w/o: 0.00/221.01/178.01) lat (ms,95%): 248.83 err/s: 0.00 reconn/s: 0.00
[ 9s ] thds: 10 tps: 72.00 qps: 405.00 (r/w/o: 0.00/227.00/178.00) lat (ms,95%): 272.27 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 10 tps: 71.99 qps: 419.97 (r/w/o: 0.00/225.98/193.99) lat (ms,95%): 253.35 err/s: 0.00 reconn/s: 0.00
SQL statistics:
queries performed:
read: 0
write: 3512
other: 2968
total: 6480
transactions: 1080 (107.32 per sec.)
queries: 6480 (643.94 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)

General statistics:
total time: 10.0596s
total number of events: 1080

Latency (ms):
min: 20.35
avg: 93.08
max: 642.52
95th percentile: 303.33
sum: 100524.40

Threads fairness:
events (avg/stddev): 108.0000/1.26
execution time (avg/stddev): 10.0524/0.01

使用上面的命令,sysbench工具会根据你的指令构造出各种各样的SQL语句去更新或者查询你的10张测试表里的数据,同时监测出你的数据库的压测性能指标,最后完成压测之后,可以执行下面的cleanup命令,清理数据。
sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --mysql-password=zl123 --mysql-db=test_db --tables=10 --table_size=100000 oltp_read_write --db-ps-mode=disable cleanup

    postgresql

    准备创建表和数据:
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_read_write --db-ps-mode=disable prepare
    

    测试数据库的综合读写TPS,使用的是oltp_read_write模式(大家看命令中最后不是prepare,是run了,就是运行压测):
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_read_write --db-ps-mode=disable run

    [ 1s ] thds: 10 tps: 32.87 qps: 846.52 (r/w/o: 599.54/42.82/204.16) lat (ms,95%): 520.62 err/s: 0.00 reconn/s: 0.00
    [ 2s ] thds: 10 tps: 68.05 qps: 1330.92 (r/w/o: 933.64/67.05/330.23) lat (ms,95%): 337.94 err/s: 0.00 reconn/s: 0.00
    [ 3s ] thds: 10 tps: 60.00 qps: 1217.95 (r/w/o: 854.96/64.00/298.99) lat (ms,95%): 303.33 err/s: 0.00 reconn/s: 0.00
    [ 4s ] thds: 10 tps: 58.00 qps: 1154.01 (r/w/o: 806.01/58.00/290.00) lat (ms,95%): 308.84 err/s: 0.00 reconn/s: 0.00
    [ 5s ] thds: 10 tps: 58.00 qps: 1125.04 (r/w/o: 793.03/57.00/275.01) lat (ms,95%): 320.17 err/s: 0.00 reconn/s: 0.00
    [ 6s ] thds: 10 tps: 56.00 qps: 1148.96 (r/w/o: 802.97/61.00/284.99) lat (ms,95%): 277.21 err/s: 0.00 reconn/s: 0.00
    [ 7s ] thds: 10 tps: 55.00 qps: 1073.07 (r/w/o: 749.05/56.00/268.02) lat (ms,95%): 314.45 err/s: 0.00 reconn/s: 0.00
    [ 8s ] thds: 10 tps: 59.99 qps: 1218.90 (r/w/o: 852.93/65.99/299.97) lat (ms,95%): 267.41 err/s: 0.00 reconn/s: 0.00
    [ 9s ] thds: 10 tps: 52.00 qps: 994.10 (r/w/o: 689.07/52.00/253.02) lat (ms,95%): 356.70 err/s: 0.00 reconn/s: 0.00
    [ 10s ] thds: 10 tps: 46.00 qps: 978.96 (r/w/o: 689.97/51.00/237.99) lat (ms,95%): 314.45 err/s: 0.00 reconn/s: 0.00
    SQL statistics:
    queries performed:
    read: 7784
    write: 577
    other: 2759
    total: 11120
    transactions: 556 (54.68 per sec.)
    queries: 11120 (1093.60 per sec.)
    ignored errors: 0 (0.00 per sec.)
    reconnects: 0 (0.00 per sec.)

    General statistics:
    total time: 10.1650s
    total number of events: 556

    Latency (ms):
    min: 52.05
    avg: 181.17
    max: 649.33
    95th percentile: 350.33
    sum: 100732.27

    Threads fairness:
    events (avg/stddev): 55.6000/3.61
    execution time (avg/stddev): 10.0732/0.04

    测试数据库的只读性能,使用的是oltp_read_only模式(大家看命令中的oltp_read_write已经变为oltp_read_only了):
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_read_only --db-ps-mode=disable run

    [ 1s ] thds: 10 tps: 421.29 qps: 6808.33 (r/w/o: 5956.79/0.00/851.54) lat (ms,95%): 36.89 err/s: 0.00 reconn/s: 0.00
    [ 2s ] thds: 10 tps: 433.25 qps: 6943.07 (r/w/o: 6075.56/0.00/867.51) lat (ms,95%): 41.10 err/s: 0.00 reconn/s: 0.00
    [ 3s ] thds: 10 tps: 424.02 qps: 6775.39 (r/w/o: 5927.35/0.00/848.05) lat (ms,95%): 39.65 err/s: 0.00 reconn/s: 0.00
    [ 4s ] thds: 10 tps: 423.99 qps: 6796.91 (r/w/o: 5948.92/0.00/847.99) lat (ms,95%): 36.24 err/s: 0.00 reconn/s: 0.00
    [ 5s ] thds: 10 tps: 386.99 qps: 6208.84 (r/w/o: 5434.86/0.00/773.98) lat (ms,95%): 56.84 err/s: 0.00 reconn/s: 0.00
    [ 6s ] thds: 10 tps: 431.01 qps: 6845.24 (r/w/o: 5983.21/0.00/862.03) lat (ms,95%): 38.25 err/s: 0.00 reconn/s: 0.00
    [ 7s ] thds: 10 tps: 429.00 qps: 6883.99 (r/w/o: 6025.99/0.00/858.00) lat (ms,95%): 43.39 err/s: 0.00 reconn/s: 0.00
    [ 8s ] thds: 10 tps: 418.03 qps: 6723.42 (r/w/o: 5887.37/0.00/836.05) lat (ms,95%): 37.56 err/s: 0.00 reconn/s: 0.00
    [ 9s ] thds: 10 tps: 414.97 qps: 6597.56 (r/w/o: 5768.61/0.00/828.94) lat (ms,95%): 40.37 err/s: 0.00 reconn/s: 0.00
    [ 10s ] thds: 10 tps: 415.97 qps: 6691.58 (r/w/o: 5858.63/0.00/832.95) lat (ms,95%): 38.94 err/s: 0.00 reconn/s: 0.00
    SQL statistics:
    queries performed:
    read: 58940
    write: 0
    other: 8420
    total: 67360
    transactions: 4210 (420.24 per sec.)
    queries: 67360 (6723.79 per sec.)
    ignored errors: 0 (0.00 per sec.)
    reconnects: 0 (0.00 per sec.)

    General statistics:
    total time: 10.0149s
    total number of events: 4210

    Latency (ms):
    min: 11.49
    avg: 23.76
    max: 121.67
    95th percentile: 39.65
    sum: 100048.03

    Threads fairness:
    events (avg/stddev): 421.0000/164.27
    execution time (avg/stddev): 10.0048/0.00

    测试数据库的删除性能,使用的是oltp_delete模式:
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_delete --db-ps-mode=disable run

    [ 1s ] thds: 10 tps: 2551.45 qps: 2551.45 (r/w/o: 0.00/102.62/2448.83) lat (ms,95%): 3.96 err/s: 0.00 reconn/s: 0.00
    [ 2s ] thds: 10 tps: 3692.43 qps: 3692.43 (r/w/o: 0.00/97.01/3595.42) lat (ms,95%): 2.76 err/s: 0.00 reconn/s: 0.00
    [ 3s ] thds: 10 tps: 3020.72 qps: 3020.72 (r/w/o: 0.00/49.98/2970.75) lat (ms,95%): 2.71 err/s: 0.00 reconn/s: 0.00
    [ 4s ] thds: 10 tps: 5410.74 qps: 5410.74 (r/w/o: 0.00/61.01/5349.73) lat (ms,95%): 2.61 err/s: 0.00 reconn/s: 0.00
    [ 5s ] thds: 10 tps: 5892.01 qps: 5892.01 (r/w/o: 0.00/48.01/5844.01) lat (ms,95%): 2.39 err/s: 0.00 reconn/s: 0.00
    [ 6s ] thds: 10 tps: 6763.40 qps: 6764.40 (r/w/o: 0.00/25.01/6739.40) lat (ms,95%): 2.30 err/s: 0.00 reconn/s: 0.00
    [ 7s ] thds: 10 tps: 7200.51 qps: 7199.51 (r/w/o: 0.00/13.00/7186.51) lat (ms,95%): 2.14 err/s: 0.00 reconn/s: 0.00
    [ 8s ] thds: 10 tps: 7198.59 qps: 7198.59 (r/w/o: 0.00/9.00/7189.59) lat (ms,95%): 2.18 err/s: 0.00 reconn/s: 0.00
    [ 9s ] thds: 10 tps: 6996.44 qps: 6996.44 (r/w/o: 0.00/4.00/6992.44) lat (ms,95%): 2.26 err/s: 0.00 reconn/s: 0.00
    SQL statistics:
    queries performed:
    read: 0
    write: 413
    other: 54132
    total: 54545
    transactions: 54545 (5445.34 per sec.)
    queries: 54545 (5445.34 per sec.)
    ignored errors: 0 (0.00 per sec.)
    reconnects: 0 (0.00 per sec.)

    General statistics:
    total time: 10.0136s
    total number of events: 54545

    Latency (ms):
    min: 0.53
    avg: 1.83
    max: 458.24
    95th percentile: 2.43
    sum: 99901.51

    Threads fairness:
    events (avg/stddev): 5454.5000/1827.26
    execution time (avg/stddev): 9.9902/0.00

    测试数据库的更新索引字段的性能,使用的是oltp_update_index模式:
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_update_index --db-ps-mode=disable run

    [ 1s ] thds: 10 tps: 5898.50 qps: 5898.50 (r/w/o: 0.00/0.00/5898.50) lat (ms,95%): 2.71 err/s: 0.00 reconn/s: 0.00
    [ 2s ] thds: 10 tps: 6078.31 qps: 6078.31 (r/w/o: 0.00/3.00/6075.31) lat (ms,95%): 2.66 err/s: 0.00 reconn/s: 0.00
    [ 3s ] thds: 10 tps: 5479.35 qps: 5479.35 (r/w/o: 0.00/0.00/5479.35) lat (ms,95%): 3.19 err/s: 0.00 reconn/s: 0.00
    [ 4s ] thds: 10 tps: 5346.23 qps: 5346.23 (r/w/o: 0.00/1.00/5345.23) lat (ms,95%): 2.91 err/s: 0.00 reconn/s: 0.00
    [ 5s ] thds: 10 tps: 6091.90 qps: 6091.90 (r/w/o: 0.00/2.00/6089.90) lat (ms,95%): 2.66 err/s: 0.00 reconn/s: 0.00
    [ 6s ] thds: 10 tps: 6198.05 qps: 6198.05 (r/w/o: 0.00/1.00/6197.05) lat (ms,95%): 2.57 err/s: 0.00 reconn/s: 0.00
    [ 7s ] thds: 10 tps: 6057.98 qps: 6057.98 (r/w/o: 0.00/1.00/6056.98) lat (ms,95%): 2.57 err/s: 0.00 reconn/s: 0.00
    [ 8s ] thds: 10 tps: 5775.32 qps: 5775.32 (r/w/o: 0.00/0.00/5775.32) lat (ms,95%): 2.81 err/s: 0.00 reconn/s: 0.00
    [ 9s ] thds: 10 tps: 5952.42 qps: 5952.42 (r/w/o: 0.00/1.00/5951.42) lat (ms,95%): 2.71 err/s: 0.00 reconn/s: 0.00
    SQL statistics:
    queries performed:
    read: 0
    write: 10
    other: 59176
    total: 59186
    transactions: 59186 (5914.42 per sec.)
    queries: 59186 (5914.42 per sec.)
    ignored errors: 0 (0.00 per sec.)
    reconnects: 0 (0.00 per sec.)

    General statistics:
    total time: 10.0038s
    total number of events: 59186

    Latency (ms):
    min: 0.58
    avg: 1.69
    max: 264.44
    95th percentile: 2.76
    sum: 99894.93

    Threads fairness:
    events (avg/stddev): 5918.6000/2315.90
    execution time (avg/stddev): 9.9895/0.00

    测试数据库的更新非索引字段的性能,使用的是oltp_update_non_index模式:
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_update_non_index --db-ps-mode=disable run

    [ 1s ] thds: 10 tps: 5641.54 qps: 5641.54 (r/w/o: 0.00/1.00/5640.54) lat (ms,95%): 2.81 err/s: 0.00 reconn/s: 0.00
    [ 2s ] thds: 10 tps: 6127.50 qps: 6127.50 (r/w/o: 0.00/0.00/6127.50) lat (ms,95%): 2.52 err/s: 0.00 reconn/s: 0.00
    [ 3s ] thds: 10 tps: 5962.63 qps: 5962.63 (r/w/o: 0.00/1.00/5961.63) lat (ms,95%): 2.61 err/s: 0.00 reconn/s: 0.00
    [ 4s ] thds: 10 tps: 6214.06 qps: 6214.06 (r/w/o: 0.00/2.00/6212.06) lat (ms,95%): 2.43 err/s: 0.00 reconn/s: 0.00
    [ 5s ] thds: 10 tps: 6029.11 qps: 6029.11 (r/w/o: 0.00/0.00/6029.11) lat (ms,95%): 2.61 err/s: 0.00 reconn/s: 0.00
    [ 6s ] thds: 10 tps: 5134.52 qps: 5134.52 (r/w/o: 0.00/1.00/5133.52) lat (ms,95%): 3.49 err/s: 0.00 reconn/s: 0.00
    [ 7s ] thds: 10 tps: 5864.00 qps: 5864.00 (r/w/o: 0.00/2.00/5862.00) lat (ms,95%): 2.86 err/s: 0.00 reconn/s: 0.00
    [ 8s ] thds: 10 tps: 6365.48 qps: 6365.48 (r/w/o: 0.00/1.00/6364.48) lat (ms,95%): 2.52 err/s: 0.00 reconn/s: 0.00
    [ 9s ] thds: 10 tps: 6117.92 qps: 6117.92 (r/w/o: 0.00/1.00/6116.92) lat (ms,95%): 2.61 err/s: 0.00 reconn/s: 0.00
    [ 10s ] thds: 10 tps: 5900.24 qps: 5900.24 (r/w/o: 0.00/0.00/5900.24) lat (ms,95%): 2.91 err/s: 0.00 reconn/s: 0.00
    SQL statistics:
    queries performed:
    read: 0
    write: 9
    other: 59370
    total: 59379
    transactions: 59379 (5934.05 per sec.)
    queries: 59379 (5934.05 per sec.)
    ignored errors: 0 (0.00 per sec.)
    reconnects: 0 (0.00 per sec.)

    General statistics:
    total time: 10.0029s
    total number of events: 59379

    Latency (ms):
    min: 0.71
    avg: 1.68
    max: 73.50
    95th percentile: 2.71
    sum: 99891.09

    Threads fairness:
    events (avg/stddev): 5937.9000/2185.96
    execution time (avg/stddev): 9.9891/0.00

    测试数据库的插入性能,使用的是oltp_insert模式:
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_insert --db-ps-mode=disable run

    [ 1s ] thds: 10 tps: 144.42 qps: 144.42 (r/w/o: 0.00/144.42/0.00) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
    [ 2s ] thds: 10 tps: 155.07 qps: 155.07 (r/w/o: 0.00/155.07/0.00) lat (ms,95%): 123.28 err/s: 0.00 reconn/s: 0.00
    [ 3s ] thds: 10 tps: 164.03 qps: 164.03 (r/w/o: 0.00/164.03/0.00) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
    [ 4s ] thds: 10 tps: 142.01 qps: 142.01 (r/w/o: 0.00/142.01/0.00) lat (ms,95%): 130.13 err/s: 0.00 reconn/s: 0.00
    [ 5s ] thds: 10 tps: 107.98 qps: 107.98 (r/w/o: 0.00/107.98/0.00) lat (ms,95%): 139.85 err/s: 0.00 reconn/s: 0.00
    [ 6s ] thds: 10 tps: 18.00 qps: 18.00 (r/w/o: 0.00/18.00/0.00) lat (ms,95%): 1235.62 err/s: 0.00 reconn/s: 0.00
    [ 7s ] thds: 10 tps: 130.00 qps: 130.00 (r/w/o: 0.00/130.00/0.00) lat (ms,95%): 219.36 err/s: 0.00 reconn/s: 0.00
    [ 8s ] thds: 10 tps: 162.98 qps: 162.98 (r/w/o: 0.00/162.98/0.00) lat (ms,95%): 125.52 err/s: 0.00 reconn/s: 0.00
    [ 9s ] thds: 10 tps: 72.01 qps: 72.01 (r/w/o: 0.00/72.01/0.00) lat (ms,95%): 434.83 err/s: 0.00 reconn/s: 0.00
    [ 10s ] thds: 10 tps: 138.00 qps: 138.00 (r/w/o: 0.00/138.00/0.00) lat (ms,95%): 132.49 err/s: 0.00 reconn/s: 0.00
    SQL statistics:
    queries performed:
    read: 0
    write: 1245
    other: 0
    total: 1245
    transactions: 1245 (124.14 per sec.)
    queries: 1245 (124.14 per sec.)
    ignored errors: 0 (0.00 per sec.)
    reconnects: 0 (0.00 per sec.)

    General statistics:
    total time: 10.0266s
    total number of events: 1245

    Latency (ms):
    min: 18.32
    avg: 80.49
    max: 1254.66
    95th percentile: 150.29
    sum: 100207.40

    Threads fairness:
    events (avg/stddev): 124.5000/5.37
    execution time (avg/stddev): 10.0207/0.01

    测试数据库的写入性能,使用的是oltp_write_only模式:
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_write_only --db-ps-mode=disable run

    [ 1s ] thds: 10 tps: 61.75 qps: 425.27 (r/w/o: 0.00/73.70/351.57) lat (ms,95%): 262.64 err/s: 1.00 reconn/s: 0.00
    [ 2s ] thds: 10 tps: 71.05 qps: 426.29 (r/w/o: 0.00/71.05/355.24) lat (ms,95%): 257.95 err/s: 0.00 reconn/s: 0.00
    [ 3s ] thds: 10 tps: 69.00 qps: 413.00 (r/w/o: 0.00/71.00/342.00) lat (ms,95%): 344.08 err/s: 0.00 reconn/s: 0.00
    [ 4s ] thds: 10 tps: 82.99 qps: 498.95 (r/w/o: 0.00/87.99/410.96) lat (ms,95%): 204.11 err/s: 0.00 reconn/s: 0.00
    [ 5s ] thds: 10 tps: 78.01 qps: 467.04 (r/w/o: 0.00/83.01/384.03) lat (ms,95%): 240.02 err/s: 0.00 reconn/s: 0.00
    [ 6s ] thds: 10 tps: 79.00 qps: 475.01 (r/w/o: 0.00/89.00/386.01) lat (ms,95%): 183.21 err/s: 0.00 reconn/s: 0.00
    [ 7s ] thds: 10 tps: 78.97 qps: 472.84 (r/w/o: 0.00/90.97/381.87) lat (ms,95%): 211.60 err/s: 0.00 reconn/s: 0.00
    [ 8s ] thds: 10 tps: 78.02 qps: 468.15 (r/w/o: 0.00/83.03/385.12) lat (ms,95%): 248.83 err/s: 0.00 reconn/s: 0.00
    [ 9s ] thds: 10 tps: 56.00 qps: 335.98 (r/w/o: 0.00/66.00/269.99) lat (ms,95%): 411.96 err/s: 0.00 reconn/s: 0.00
    [ 10s ] thds: 10 tps: 74.00 qps: 442.98 (r/w/o: 0.00/86.00/356.99) lat (ms,95%): 215.44 err/s: 0.00 reconn/s: 0.00
    SQL statistics:
    queries performed:
    read: 0
    write: 803
    other: 3636
    total: 4439
    transactions: 739 (72.85 per sec.)
    queries: 4439 (437.61 per sec.)
    ignored errors: 1 (0.10 per sec.)
    reconnects: 0 (0.00 per sec.)

    General statistics:
    total time: 10.1405s
    total number of events: 739

    Latency (ms):
    min: 40.34
    avg: 136.27
    max: 592.86
    95th percentile: 267.41
    sum: 100703.81

    Threads fairness:
    events (avg/stddev): 73.9000/3.18
    execution time (avg/stddev): 10.0704/0.04

    使用上面的命令,sysbench工具会根据你的指令构造出各种各样的SQL语句去更新或者查询你的20张测试表里的数据,同时监测出你的数据库的压测性能指标,最后完成压测之后,可以执行下面的cleanup命令,清理数据。
    sysbench --db-driver=pgsql --time=10 --threads=10 --report-interval=1 --pgsql-host=172.18.44.120 --pgsql-port=26259 --pgsql-user=root --pgsql-password= --pgsql-db=test_db --tables=10 --table_size=100000 oltp_read_write --db-ps-mode=disable cleanup

      文章知识点与官方知识档案匹配,可进一步学习相关知识
      PostgreSQL技能树首页概览5025 人正在系统学习中

      与[转帖]用sysbench压测mysql、postgresql(蟑螂db)对比相似的内容:

      [转帖]用sysbench压测mysql、postgresql(蟑螂db)对比

      mysql: 准备创建表和数据: sysbench --db-driver=mysql --time=10 --threads=10 --report-interval=1 --mysql-host=172.18.44.84 --mysql-port=7999 --mysql-user=zl --m

      [转帖]用sysbench进行数据库OLTP基准测试

      https://www.cnblogs.com/ariesblog/p/13847740.html 基于TPC-C的OLTP基准测试,对比Mysql和PostgreSQL的性能 一、什么是TPC-C和tpmC 1、TPC-C TPC-C是一种旨在衡量联机事务处理(OLTP)系统性能与可伸缩性的行业标

      [转帖]tidb-系统内核调优及对比

      一、背景 验证系统调优对性能的影响,用sysbench做了一些简单的测试,具体调整方法可见官方文档 二、特殊说明 1.透明大页查看 # 查看透明大页是否开启,[]在always处表示开启,[]在never处表示关闭 cat /sys/kernel/mm/transparent_hugepage/en

      [转帖]用了这18种方案,接口性能提高了100倍!

      https://juejin.cn/post/7167153109158854687 前言 大家好,我是捡田螺的小男孩。 之前工作中,遇到一个504超时问题。原因是因为接口耗时过长,超过nginx配置的10秒。然后 真枪实弹搞了一次接口性能优化,最后接口从11.3s降为170ms。本文将跟小伙伴们分

      [转帖]用bat更改hosts文件批处理

      原文地址: https://www.jb51.net/article/51902.htm copy@echo off echo "请注意你的杀毒软件提示,一定要允许" @echo ######################################## @xcopy C:\Windows\s

      [转帖]用buildkit和containerd构建镜像

      https://zhuanlan.zhihu.com/p/366671300 最近因为K8s抛弃Docker了,所以就只装了个containerd,这样就需要一个单独的镜像构建工具了,就用了buildkit,这也是Docker公司扶持的,他们公司的人出来搞的开源工具,官网在 https://gith

      [转帖]用buildkit和containerd构建镜像

      https://zhuanlan.zhihu.com/p/366671300 最近因为K8s抛弃Docker了,所以就只装了个containerd,这样就需要一个单独的镜像构建工具了,就用了buildkit,这也是Docker公司扶持的,他们公司的人出来搞的开源工具,官网在 https://gith

      [转帖]用实力诠释细节!“Java性能调优六大工具”之JDK命令行工具

      https://www.zhihu.com/people/javajia-gou-ji-zhu-44/posts JDK命令行工具 在JDK的开发包中,除了大家熟知的java.exe和javac.exe外,还有一系列辅助工具。这些辅助工具位于JDK安装目录下的bin目录中,可以帮助开发人员很好地解决

      【转帖】用pycharm开发django项目示例

      https://www.cnblogs.com/kylinlin/p/5184592.html pycharm开发django工程(一) 在pycharm(企业版)中新建Django工程,注意使用虚拟环境 创建成功后,在pycharm显示的工程目录结构如下: 打开pycharm的Terminal,进

      [转帖]如何用Perf解开服务器消耗的困境

      https://rdc.hundsun.com/portal/article/637.html 无论是网站还是软件产品,服务器作为资源池,其重要性不言而喻。监控并了解服务器资源的消耗情况更是能将众多问题防范于未然,也许,一般的监控对于业内人基本不是问题,那让我们聊聊秘密武器Perf,你也许会有恍然大