Video in progress
What is Kafka, and how is it different from a regular message queue?
Kafka is a distributed log written to disk. A message isn't deleted after it's read; it stays until the retention period ends, so several systems can read it independently, as many times as they like.
📖 Answer
In a regular queue (say, a classic RabbitMQ queue) the consumer takes a message, acks it, and the message is gone from the queue. In Kafka the message is appended to the end of a topic and just stays there. Each consumer keeps its own position ("where have I read up to"), called the offset.
In practice this gives you:
- both the
billingservice and theanalyticsservice read the sameorderstopic without getting in each other's way; - if buggy code gets deployed, you can move the offset back and reprocess the messages;
- since writes to disk are sequential, hundreds of thousands of messages per second is normal.
If you think of Kafka as an "event log", a lot of things fall into place: it's not a mail carrier that delivers a message and is done, it's a journal that everyone can read.
Sign up to mark studied questions and save your progress.