Coder Social home page Coder Social logo

Broker about kafka-playground HOT 1 OPEN

jihwan2da avatar jihwan2da commented on May 13, 2024
Broker

from kafka-playground.

Comments (1)

jihwan2da avatar jihwan2da commented on May 13, 2024

Broker가 무엇인가?

  • Kafka에서 Broker는 producer와 consumer 사이에서 데이터를 주고 받기 위해 사용하는 주체이자, 데이터를 분산 저장하여 장애가 발생하더라도 안전하게 사용할 수 있도록 도와주는 애플리케이션이다.
  • 여러개의 Topic과 Partition을 가진 물리적 장비이다.
  • 하나의 서버에 하나의 브로커 프로세스가 실행되고, 브로커 서버 1개로도 운영이 가능하지만, 데이터를 안전하게 보관/처리하기 위해(브로커 서버 1개로 운영했을 때, 그 브로커 서버 1개의 장애가 생기는 경우 데이터를 일시적으로 처리하지 못함) 3대 이상의 브로커 서버를 1개의 클러스터 묶어서 운영한다.

Broker의 정확한 역할은 무엇이 있을까?

  • Controller Broker
    • 하나의 Cluster에서 여러개의 Broker 중 하나가 Controller Broker로서 역할을 하게 되는데, 다른 Broker들의 상태를 체크하고 하나의 Broker에서 장애가 발생했을 때, 후처리 역할을 한다.
    • 어느 하나의 Broker가 빠지는 경우(장애가 발생한 경우) 해당 Broker에 존재하는 Leader Partition을 재분배 하는 역할을 한다.
    • 만약 Controller Broker에서 장애가 발생한다면?
      • 다른 Broker가 Controller Broker 역할을 한다.
  • 데이터 삭제
    • Kafka는 컨슈머가 데이터를 가져가더라도 토픽의 데이터는 삭제되지 않는다. (다른 메세징 플랫폼과 다른점) 프로듀서/컨슈머가 삭제 요청도 할 수 없다. 오직 Broker만 데이터 삭제를 할 수 있다
    • 그면 Broker는 어떻게 삭제하나?
      • Kafka는 record(데이터)들을 log segment단위로 관리를 하는데, 그 log segment가 active하지 않은 segment이고 kafka가 설정한 시간이 지난 or 용량의 한계가 있는 segment이면 그 segment를 통째로 삭제한다.(여러개의 record가 한번에 삭제됨)
  • consumer offset 저장
    • consumer 그룹은 topic의 특정 partition으로 부터 데이터를 가져가서 처리하고 이 partition의 어느 record까지 가져갔는지 기록하기 위해 offset을 commit한다.
    • commit한 offset은 __consumer_offset 토픽에 저장한다.
    • __consumer_offset은 internal topic으로 자동 생성되고 관리되어 진다.
  • group cordinator
    • consumer group의 상태를 체크하고 partition을 consumer와 매칭되도록 분배한다.
    • consumer 그룹의 특정 consumer가 장애가 발생하면 그 consumer와 매칭되어 있던 partition을 다른 consumer와 매칭해주는 rebalnce 작업을 한다.

from kafka-playground.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.