系統管理
1753266 會員
5507 線上
108792 解決方案
發表新文章

CPU - %idle and Load Average question

 
watermelonyu
教授

CPU - %idle and Load Average question

Hi,

從很多 monitor CPU 的 tools(Glance,top,sar,vmstat,uptime,..)

中得到的資料讓我有些迷惑處,為什麼明明

CPU 還有 15%idle 但 load avergae 還是有約 0.17.



我把 Load Average 的值解釋成現在有

多少個 processes 在等著 CPU 幫它做事,既然 CPU 還有 idle 那 Load avergae 應該為 0 啊,換個角度看,若 Load Avergae 的值大於0 那 CPU 的 idle 應該等於 0 啊,請問為何事實並非如此?



Thks & Best Regards,

4則回覆 4
watermelonyu
教授

CPU - %idle and Load Average question

即使CPU在100% idle的狀態下, load average的值還是會大於0, 在系統中, 除了user process外(ap process ... ), 還會有system process, 況且os是在live的狀態下
watermelonyu
教授

CPU - %idle and Load Average question

Hi Mathhew,



Thanks for your information.



可否解釋一下 Load Average(run queue)

定義?

系統是不是有一個 "queue" 的機制,所有的 process 需要 CPU 幫他做事時都一定要進入這個 queue 排隊然後 CPU 再從這個 queue 一個一個抓出來執行縱使現在 CPU 有 idle,而不是 CPU 現在很忙很忙沒時間幫我這個 process 做事,我這個 process 才會排進 queue 裏面?



Best Regards,
watermelonyu
教授

CPU - %idle and Load Average question

當一個process產生時, 標準的週期就是先等process需要的

資源,等資源準備妥當後, 就進入CPU的RUN QUEUE, 等待被執

行.



In HPUX uses a round robin scheduling mechanism

on CPU scheduler, the CPU lets each process run

for a preset amount of time, called a quantum

or time slice, until the process completes, or

is preempted to let another process run. This

also called 'context switching'.



對於load average(run queue)的解釋, 前者是對的,

但後面, 關於CPU idle, 如前面所述, 只要process

需要的資源準備妥了, 就會被放到cpu的run queue中

, 至於cpu什麼時候能執行process, 則要看

context switching, process priority..



詳細可參考附檔, 附檔內容自HP-UX 11i Internals節錄出來, 或者到教育訓練中心上HP-UX performance and tuning, 一定受益匪淺.
watermelonyu
教授

CPU - %idle and Load Average question

loading average 在 HP-UX 的定義是 : the average number of jobs in the run queue over the last 1, 5, and 15 minutes for the active processors.



即使系統沒有 run 任何的 ap, 因為有 OS 的 process 在執行, 所以 loading average 不會為 0



一般來說, 我們是透過觀察 loading average , 來衡量 CPU 是否 loading 過重. 如 loading average 為 CPU 個數的 2 倍以下, 則 CPU performance 佳, 如超過 3 倍, 即使還有 idle , 此時系統 performance 已經很糟了