Jui-Nan Lin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 2/8 SRE 讀書會共筆 --- 場地提供:PIXNET - 誠徵 [SRE 服務可靠度工程師](https://gist.github.com/jnlin/8329bea1c1ed92a1924da7e032304261),有興趣的朋友可聯繫 applyjob@pixnet.tw # 第十九章:Load Balancing at the Frontend - by 91APP 黃冠維 Frontend Load Balancer - 流量要怎麼從用戶傳導到 Load Balancer ## 負載平衡的一些考量 * 再強大的硬體都有極限 * 負載平衡系統 用來決定 哪些機器處理某個請求 * 架構考量 / 技術考量 / 使用者流量的屬性 搜尋請求 - 快速反應 影片上傳 - 大頻寬 * 使用 DNS 來進行負載平衡 * DNS 是最簡單、最有效的負載平衡機制 * 一個 Load Balancer 有很多個 IP,根據流量來作延展 AWS 的 ELB,最多解析 8 個 IP 壓測工具,如果解出的 IP 是同一個,Load Balancer 很快就被打掛了 假設全世界的使用者,都會指到不同 IP 使用傳統 ELB,如果預期會有大量流量,需要開 support ticket 給 AWS,作 warm up 的工作 * 使用虛擬 IP 處理負載平衡 (NLB) * 對用戶來說,解析到同一個 IP * 對封包來說,要怎麼知道要傳的目的地機器? id(packet) mod N * 用 MAC address 的解法 * 用 NAT 的解法 * 用 GRE 封包包裝的解法 => 可以跨機房 # 第二十章:Load Balancing in the Datacenter - by 91APP 黃冠維 * 理想狀況:每一台 server 一樣的 loading * 實際狀況:每一台 loading 有差別 如果沒有平均,那 1000 台就沒辦法正常的 Load Balance ## 流量控制、健康管理 健康、拒絕連接、跛腳鴨狀態 例如:Server 升級的時候,可以宣告自己是「跛腳鴨狀態」,拒絕新連線的連入 ## 子集劃分 Healthy Check,Server數太多的時候,不是好的分散式系統 例如:一個 Load Balancer 節點,負責三十個 Server 的 Healthy Check,前端 Connection 太多 建連線成本很大 用 Random 的結果,會不夠平均 套了神秘的演算法,就可以平均分配囉! 寫 Python 程式來驗證 用 random 是 C(300, 90) 的概念 ## 連線分配 * 輪詢 (Simple Round-Robin) * 子集太小 * 每個 Request 成本不同 * 不同等級的後端 Server * 其他因素 * Least-Loaded Round-Robin * Server 很快回錯誤,比正常消化快,Load Balancer 會一直丟給這個有問題的 Server * 不知道其他 Load Balancer 有丟給節點的數量 * Weighted Round-Robin * 混合各種系統健康速度,來作加權,決定要丟給哪個節點 ## 討論 * jnlin (PIXNET):遇過 DDoS 攻擊,後來用 DNS 來解決,把從越南、中國來的攻擊流量進行阻擋或 Filter * Rick (91APP):可以用 Route53 的 GeoDNS 來解決 * 某些店被競品競爭,會被 DDoS * Raix (PIXNET):Virtual IP 如何 Route 到特定的機器 * 硬體可以做得到 * 小明:有沒有一個方式,可以在各國有自己的 8.8.8.8 # 第二十一章:Handling overload - by PIXNET Dennis ## 系統總是會過載 * 服務降級 * 只搜尋小部分的回傳結果 * 存取非即時的 Cache 資料 * QPS 陷阱 * 限制服務端用量 * 針對「異常」,返回錯誤訊息 * 對服務配置額度 * 服務端節流機制 * 配額不足回應過多,應自己限制 request * Request 可以分重要性 * 重要性可以繼承 * 資源利用信號 * 以 CPU 為指標 * 由執行器負載均值來決定 * 過載錯誤處理 * 大部分資源過載 * 停止 retry * 小部分資源過載 * 快速拒絕,快速 retry * 可能是 load balancer 不完美造成的 * Retry 的次數 * 次數限制 < 3 次 * 觀察 retry 比例 < 10% * 過載情況下,不需要 retry * 由可用資源拒絕 將過載極限值盡量提升到很難發生的程度 正瑋:降級服務,有人曾經作過這樣設計嗎? Rick (91APP):作開關,例如廣告拿掉。 Rick (91APP):有在做容量 Control 嗎? 正瑋:跟容量規劃有點像 Rick (91APP):nginx 有內建,API Gateway 有類似的機制

    Import from clipboard

    Paste your markdown or webpage here...

    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 lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    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 with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # 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
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    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.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        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
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

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

        Syncing

        Push failed

        Push successfully