리눅스/kafka
group coordinator , static group membership
정지홍
2024. 10. 20. 16:29
group coordinator
- consumer group을 관리한다.
- partition의 할당 및 rebalancing을 한다
- consumer가 읽은 데이터의 마지막 위치인 offset을 관리
- consumer의 상태 확인
- consumer가 group coordinator에게 heartBeat를 보내서 확인
- 장시간 consumer로부터 heart beat를 못받으면, group coordinator는 해당 consumer를 그룹에서 제거
- consumer group이 효율적으로 data를 사용할수있게 한다.
static group membership
- consumer group안에서 consumer의 세션을 고정시켜서, 재시작 or 일시중지되어도 rebalancing을 피하게 하는 기능
- 즉, 이전에 할당 받은 파티션을 계속하여 소비할 수 있게 해주는 기능.
- 이렇게 하여 서비스 중단 or 지연을 최소화한다.
- 만약 많은 consumer를 가지는 group에서 rebalancing이 일어나면, 모든 consumer가 rebalance를 하니 속도가 많이 느려짐
- Dynamic Membership 기본동작
- consumer가 session out을 하면, rebalancing을 수행
- Static Membership
- consumer가 고유한 meber ID를 가짐.
- consumer가 재시작 등을 하여도, kafka는 consumer가 다시 돌아올것이라고 예상하며 rebalancing을 하지않음.
- 이렇게 하여 동일한 consumer가 같은 partition을 계속 처리하는 것이 가능
- group coordinator는 consumer의 instance ID를 기억한다.
- 단, session.timeout.ms안에 재시작 해야함
- 장점:
- 1. rebalancing 최소화
- 2. consumer의 재시작 속도 향상
- 3. 세션 유지
1. consumer를 3개 기동시킨다.

2. 그리고 describe를 해본다.

3. 파티션 1번을 담당하는 것을 죽이고 다시 기동시킨다.


4. 이번에는 session.timeout.ms이 지나서 확인해보자.

