大网数据广告活动
服务器运维问答

How do I know if SSD is the bottleneck in Linux?

· 52CE 我爱测

I have a database server which uses a Samsung 840 pro disk. The load is constantly higher than usual, even if there is not much activity on the website. So I suspect the disk has worn out. But how can I check that the disk i/o is…

问题原文

原帖链接 · Milkyway · CC BY-SA 4.0

I have a database server which uses a Samsung 840 pro disk. The load is constantly higher than usual, even if there is not much activity on the website. So I suspect the disk has worn out. But how can I check that the disk i/o is the bottleneck?

Here are some snapshots that might be relevant:

 top - 03:02:11 up 766 days, 20:45,  1 user,  load average: 7.42, 6.89, 6.72
Tasks: 325 total,   1 running, 321 sleeping,   3 stopped,   0 zombie
%Cpu(s): 17.3 us,  0.4 sy,  0.0 ni, 82.1 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem:  13227468+total, 27130284 used, 10514440+free,    94308 buffers
KiB Swap:  3906556 total,     9136 used,  3897420 free.  3833216 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                         
21764 mysql     20   0 27.058g 0.021t  12164 S 576.0 17.2  17369,44 mysqld                                                          
  574 root      20   0       0      0      0 S   0.3  0.0 280:00.66 jbd2/sda1-8                                                     
 5585 root      20   0       0      0      0 S   0.3  0.0   0:08.04 kworker/18:0                                                    
    1 root      20   0   28692   4540   2964 S   0.0  0.0  42:51.98 systemd                                                         
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.50 kthreadd                                                        
    3 root      20   0       0      0      0 S   0.0  0.0 894:44.38 ksoftirqd/0                                                     
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                    
    6 root      20   0       0      0      0 S   0.0  0.0  21:07.91 kworker/u64:0                                                   
    8 root      20   0       0      0      0 S   0.0  0.0   2510:32 rcu_sched                                                       
    9 root      20   0       0      0      0 S   0.0  0.0   0:00.00 

iotop output:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                         
21764 mysql     20   0 27.058g 0.021t  12164 S 576.0 17.2  17369,44 mysqld                                                          
  574 root      20   0       0      0      0 S   0.3  0.0 280:00.66 jbd2/sda1-8                                                     
 5585 root      20   0       0      0      0 S   0.3  0.0   0:08.04 kworker/18:0                                                    
    1 root      20   0   28692   4540   2964 S   0.0  0.0  42:51.98 systemd                                                         
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.50 kthreadd                                                        
    3 root      20   0       0      0      0 S   0.0  0.0 894:44.38 ksoftirqd/0                                                     
    5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                    
    6 root      20   0       0      0      0 S   0.0  0.0  21:07.91 kworker/u64:0                                                   
    8 root      20   0       0      0      0 S   0.0  0.0   2510:32 rcu_sched                                                       
    9 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh                                                          
   10 root      rt   0       0      0      0 S   0.0  0.0   5:28.52 migration/0                                                     
   11 root      rt   0       0      0      0 S   0.0  0.0   3:15.12 watchdog/0                                                      
   12 root      rt   0       0      0      0 S   0.0  0.0   3:27.27 watchdog/1                                                      
   13 root      rt   0       0      0      0 S   0.0  0.0   3:19.37 migration/1                                                     
   14 root      20   0       0      0      0 S   0.0  0.0 190:10.26 ksoftirqd/1                                                     
   16 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/1:0H                                                    
   17 root      rt   0       0      0      0 S   0.0  0.0   3:19.65 watchdog/2                                                      
   18 root      rt   0       0      0      0 S   0.0  0.0   2:52.44 migration/2                                                     
   19 root      20   0       0      0      0 S   0.0  0.0 194:18.02 ksoftirqd/2                                                     
   21 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/2:0H                                                    
   22 root      rt   0       0      0      0 S   0.0  0.0   3:21.4

iostat -m (the database is on sda and the linux filesystem on sdb)

Linux 3.16.0-4-amd64 (back)     03/27/20    _x86_64_    (32 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           6.76    0.00    0.38    0.07    0.00   92.79

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sdd               0.03         0.00         0.01      43327     384521
sdc               0.08         0.00         0.01     166547     748630
sdb               0.37         0.00         0.02      78269    1076710
sda               8.46         0.00         0.11      54407    7463246

已采纳解答

原帖链接 · davidgo · CC BY-SA 4.0

Everything posted above implies the CPU is the bottleneck -not the SSD. Most tellingly the 576% CPU, which I expect means 5.76 CPU cores being consumed.

The problem appears to relate to MySQL - maybe a race condition or complex query, corrupted table or bad indexing?

Were the problem the disk, I would gave expected to see low CPU and high IOWait, but IOWait is 0.07.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-03-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。