Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broker #1

Open
jihwan2da opened this issue Mar 22, 2023 · 1 comment
Open

Broker #1

jihwan2da opened this issue Mar 22, 2023 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@jihwan2da
Copy link
Owner

jihwan2da commented Mar 22, 2023

Kafka Broker

@jihwan2da
Copy link
Owner Author

jihwan2da commented Mar 22, 2023

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 작업을 한다.

@jihwan2da jihwan2da self-assigned this Mar 22, 2023
@jihwan2da jihwan2da added the documentation Improvements or additions to documentation label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant