HackMD
  • New!
    New!  “Bookmark” and save your note
    Find a note that's worth keeping or want reading it later? “Bookmark” it to your personal reading list.
    Got it
    • New!  “Bookmark” and save your note
      New!  “Bookmark” and save your note
      Find a note that's worth keeping or want reading it later? “Bookmark” it to your personal reading list.
      Got it
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
      • ODF (Beta)
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
    Menu Sharing Help
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML ODF (Beta)
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note    
    Published Linked with
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ###### tags: `Linux`, `SRE` # SRE 讀書會 Round 4 #02 - 線上讀書會共筆 ## 活動資訊 * Date: 05/07 (四) 20:00 - 21:30 * [導讀進度表](https://docs.google.com/spreadsheets/d/1Lgti3mILkvwxyzklX1vvLraaGD-7ePK9rkmlulfOknE/edit#gid=0) * [導讀 Guideline](https://study-area.sre.tw/GuideLine/) * Github: [study-area-docs](https://github.com/cross-community/study-area-docs) --- # 現場共筆 ## 基礎篇05: 某個應用的 CPU 使用率居然達到 100%, 我該怎麼辦? #### 工具分享 - top - htop: 與 TOP 差異是會把 loading 用圖示的方式顯示 - atop - glances - pidstat 1 5 - 每個一秒鐘取樣一次,跑五次 #### 文章分享 * [Linux CPU利用率的這點事,身為DevOps的你有必要知道](https://kknews.cc/zh-tw/code/8ger29g.html):**推推** * [4.3. INTERRUPTS AND IRQ TUNING](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/performance_tuning_guide/s-cpu-irq) 龍星:我的老筆記 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](http://man7.org/linux/man-pages/man2/nice.2.html) 能力權限的控管 > 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: 硬體有關,通常是網路處理封包 ## 延伸討論話題 * https://github.com/michael-kehoe/sre-interview/blob/master/system-design.md --- # 參考資料 * [jiffies, HZ, ticks](https://eeepage.info/jiffies-kernel-timer/) * [execsnoop](http://www.brendangregg.com/blog/2014-07-28/execsnoop-for-linux.html) * download: https://github.com/brendangregg/perf-tools * [top](https://rickhw.github.io/2019/09/08/Linux/top/) * [execsnoop](https://github.com/brendangregg/perf-tools) * [bandwidthd](http://bandwidthd.sourceforge.net) * [LinkedIn 內部資深 SRE 所列舉的 SRE 面試題目](https://www.facebook.com/groups/sre.taiwan/permalink/1660123477486883/)

    Import from clipboard

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.
    All
    • All
    • Team
    No template found.

    Create a template

    Delete template

    Do you really want to delete this template?

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in via Google

    New to HackMD? Sign up

    Help

    Documents

    Tutorials
    YAML Metadata
    Slide Example
    Book Example

    Contacts

    Talk to us
    Report an issue
    Send us email

    Cheatsheet

    Example Syntax
    Header # Header
    • Unordered List
    - Unordered List
    1. Ordered List
    1. Ordered List
    • Todo List
    - [ ] Todo List
    Blockquote
    > Blockquote
    Bold font **Bold font**
    Italics font *Italics font*
    Strikethrough ~~Strikethrough~~
    19th 19^th^
    H2O H~2~O
    Inserted text ++Inserted text++
    Marked text ==Marked text==
    Link [link text](https:// "title")
    Image ![image alt](https:// "title")
    Code `Code`
    var i = 0;
    ```javascript
    var i = 0;
    ```
    :smile: :smile:
    Externals {%youtube youtube_id %}
    LaTeX $L^aT_eX$

    This is a alert area.

    :::info
    This is a alert area.
    :::

    Versions

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub

        Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully