What is Event-Driven Architecture (EDA)?
In Event-Driven Architecture, services:
-
Produce events when something happens
-
Consume events asynchronously
-
Do not wait for each other
π Services are loosely coupled.
π Example Event:
πΉ Why Use Event-Driven Architecture?
Without EDA:
-
Services call each other synchronously
-
Failures propagate
-
Poor scalability
With EDA:
-
High throughput
-
Fault tolerance
-
Better scalability
πΉ Role of Kafka in Microservices

Apache Kafka is a distributed event-streaming platform.
Kafka acts as:
-
Event broker
-
Message buffer
-
Streaming platform
πΉ Kafka Core Concepts
| Term | Meaning |
|---|---|
| Topic | Event category |
| Partition | Parallelism |
| Producer | Publishes events |
| Consumer | Reads events |
| Consumer Group | Scales consumers |
| Offset | Message position |
πΉ Kafka Event Flow
-
Producer publishes event to topic
-
Kafka stores event durably
-
Consumers read at their own pace
-
Offset committed after processing
πΉ Why Kafka is Preferred?
β
High throughput
β
Horizontal scalability
β
Message durability
β
Replay capability
β
Loose coupling
πΉ Example (E-commerce)
Order Service β publishes OrderPlaced
Payment Service β consumes
Email Service β consumes
Inventory Service β consumes
π No direct dependency.
πΉ Kafka Delivery Semantics
-
At-most-once
-
At-least-once
-
Exactly-once
πΉ Kafka vs RabbitMQ (Quick)
| Feature | Kafka | RabbitMQ |
|---|---|---|
| Throughput | Very High | Medium |
| Retention | Long | Short |
| Replay | Yes | No |
| Use Case | Event streams | Task queues |
β Interview One-Liner
βEvent-driven architecture uses events for communication, and Kafka enables scalable, fault-tolerant, asynchronous messaging between microservices.β
πΉ Common Follow-Up Questions
-
How do you handle duplicate events?
-
How do you ensure ordering in Kafka?
-
What is consumer lag?