-
2025.02.11 spring kafka delayTIL 2025. 2. 11. 22:03
Spring Kafka Idle Between Polls
I've had a business requirement to slow down the consumption rate of a kafka consumer due to the impact it could possibly cause to other microservices. After a bit of research I've come to a solution
stackoverflow.com
spring kafka를 사용하는 환경입니다.
대량의 데이터가 한 번에 들어올 경우 애플리케이션 내부 로직으로 인해 컨슈머 애플리케이션뿐 아니라 DB, 타 서비스까지 트래픽이 전염됩니다.
이때 spring kafka의 설정 중 idleBetweenPolls를 사용하면 max-poll-records 만큼 poll한 메시지를 소비하고 다시 poll 하기 전의 delay를 줄 수 있습니다.
내부 구현을 보면 Thread.sleep으로 구현되어있습니다.주의할 점은 consumer group에서 제외당하지 않도록 max.poll.interval.ms보다 짧게 설정해야 한다는 것입니다.
또 concurrency별로 따로 적용될 테니 적절한 설정 값이 필요합니다
'TIL' 카테고리의 다른 글
2025.02.19 line 장애대응 (0) 2025.02.19 2025.02.13 mysql insert performance (0) 2025.02.13 2025.02.08 (0) 2025.02.08 2025.01.20 get_lock, user level lock (0) 2025.01.20 2025.01.07 mariadb source code (0) 2025.01.07