리눅스/kafka
consumer의 heart beat thread
정지홍
2024. 10. 21. 09:46
heart beat thread
- consumer와 group coordinator와의 연결 상태를 주기적으로 유지하는 역할을 하는 background thread이다.
- consumer의 활성 상태 확인
- session time out 감지
- rebalancing감지
- group coordinator가 group안에서 rebalancing 시작하면, heart beat thread는 consumer에게 이를 알려줌.
- 이를 전달 받은 consumer는 할당된 partition의 처리를 멈추고 새로운 partition할당을 기다림
- group coordinator가 group안에서 rebalancing 시작하면, heart beat thread는 consumer에게 이를 알려줌.
- heartbeat.interval.ms
- heartbeat 신호를 보내는 간격. default= 3000ms
- session.timeout.ms
- consumer를 timeout시키는 시간. default=10000ms
- max.poll.interval.ms
- 메시지를 풀링하는데 최대 시간 간격.
- 이 시간안에 풀링을 안하면 rebalancing. default=300000ms
props.setProperty(ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG , "5000");
props.setProperty(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG , "500000");
props.setProperty(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG , "600000");