java面试题:服务器IO延时如何定位

  1. 首先是top查看一下系统状况

发现两个参数异常,一是平均负载高,一是cpu %wa一直在50%以上。

查了一下%wa参数的意义:就是等待IO的时间

wa -- iowait
 Amount of time the CPU has been waiting for I/O to complete.
  1. 查看磁盘使用情况
> PROCESS STATE CODES  
> D uninterruptible sleep (usually IO) 
>  R running or runnable (on run queue) 
>  S interruptible sleep (waiting for an event to complete)  
> T stopped, either by a job control signal or
> because it is being traced.  
> W paging (not valid since the 2.6.xx kernel)  
> X dead (should never be seen)  
> Z defunct ("zombie") process, terminated but not reaped by its parent.
  1. 查看到进程中状态D(disk sleep)的进程
for x in `seq 1 1 10`; do ps -eo state,pid,cmd | grep "^D"; echo "----"; sleep 5; done
  1. 查看进程相关状态信息
cat /proc/487/io
 rchar: 48752567
 wchar: 549961789
 syscr: 5967
 syscw: 67138
 read_bytes: 49020928
 write_bytes: 549961728
 cancelled_write_bytes: 0

查看都往哪写东西了

 lsof -p 487

就是查看引起进程该状态的原因

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值