Terminologies

A few terms are used in Kafka you need to know.

  • Message: A stream of bytes. For simplicity, assume it as a string.
  • Producer: The application or client that produces messages which will be consumed by other clients.
  • Consumer: A client who receives the messages produced by the producers.
  • Broker: Receives the messages, stores it, and decides the consumers who should get these messages.
  • Topic: A unique name through which the data is streamed.
  • Partition: A Partition is a virtual division which allows parallelizing a topic by splitting the data in a particular topic across multiple brokers. A topic can have multiple partitions. Minimum of 1.
  • Offset: A unique number for a message in a topic’s partition.
  • Consumer Group: A group of consumers.
  • Leader: The responsible unit for the topic’s partitions to store messages.
  • Replica: The mirror/sync of your data to handle the faults. So that the data doesn’t get lost.
  • In-Sync Replica(ISR) (Replication Group): The in-sync replicas are replicas that are alive and are in sync with the leader.

 

중요 포인트

  • 토픽으로 통하는 모든 데이터의 read/write는 오직 리더와 이루어진다.
  • ISR 내의 모든 follower들은 누구라도 리더가 될 수 있다.
  • 자신이 읽고 있는 파티션에는 같은 그룹내 다른 컨슈머가 읽을 수 없다.
  • 한번 늘린 파티션은 절대로 줄일 수 없기 때문에 운영중에 파티션을 늘리는 것은 충분히 고려해야한다.
  • 파티션에 순차적으로 메세지가 쓰여지지 않는다. 곧 컨슈머가 메세지를 순서대로 읽지 못할수있다.
  • 파티션 개수 >= 컨슈머 개수
  • 여러개의 컨슈머 그룹은 동일한 레코드를 받는다. 이때 각 컨슈머 그룹마다 별도로 오프셋 관리를 한다.

 

토픽, 리플리케이션 팩터, 카프카 클러스터 한눈에 정리

Topic Peter-Topic01 Peter-Topic02
파티션 수 2 2
레플리케이션 팩터 3 2
브로커 수 3 3

토픽의 파티션 리더의 위치를 유심히 보자
Kafka replication example
파티션 개수는 컨슈머 개수보다 크거나 같다

Offset 이란?

Partition 의 특정 Consumer 가 메세지를 읽어들인 위치를 나타냄. Consumer 가 메세지 수신 처리를 재개할 때 어떤 메세지 부터 가져 가야 하는 지 알 수 있음.

 

Offset Topic

Kafka 에는 Consumer 의 offset 을 저장 하는 topic 이 존재함. (v0.9 release)

  • __consumer_offsets
    • 일반 토픽처럼 partitioning, replication 되어 있음(offsets.topic.replication.factor=1 (default=1)
      • Consumer 가 Kafka에 현재까지 읽은 메세지의 offset 정보를 알려주는 것을 commit 이라 한다.

 

 

'빅데이터 > Kafka Cluster' 카테고리의 다른 글

Kafka restart과 retention  (0) 2022.02.28
Kafka 스트레스 테스트  (0) 2022.02.28
Kafka Consumer/Producer  (0) 2022.02.28
Kafka 자주 사용하는 명령  (0) 2022.02.28
Kafka cluster failover  (0) 2022.02.28

+ Recent posts