Kai Chen
    • 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
    # 虎年行大運 ~ Kafka - 介紹 ## 【What is Kafka?】 **Kafka** 是由 Apache 軟體基金會開發的專門處理訊息串流的服務平台,其底層是由 Java 和 Scala 撰寫開發完成。主要負責訊息的接收與處理和後續的發送。 最初由 **LinkedIn** 開發,並於 2011 年開放原始碼,在 2012 年由 Apache 發布穩定版本。 而所謂的專門,指的便是面對 C10K、C100K 等級的訊息流量還能夠保持正常運行的硬實力 當然其所需要耗費的維護成本也相對高些,因此在低流量的商業服務中,並不需要特別架設 Kafka 的服務,可能 AWS 的 SQS、Redis 都可以暫且充當 MQ 的角色。 > 甚至可能不需要 MQ... 總而言之,如果你的商業服務正面臨著巨大的商業流量需求,而數據讀寫的速度與交流方式一直有交互影響的問題產生,那 Kafka 很適合幫助你解決這些困擾! ## 【優勢】 - **解耦合** 為了傳遞資料訊息,服務與服務之間必須要相互連接,因此就產生了高耦合的壞處,這並不符合「低耦合、高內聚」的設計精神,因此勢必在眾多需要交換資料的服務中,會需要一個統一處理資料的中心,Kafka 正好適合這個中間人的角色,他幫助所有服務斷開彼此的耦合,並把訊息的接收、處理、通知工作全攬在身上,服務們只需要送入資料、等待資料處理完成的通知,然後再做取資料即可。 - **擴展性佳** Kafka 本身的服務也是一個集群,能透過增添更多的 Kafka 服務輕鬆擴展,且就算要減少集群的服務也算容易,Kafka 本身面對服務的擴展與減少都有很強的自動調整機制,當然減少的風險還是比增加的高很多,因為為了配合既存資料的備份與轉換身分(後續會提到),這點要多加注意! - **持久化** 為了避免訊息的遺失,Kafka 在保存上會直接將訊息寫入資料檔,並存於 Logs 資料夾底下,直到被正確的使用完畢後才刪除(甚至根本不刪除)。同時訊息會同步備份在不同 Kafka 服務中。 - **可恢復性** 當個別的服務停止運行時,尚且能夠在其他服務中找到相同的資料,不影響整體系統。在服務恢復運行後,會自動重新進入集群,無須再重啟所有 Kafka 項目。 - **保證資料順序** Kafka 提供不同的區域存放資料,通常也被拿來做分類使用,Kafka 保證分區的資料順序性,但不保證不同分區的順序。通常一區域會完全放置相同類型的資料,以確保順序,但若是存放備份資料的區域則不太考慮此情況。 - **支援異步處理** 資料送入,在經過處理後,可經由設定自動發送通知,通知其他服務來取資料使用,讓服務之間不再需要互相等待。 - **緩衝** Kafka 處理好的資料並不是透過自己傳送給需要資料的服務,僅是做到送出通知,而接收通知的服務則自行過來取用資料,這樣的好處是避免雙方的硬體設備、網路環境差異導致處理效益不彰。 ## 【缺點】 - **配置參數過多** 這可以是優點,也可以是缺點。 好處是可調整性高,且 Kafka 的預設參數偏向效能取向,所以在不要求多高安全性的情況下,基本不太需要調整。 壞處就是如果要將其安全性調整的高一些,那麼首先要了解所有參數的設置方式與其影響,講一句簡單的: 如果覺得調整 JVM 不是一件難事且很享受,那調整 Kafka 你會得到相同程度的愉悅快感。 - **複雜的建置過程** 在建立代理連線或發現服務上,Kafka 都不是非常友善,若沒有透過 ZooKeeper 的話,非常容易讓新手撞壁。簡單來說幾乎是綁死 ZooKeeper 服務在一包裡。 - **分區不保證資料順序、資料可能重複等** 這個可以透過同類型的資料送入同區得到解決,但在初期尚未釐清其寫入資料的流程與方式前,這會是一個困擾許多人的點,畢竟辛苦建立起的東西居然無法解決這些順序或重複資料的問題也太奇怪了。 ## 【傳送方式】 - **點對點模式** 處理好的資料只往一個點送通知,並等待被取出。被取出後的資料便會自動在 Kafka 中刪除。 - **發布/訂閱模式 (Kafka 主推)** 處理好的資料會往多個點推送通知,後續流程如上,但資料會保存在 Kafka 中更久的時間(甚至不刪除)。 ## 【結語】 簡單的介紹一下優缺點,下一篇開始介紹其架構,Kai 希望能用簡單的方式帶大家讀懂 Kafka 的資料流程。 首頁 [Kai 個人技術 Hackmd](/2G-RoB0QTrKzkftH2uLueA) ###### tags: `Kafka`

    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