What Problem Does Kafka Solve?
When a customer places an order on Zomato, multiple things need to happen at the same time:
- Payment service needs to charge the customer
- Restaurant service needs to notify the kitchen
- Notification service needs to send a confirmation SMS
Without Kafka, the Zomato app would call each of these services directly over HTTP/REST. If the payment service is slow, everything waits. If the notification service is down, data is lost.
Kafka solves this by decoupling producers from consumers using a message broker.
Core Components
Producer
- The component that sends (writes) data into Kafka
- In Zomato's case: the Zomato App, Driver App, REST API, IoT Sensors
- Producers don't care who reads the data — they just publish to a topic
Broker (Kafka Server)
- The heart of Kafka — stores and manages messages
- Contains Topics, which are named channels for messages
- Messages are persisted on disk — even if consumers are slow or offline
- Can be clustered (multiple brokers) for high availability
Topic
- A named stream of messages