What is Apache Kafka?

Apache Kafka is a distributed event streaming platform used to publish, store, and process continuous streams of data records in real time, at high throughput and scale.

Key Points

Example

An online retailer might use Kafka to capture every "item added to cart" event in real time, feeding both a live inventory system and a recommendation engine from the same stream of events.

// Spring Boot: publish an event and consume it (spring-kafka dependency)
@Service
public class CartEvents {

    private final KafkaTemplate<String, String> kafkaTemplate;

    public CartEvents(KafkaTemplate<String, String> kafkaTemplate) {
        this.kafkaTemplate = kafkaTemplate;
    }

    public void itemAdded(String userId, String productId) {
        // key = userId, so all events of one user stay in order on one partition
        kafkaTemplate.send("cart-events", userId, "ADDED:" + productId);
    }
}

@Component
public class InventoryListener {

    @KafkaListener(topics = "cart-events", groupId = "inventory-service")
    public void onEvent(String event) {
        System.out.println("Inventory received " + event);
    }
}

// application.properties
// spring.kafka.bootstrap-servers=localhost:9092

Interview Tip

A concise interview answer is

Apache Kafka is a distributed event streaming platform that lets applications publish and subscribe to continuous streams of data through durable, partitioned topics, and it's built to handle very high throughput with strong durability and horizontal scalability, which is why it's a common backbone for real-time data pipelines.

Last updated: 1 November 2026

Next question: What are some common use cases of Kafka?

More Kafka (Optional) interview questions

All Kafka (Optional) questions