Try   HackMD
tags: Linux, SRE

SRE 讀書會 Round 4 #02 - 線上讀書會共筆

活動資訊


現場共筆

基礎篇05: 某個應用的 CPU 使用率居然達到 100%, 我該怎麼辦?

工具分享

  • top
  • htop: 與 TOP 差異是會把 loading 用圖示的方式顯示
  • atop
  • glances
  • pidstat 1 5
    • 每個一秒鐘取樣一次,跑五次

文章分享

龍星:我的老筆記
https://sites.google.com/site/ina2588book/
Verynice(包:verynice)服務通過調整進程nice(優先級)動態分配CPU資源。/etc/verynice.conf是配置文件,Verynice會分給其中goodexe(比如X、多媒體軟件)更多的CPU資源,badexe反之。

IOWait 放在
http://www.brendangregg.com/USEmethod/use-linux.html
http://www.brendangregg.com/linuxperf.html

問題探討

Q1: nice 為什麼 user 只能動 1~19?
A: 可能是因為系統層面有些部分還是需要更高的權限,類似 tcp port 1024 以下只有 root 可以開。
A2: CAP_SYS_NICE 能力權限的控管

The calling process attempted to increase its priority by
supplying a negative inc but has insufficient privileges.
Under Linux, the CAP_SYS_NICE capability is required. (But
see the discussion of the RLIMIT_NICE resource limit in

Q2: irq 和 softirq 有什麼不同?
A2: softirq 應該是共用硬體 irq,軟中斷。

案例06: 系統的 CPU 使用率很高,但為啥卻找不到高的 CPU 應用?

Nginx RPS (Request Per Seconds) 比較

正常情況下:14540.80 (/seconds)
使用 ab 測試情況下: 280 (/seconds) < 因有問題導致 RPQ 過低
(沒有比較沒有傷害)

  • debug 需要有經驗
  • 當在救火時,建議要有發言人,讓救火的人可以安心救火,不被打擾
  • permission denied
    • userid of process == userid of file or directory
  • 有些 process 是短時間 process, 所以會不斷重啟, pid 會一直改變,這樣很難去偵測問題,所以要去找他的 parent process, 找到調用它的 process, 比較可以找到問題。
  • 指令記得盡量用打的,不要 copy & paste
  • bandwidthd: 查看網路頻寬資訊的工具

irq: 硬體有關,通常是網路處理封包

延伸討論話題


參考資料