Partitions in action
Course: Kafka - chapter 7
In this slide, we’ll talk about what are partitions in Kafka
- Create a new topic with 3 partitions
./kafka-topics.sh --create --topic payment-done --partitions 3 --bootstrap-server localhost:9092- Ensure it has 3 partitions
./kafka-topics.sh --describe --topic payment-done --bootstrap-server localhost:9092- Update the topic in the node.js script to use
payment-done
async function main() { await producer.connect(); await producer.send({ topic: "payment-done", messages: [{ value: "hi there", key: "user1" }] });}///await consumer.subscribe({ topic: "payment-done", fromBeginning: true})- Consume messages in 3 terminals
npm run consume- produce messages
npm run produce- Notice the messages get consumed by all 3 consumers

Current architecture
Section titled “Current architecture”
Assignment
Section titled “Assignment”Try deleting a few consumers and notice the partition gets re-assigned to a different one
Use the following to see which consumer is consuming on which topic
./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-app3