计算机组成 -- IO_WAIT
IO性能
- 硬盘厂商的性能报告:响应时间(Response Time)、数据传输率(Data Transfer Rate)
- HDD硬盘一般用的是SATA 3.0的接口;SSD硬盘通常会用两种接口,一部分用SATA 3.0接口,另一部分用PCI Express接口
- 数据传输率
- SATA 3.0接口的带宽是6Gb/s ≈ 768MB/s
- 日常用的HDD硬盘的数据传输率,一般在200MB/s
- SATA 3.0接口的SSD的数据传输率差不多是500MB/s
- PCI Express接口的SSD,读取时的数据传输率能到2GB/s,写入时的数据传输率也能有1.2GB/s,大致是HDD的10倍
- SATA 3.0接口的带宽是6Gb/s ≈ 768MB/s
- 响应时间
- 程序发起一个硬盘的读取或写入请求,直到请求返回的时间
- SSD的响应时间大致在几十微秒这个级别,HDD的响应时间大致在十几毫秒这个级别,相差几十倍到几百倍
- IOPS
- 每秒读写的次数,相对于响应时间,更关注IOPS这个性能指标
- 在顺序读写和随机读写的情况下,硬盘的性能是完全不同的
- IOPS和DTR才是IO性能的核心指标
- 在实际的应用开发当中,对于数据的访问,更多的是随机读写,而不是顺序读写
- 因此随机读写的IOPS才是IO性能的核心指标
定位IO_WAIT
- IOPS:HDD为100,SSD为20,000
- CPU的主频通常在2GHz以上,即每秒可以做20亿次操作 – 性能瓶颈在IO上
top
1 | top - 12:45:53 up 455 days, 23:33, 0 users, load average: 7.64, 7.20, 6.37 |
iostat
1 | avg-cpu: %user %nice %system %iowait %steal %idle |
- tps – IOPS
- Indicate the number of transfers per second that were issued to the device.
- A transfer is an I/O request to the device.
- Multiple logical requests can be combined into a single I/O request to the device.
- A transfer is of indeterminate size.
- kB_read/s – DTR
- Indicate the amount of data read from the device expressed in a number of blocks (kilobytes, megabytes) per second.
- Blocks are equivalent to sectors and therefore have a size of 512 bytes.
- kB_wrtn/s – DTR
- Indicate the amount of data written to the device expressed in a number of blocks (kilobytes, megabytes) per second.
iotop
1 | Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s |
stress
通过stress命令,来模拟一个高IO负载的场景
1 | -d, --hdd N |
1 | $ stress -d 2 |
top
1 | top - 01:54:07 up 7 min, 3 users, load average: 1.23, 0.35, 0.14 |
iostat
1 | avg-cpu: %user %nice %system %iowait %steal %idle |
iotop
1 | Total DISK READ : 0.00 0.00 BTotal DISK WRITE : 669.38 M/s |
参考资料
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.