Skip to content

Instantly share code, notes, and snippets.

@thieux
Last active February 17, 2017 09:56
Show Gist options
  • Save thieux/ff3c474a7dd13b2fdde7dcadacd31eb5 to your computer and use it in GitHub Desktop.
Save thieux/ff3c474a7dd13b2fdde7dcadacd31eb5 to your computer and use it in GitHub Desktop.

Apache Kafka Overview

Replication

1 leader is elected per partition. Many followers. Followers calculate the offset. If leader crashes, a new leader is elected. Non replicated messages are lost.

Producers & consumers deal with the leader.

Producers

Producer request topology metadata. For 1 topic with 3 partition, we can have 3 leaders (to loadbalance).

Consumers

Broker cluster are consumed by groups. Each group can listen to all partitions. In a group, there could only be 1 consumer for 1 partition.

A consumer can be low-level. It deals with wire protocol, coordinates & offsets. Or it can be high-level. Then all the orchestration is already done.

Consumer failover: traffic is rebalanced to another consumer (some client libraries does not do it for you).

Important Definitions

  • ISR: In-sync replica
  • Topic
  • Partition
  • Producer
  • Broker
  • Consumer

CLI

Start configuration service

/opt/apache/kafka_2.11-0.10.1.1$ bin/zookeeper-server-start.sh config/zookeeper.properties 

Start the broker

/opt/apache/kafka_2.11-0.10.1.1$ sudo bin/kafka-server-start.sh config/server.properties 

Lists the topics

/opt/apache/kafka_2.11-0.10.1.1$ bin/kafka-topics.sh --list --zookeeper localhost:2181
echo Hello world | bin/kafka-console-producer.sh --broker-list localhost:9092 --topic Hello-Kafka
bin/kafka-console-consumer.sh --zookeeper localhost:2181 —topic Hello-Kafka --from-beginning

Sources

https://www.youtube.com/watch?v=GRPLRONVDWY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment