Site icon Narayana Tutorial

Apache Kafka Terminology or Keywords

Apache-Kafka-Terminology

Apache-Kafka-Terminology

Apache Kafka Terminology or Keywords

In this article, we will discuss Apache Kafka Keywords such as Topic, Partition, Broker, Producer, Consumer, Consumer Group, Partitions, Message Key, Offset, Replication Factor, etc..

 

Topic

kafka-topics.bat --zookeeper localhost:2181 --create --topic MyFirstTopic2 --partitions 1 --replication-factor 3

Replication Factor

kafka-topics.bat --zookeeper localhost:2181 --create --topic MyFirstTopic2 --partitions 1 --replication-factor 3

Here partitions are 1, the partitions data will be replicated 3 times.

Partitions

Kafka-Partitions

kafka-topics.bat --zookeeper localhost:2181 --create --topic MyFirstTopic2 --partitions 1 --replication-factor 3

Broker

Kafka-Broker-Leader-Replications

Message Key

Producer

Kafka-Producers

Consumer

Kafka-Consumers

Producers – Consumers

Kafka-Producers-Consumers

Consumer Group

Example:

Consumer 1 —> Partition 1 —- Right

Consumer 1 —> Partition 1 & Partition 2 —- Right

Partition 1 —> Consumer 1 —- Right

Partition 1 —> Consumer 1 & Consumer 2 —- Wrong

Example: 4 Consumers and 3 Partitions -> 1 Consumer will be idle

Kafka-Consumers-Consumers-Count-Greatar-Than-Partitions-Count

Example: 3 Consumers and 4 Partitions

Consumer 1 —> Partition 1

Consumer 2 —> Partition 2

Consumer 3 —> Partition 3

Consumer 1 or Consumer 2 or Consumer 3 in which any one of the consumers consume the partition P4

Kafka-Consumers-PartitionCount-Greater-Than-Consumer-Count

Example: 3 Consumers and 3 Partitions

Consumer 1 —> Partition 1

Consumer 2 —-> Partitiion 2

Consumer 3 —-> Partitiion 3

Kafka-Consumers-Partitions-Consumers-Equal

Offset

Each message in a topic is assigned a sequential number that uniquely identifies the message within a partition. This number is called an offset,