본문 바로가기
kafka/core

Consumer Fetcher 관련 주요 파라미터와 Fetcher 메커니즘 이해

by 개복이 2025. 5. 15.

Consumer Fetcher 관련 주요 파라미터와 Fetcher 메커니즘 이해

Consumer Fetcher 프로세스 개요

  • Fetcher는 Linked Queue 데이터를 가져오되, Linked Queue에 데이터가 없을 경우 ConsumerClientNetwork에서 데이터를 브로커로부터 가져올 것을 요청한다.

 

fetch.min.bytes

  • Fetcher가 record들을 읽어들이는 최소 bytes. 브로커는 지정된 fetch.min.bytes 이상의 새로운 메시지가 쌓일 때까지 전송을 하지 않는다.
  • 기본은 1bytes

 

fetch.max.bytes

  • Fetcher가 한번에 가져올 수 있는 최대 데이터 bytes
  • 기본은 50MB

 

fetch.max.wait.ms

  • 브로커에 fetch.min.bytes 이상의 메시지가 쌓일 때까지 최대 대기 시간.
  • 기본은 500ms

 

max.partition.fetch.bytes

  • Fetcher가 파티션별 한번에 최대로 가져올 수 있는 bytes
  • 기본은 1MB

 

max.poll.records

  • Fetcher가 한번에 가져올 수 있는 레코드 수.
  • 기본은 500

 

Consumer Fetcher 관련 주요 설정 파라미터 이해

consumer.poll(1000)으로 수행 시

  • 가져올 데이터가 1건도 없으면 poll() 인자 시간만큼 대기 후 return.
  • 가져와야할 과거 데이터가 많을 경우 max.partition.fetch.bytes로 배치 크기 설정. 그렇지 않을 경우 fetch.min.bytes로 배치 크기 설정.
  • 가장 최신의 offset 데이터를 가져오고 있다면 fetch.min.bytes만큼 가져오고 return. fetch.min.bytes 만큼 쌓이지 않는다면 fetch.max.wait.ms만큼 기다린후 return.
  • 오랜 과거 offset 데이터를 가져 온다면 최대 max.partition.fetch.bytes 만큼 파티션에서 읽은 뒤 return.
  • max.partition.fetch.bytes에 도달하지 못하여도 가장 최신의 offset에 도달하면 반환.
  • 토픽에 파티션이 많아도 가져오는 데이터량은 fetch.max.bytes로 제한.
  • Fetcher가 Linked Queue에서 가져오는 레코드의 개수는 max.poll.records로 제한.
fetch.min.bytes = 16384 ( 16KB )
fetch.max.wait.ms = 500 ( 500ms )
fetch.max.bytes = 52428000 ( 50MB )
max.partition.fetch.bytes = 1024168 ( 1MB )
max.poll.records = 500 ( 500개 )

 

 

 

댓글