top中的wa的理解


CPU使用率:
參考 mpstat 手冊,%usr + %nice + %sys + %iwoait + %irq + %soft + %steal + %guest + %gnice + %idle = 100%

%steal一般是在虛擬機中才能看到數值,比如CPU overcommitment很嚴重的VPS,而%guest和%nice一般都很低,
所以也可以根據/proc/stat或者top可得,user + nice + system + idle + iowait + irq + softirq + steal = 100

To calculate Linux CPU usage time subtract the idle CPU time from the total CPU time as follows:
Total CPU time since boot = user + nice + system + idle + iowait + irq + softirq + steal
Total CPU Idle time since boot = idle + iowait
Total CPU usage time since boot = (Total CPU time since boot) - (Total CPU Idle time since boot)
Total CPU percentage = (Total CPU usage time since boot)/(Total CPU time since boot X 100)

%iowait:
%iowait 表示在一個采樣周期內有百分之幾的時間屬於以下情況:CPU空閑、並且有仍未完成的I/O請求。 就是由於IO導致無法充分利用CPU的時間。
%wa的解釋:Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request. 因此只要IO時間段內有CPU空閑,那這段CPU空閑的鍋就會由IO來背。wa就是用來提示io可能阻塞了系統性能。 實際wa本來也就是一段CPU空閑時間。

對 %iowait 常見的誤解有兩個:
  一是誤以為 %iowait 表示CPU不能工作的時間,
  二是誤以為 %iowait 表示I/O有瓶頸。

首先 %iowait 升高並不能證明等待I/O的進程數量增多了,也不能證明等待I/O的總時間增加了。例如,在CPU繁忙期間發生的I/O,無論IO是多還是少,%iowait都不會變;當CPU繁忙程度下降時,有一部分IO落入CPU空閑時間段內,導致%iowait升高。

可見%iowait是一個非常模糊的指標,如果看到 %iowait 升高,還需檢查I/O量有沒有明顯增加,avserv/avwait/avque等指標有沒有明顯增大,應用有沒有感覺變慢,如果都沒有,就沒什么好擔心的。有可能只是CPU閑了,結果wa指標出來了。

vmstat、sar、dstat、sysstat都沒有對磁盤作非常詳細的監控。
懷疑IO真的到達瓶頸時可以通過iostat來確認當前磁盤的IO狀態。iostat -d -x -k -c 1 10
也可以通過dstat來查看各種負載狀況來確認是否由其他負載導致。dstat -lmcdnr -fs --top-mem --top-io --top-cpu

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM