tidb写入压测, 查询慢

为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:
【 TiDB 使用环境】
测试tidb功能和性能, centos7.9 千兆网卡 SSD
集群信息如下:




【概述】 场景 + 问题概述

  1. 写入性能进行压测
  2. 写入的对数据进行查询 统计

【背景】 做过哪些操作

【现象】 业务和数据库现象
在高频率写入的场景,大概每秒3K条,查询性能不稳定
写入压测能达到20K条记录,此时读取性能基本不可用

【问题】 当前遇到的问题
高频写入的同时读取不受影响

【业务影响】

【TiDB 版本】

【应用软件及版本】

【附件】 相关日志及配置信息

  • TiUP Cluster Display 信息
  • TiUP CLuster Edit config 信息

监控(https://metricstool.pingcap.com/)

  • TiDB-Overview Grafana监控
  • TiDB Grafana 监控
  • TiKV Grafana 监控
  • PD Grafana 监控
  • 对应模块日志(包含问题前后 1 小时日志)
    profile_2022-04-21_13-37-00.zip (1009.4 KB)

若提问为性能优化、故障排查类问题,请下载脚本运行。终端输出的打印结果,请务必全选并复制粘贴上传。

1 个赞

QPS 4.3K时候的服务器资源监控

1 个赞

100多M的写入,磁盘利用率就快70%了,用的啥ssd,物理机、云盘?

1 个赞

SSD 具体型号不详, 我去看下

1 个赞

全部是物理机

1 个赞

你测下盘的写入速度咋样

1 个赞

测试完了我贴数据, 谢谢

1 个赞

dd 测试, 命令 dd if=/dev/zero bs=1k count=1000000 of=1Gb.file
峰值500多M

1 个赞

image

2 个赞

? 换命令吗

1 个赞

感觉我这个速度 比你那个要稳定些呢

1 个赞

取平均值也有300多M, 不太清楚官方建议的硬盘性能大概是多少, 或者有没有一些TIDB需要的IO优化策略

1 个赞

贴个官方大佬的回复:
IOPS 分为读写两部分,云盘标称的高 IOPS 大都是利用缓存获得提升的读 IOPS;磁盘的性能还包括带宽和 fdatasync,TiKV 在数据写入时需要进行磁盘的 sync 操作,以确保数据已经从缓冲区刷到硬件,再返回给业务侧,具体为 fdatasync 的操作系统调用。
TiKV 磁盘的建议 2GB/s 以上的写带宽,20K 次/s 以上的 fdatasync,在 4KB 高并发 direct 写的测试中 P99.99 低于 3ms;可以使用 fio 新版、或者 pg_test_fsync 工具进行测试。可以加上 -fdatasync=1 选项测一下,例如 大并发每次写4k而且每次 fsync
fio -direct=0 -fdatasync=1 -iodepth=4 -thread=4 -rw=write -ioengine=libaio -bs=4k -filename=./fio_test -size=20G -runtime=60 -group_reporting -name=write_test
fdatasync的性能参考
参考值一:非 NVMe 的 SSD 的 fdatasync/s 约 5~8K/s
参考值二:中早期 NVMe 的 fdatasync/s 约 20~50K/s
参考值三:当前成熟的 PCIE 3 的 NVMe 约 200~500K/s

1 个赞

谢谢, 我去研究研究

1 个赞

[root@localhost tidb]# fio -direct=0 -fdatasync=1 -iodepth=4 -thread=4 -rw=write -ioengine=libaio -bs=4k -filename=./fio_test -size=20G -runtime=60 -group_reporting -name=write_test
write_test: (g=0): rw=write, bs=® 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=4
fio-3.7
Starting 1 thread
write_test: Laying out IO file (1 file / 20480MiB)
Jobs: 1 (f=1): [W(1)][100.0%][r=0KiB/s,w=45.8MiB/s][r=0,w=11.7k IOPS][eta 00m:00s]
write_test: (groupid=0, jobs=1): err= 0: pid=153520: Thu Apr 21 17:25:11 2022
write: IOPS=11.0k, BW=46.7MiB/s (48.0MB/s)(2802MiB/60001msec)
slat (usec): min=3, max=129, avg= 5.13, stdev= 2.97
clat (usec): min=89, max=987, avg=251.62, stdev=21.68
lat (usec): min=93, max=1002, avg=256.88, stdev=22.51
clat percentiles (usec):
| 1.00th=[ 239], 5.00th=[ 241], 10.00th=[ 241], 20.00th=[ 241],
| 30.00th=[ 243], 40.00th=[ 243], 50.00th=[ 245], 60.00th=[ 247],
| 70.00th=[ 249], 80.00th=[ 255], 90.00th=[ 277], 95.00th=[ 285],
| 99.00th=[ 310], 99.50th=[ 383], 99.90th=[ 502], 99.95th=[ 529],
| 99.99th=[ 660]
bw ( KiB/s): min=45245, max=49384, per=100.00%, avg=47830.27, stdev=866.22, samples=119
iops : min=11311, max=12346, avg=11957.52, stdev=216.58, samples=119
lat (usec) : 100=0.01%, 250=72.00%, 500=27.90%, 750=0.10%, 1000=0.01%
fsync/fdatasync/sync_file_range:
sync (nsec): min=47, max=23329, avg=122.47, stdev=250.14
sync percentiles (nsec):
| 1.00th=[ 96], 5.00th=[ 99], 10.00th=[ 100], 20.00th=[ 102],
| 30.00th=[ 103], 40.00th=[ 103], 50.00th=[ 104], 60.00th=[ 104],
| 70.00th=[ 105], 80.00th=[ 110], 90.00th=[ 181], 95.00th=[ 211],
| 99.00th=[ 229], 99.50th=[ 346], 99.90th=[ 450], 99.95th=[ 644],
| 99.99th=[14656]
cpu : usr=3.94%, sys=29.70%, ctx=2152593, majf=0, minf=111
IO depths : 1=0.1%, 2=0.1%, 4=200.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=0,717439,0,0 short=717437,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=4

Run status group 0 (all jobs):
WRITE: bw=46.7MiB/s (48.0MB/s), 46.7MiB/s-46.7MiB/s (48.0MB/s-48.0MB/s), io=2802MiB (2939MB), run=60001-60001msec

Disk stats (read/write):
dm-0: ios=0/1432322, merge=0/0, ticks=0/35400, in_queue=35395, util=59.10%, aggrios=0/1434915, aggrmerge=0/4, aggrticks=0/34045, aggrin_queue=33810, aggrutil=56.34%
sda: ios=0/1434915, merge=0/4, ticks=0/34045, in_queue=33810, util=56.34%
[root@localhost tidb]#

1 个赞

[root@localhost tidb]# fio -direct=0 -fdatasync=1 -iodepth=4 -thread=4 -rw=write -ioengine=libaio -bs=4k -filename=./fio_test -size=20G -runtime=60 -group_reporting -name=write_test
write_test: (g=0): rw=write, bs=® 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=4
fio-3.7
Starting 1 thread
write_test: Laying out IO file (1 file / 20480MiB)
Jobs: 1 (f=1): [W(1)][100.0%][r=0KiB/s,w=47.5MiB/s][r=0,w=12.2k IOPS][eta 00m:00s]
write_test: (groupid=0, jobs=1): err= 0: pid=54004: Thu Apr 21 17:25:11 2022
write: IOPS=12.4k, BW=48.5MiB/s (50.8MB/s)(2907MiB/60001msec)
slat (nsec): min=2674, max=60657, avg=4355.66, stdev=1299.93
clat (usec): min=74, max=939, avg=242.52, stdev=19.52
lat (usec): min=78, max=943, avg=247.00, stdev=19.72
clat percentiles (usec):
| 1.00th=[ 233], 5.00th=[ 235], 10.00th=[ 235], 20.00th=[ 235],
| 30.00th=[ 235], 40.00th=[ 237], 50.00th=[ 237], 60.00th=[ 239],
| 70.00th=[ 241], 80.00th=[ 245], 90.00th=[ 258], 95.00th=[ 269],
| 99.00th=[ 293], 99.50th=[ 363], 99.90th=[ 494], 99.95th=[ 515],
| 99.99th=[ 644]
bw ( KiB/s): min=47640, max=50832, per=99.97%, avg=49601.64, stdev=685.75, samples=119
iops : min=11910, max=12708, avg=12400.36, stdev=171.43, samples=119
lat (usec) : 100=0.01%, 250=86.29%, 500=13.63%, 750=0.07%, 1000=0.01%
fsync/fdatasync/sync_file_range:
sync (nsec): min=42, max=17802, avg=99.63, stdev=60.30
sync percentiles (nsec):
| 1.00th=[ 90], 5.00th=[ 92], 10.00th=[ 94], 20.00th=[ 96],
| 30.00th=[ 96], 40.00th=[ 97], 50.00th=[ 97], 60.00th=[ 97],
| 70.00th=[ 98], 80.00th=[ 98], 90.00th=[ 101], 95.00th=[ 104],
| 99.00th=[ 183], 99.50th=[ 270], 99.90th=[ 358], 99.95th=[ 386],
| 99.99th=[ 474]
cpu : usr=3.69%, sys=29.10%, ctx=2233122, majf=0, minf=6
IO depths : 1=0.1%, 2=0.1%, 4=200.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
issued rwts: total=0,744279,0,0 short=744277,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=4

Run status group 0 (all jobs):
WRITE: bw=48.5MiB/s (50.8MB/s), 48.5MiB/s-48.5MiB/s (50.8MB/s-50.8MB/s), io=2907MiB (3049MB), run=60001-60001msec

Disk stats (read/write):
dm-0: ios=0/1485758, merge=0/0, ticks=0/34651, in_queue=34648, util=57.88%, aggrios=0/1488567, aggrmerge=0/5, aggrticks=0/33095, aggrin_queue=32802, aggrutil=54.68%
sda: ios=0/1488567, merge=0/5, ticks=0/33095, in_queue=32802, util=54.68%
[root@localhost tidb]#

1 个赞

抽取了两台机器的测试结果 fdatasync是这个 sync (nsec): min=47, max=23329, avg=122.47, stdev=250.14 值吗

1 个赞

这些指标我也不太懂:sweat_smile: 只原样贴下文字, 从你的监控上看100多M写入,利用率都快70%,感觉不正常

1 个赞

好的, 谢谢了

1 个赞


我的普通sata盘,12块的raid10,2G缓存 的写入性能


arm机器,普通ssd 3块raid0,1G缓存