ModernWeb
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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 New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # “淩雲”分散式任務調度架構設計與應用 - 毛宏 (Jason) ###### tags: `MW18` {%hackmd j86FNbMoRoeN4Xn0pg5ofw %} > 請從這裡開始 ## Agenda * 背景與挑戰 * 凌雲任務調度架構 * 應用與實踐 * 總結與展望 ## 背景與挑戰 ### 搜狗商業平台特點 * 承擔多產品線的廣告投放 * 為廣告主、合作夥伴及業務人員提供安全穩定的商業平台 * 商業複雜度高 ### 最初方案 * Linux Crontab * 簡單、快速、佈屬便捷 * 隨著任務數量逐漸增多,問題凸顯 * 任務管理分散 難查 log * 任務配置成本高 * 手動配置易出錯 * 任務監控成本高 * 需要為每個任務做客製化的監控,成本很高 * ...... ### 改進方案 * 引入Quartz作業調度框架 * 抽象任務調度層,提供公共任務執行框架 * 各任務節點獨立調度自己的任務 * 問題 * 任務節點負載不均,且有單點問題 ### 挑戰 * 任務類型多、數量多 * 任務之間依賴關係複雜 * 任務觸發方式多樣 * 監控方案複雜 * 失敗重試 * 超時警告 * 任務高可用 * 如果節點 fail 需要人工介入轉到另一個節點執行 ## 凌雲任務調度架構 ### 目標 * 提供一個統一的任務平台,管理所有任務配置,調度與執行 * 平台化 * 各團隊統一任務調度 * 提升營運效率 * 任務依賴 * 支持任務有多個前驅任務或後繼任務 * 支持任務依賴型及跟蹤 * 可擴展性 * 系統模塊可水平擴容、縮容 * 任務運行類型可擴展 (不限於某一類任務) * 穩定性 * 系統高可用 * 節點當機時不影響任務正常調度 * 用戶接口簡單、方便接入 * 開發任務程式碼 -> 註冊 -> 凌雲任務調度平台 * 測試 (驗證) * 運維 (管理) ### 思考 * 如何平台化? * 任務管理 * 規範化任務配置 (負責人、屬性、程式碼) * 統一任務調度方式 * 面對用戶 * 區分不同登入角色 * 對用戶儘量透明 * 靈活支援用戶需求 * 系統架構 * 高可用、可擴展 * 調度策略可配置 * 不同任務互不干擾 ### 重新訂義任務調度平台 任務調度平台 = 任務管理 + 任務觸發 + 任務執行 * 任務管理 * 基本資訊 * 生命週期 * 依賴關係 * 統計分析 * 任務觸發 * 基於時間 * 基於事件 * 基於消息 * 路由策略 * 任務執行 * 不限語言 * 不限框架 ### 設計-整體架構 低耦合任務管理、任務調度、任務執行各司其職 * 管理平台 * 節點管理 * 任務管理 * 調度管理 * 用戶管理 調度集群 任務節點 * 執行任務 * 呈現結果 #### 如何通信 * 考慮點 * 高性能 * 擴展性強 * 開發成本可控 * 我們的選擇:thrift * 可伸縮的跨語言福的高性能 RPC 框架 * 支援多種資料傳輸格式和傳輸方式 * 支援阻塞、非阻塞方式 * 支援堵塞非堵塞等多種服務模型 * 管理平台與調度集群之間 * 基於 Thrift http 通信 * 調度集群與任務節點之間 * 無狀態 stateless * Thrift RPC * 調度演算法外掛程式化,支援動態調度 * 安全認證 * 基於簡單密鑰進行統一認證授權 * 高可用 * Web 管理平台 * 通過 nginx 做 reverse proxy * 多個服務實力共用 session * 調度集群 * stateless * 水平擴容 * 任務節點 * 一個任務組下多個節點,可動態伸縮 #### 任務調度執行 * 有關任務運行需求 * 我的任務要每小時 0 分準時執行 * 每週上午 9 點執行 * 1號發出郵件 * 每季末要做彙總計算 * 仰賴其他認爲結果,需要再依賴的任務完成後才能執行 * 計算密集型,需要消耗 CPI * 數導出 需要 IO 資源 * 使用大量內存 * 每月一號發郵件 * 每季度莫彙總 * 我的任務必須依賴其他任務的結果 * 我的任務要滿足一定業務需求才需要運行 * 計算密集型,需要高CPU * 資料導入導出需要高IO * 需要大量記憶體 * 任務觸發方式 * 基於時間 * 基於 Quartz 集群模式 * 基於資料庫鎖 * 一次任務調度只會觸發一次 * 任務映射 * 使用者導向:task trigger * quartz導向:qrtzJobDetal, qrtzTriggers * 基於依賴 * 管理平台維護任務依賴關係,建立任務依賴圖譜 * 調度集群管理一組依賴任務的生命週期 * 基於事件 * 提供 API,讓客戶端在事件發生時呼叫 * 如何執行任務 * 由任務節點執行 * 基於任務代理 一個輕量級的代理執行序 * 任務執行結果 * 判斷任務執行序結束碼 * 0: 成功 * 非0: 對應不同失敗原因 * 調度算法插件化 * 任務類型不同 * CPU 密集型 * IO 密集型 * memory 密集型 * 不同業務場景有不同調度需求 * 輪詢、隨機、一致性HASH * 定向調度 * 提供調度算法接口 * 根據具體場景實現調度算法接口 * 任務節點探測 * 心跳檢測 * 主動上報節點狀態 * 任務運行情況 * 附載狀況 * 資源使用率 * 超時複檢 * 若一定時間內未收到節點上報狀態,調度集群主動發起一次探測 * 若 ok 等到節點下一次週期上報,連續 N 次未收到,摘除節點 * 若 Fail,摘除節點 * 節點恢復 * 節點恢復後,主動上報狀態,重新加入節點組 * 重試 * 視覺化集中管理 * 建構統一的任務管理平台 * 任務參數 * 多個key-value參數 * 任務內部可通過key獲取value值作為運行時參數 * 報警策略 * 郵件 * 短信 ![](https://i.imgur.com/VFluLq7.jpg) * 調度管理 * 基於觸發器調度 * 基於依賴調度 * 基於事件調度 * 用戶管理 * 基於角色的存取權限控制(RBAC) * 開發、測試、生產環境,許可權隔離 ### 設計-低成本接入 * 統一任務開發框架 * 抽象任務類型 * 提供統一的任務開發SDK * 提供取得任務基本資訊的 API * 開發人員只需關注業務代碼本身 * 部署任務代碼到指定任務節點即可 ## 應用與實踐 * 目前應用場景 * 廣告風險控制 * 報告計算 * 計費比對 * 大數據分析 * 機器學習 * 快取更新 * 資料備份 * 自動化測試 * 運維監控 * 依賴鏈路跟蹤 * 任務鏈的第一個任務生成任務 trace ID * 根據任務的 trace ID跟蹤任務 ## 總結與展望 ### 總結 * 系統架構 * 解耦合 * 可擴展 * 高可用 * 彈性擴縮容 * 調度管理 * 簡單 * 動態 * 支援依賴 * 容錯轉移 * 失敗重試 * 進度監控 * 及時日誌 * 任務開發 * 易上手 * 語言不限 * 部署方便 ### 展望 * 容器化調度,目前是基於實體節點的調度 * 分片任務調度 * Web IDE 支援 * 開源回饋 ###### tags: `MW18`

    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