What is Apache Kafka? It is an open source distributed event streaming platform used to publish, store and process streams of events in real time. Instead of systems calling each other directly, they write events such as an order placed or a sensor reading to Kafka, and any number of other systems read those events when they are ready. Kafka handles very high volumes with low delay and keeps events for as long as you choose. This guide explains how Kafka works, its core concepts, common use cases, how it compares with message queues, and how to run it well.
Short answer: Kafka is a durable, scalable log of events. Producers append events to topics, which are split into partitions across brokers, and consumers read at their own pace. It is used for real-time data pipelines, event driven applications, activity tracking and stream processing.
What is Apache Kafka?
Kafka was created at LinkedIn and released as open source in 2011, and the Apache Kafka article on Wikipedia covers its history. It is now one of the most widely used technologies for moving data between systems. Kafka is a foundation for event driven architecture, for streaming parts of a data pipeline and for connecting services in a microservices design.
Core Kafka concepts
| Concept | Meaning | Why it matters |
|---|---|---|
| Event, or record | A key, a value and a timestamp describing something that happened | The basic unit of data |
| Topic | A named stream of events, such as orders | Organises events by subject |
| Partition | A topic is split into ordered partitions spread across brokers | Provides parallelism and scale |
| Broker | A Kafka server that stores partitions and serves clients | A cluster has several for resilience |
| Producer | An application that writes events to topics | Publishes without knowing consumers |
| Consumer and consumer group | Applications that read events, sharing the work in a group | Scale reading and keep independent positions |
| Offset | The position of a consumer in a partition | Allows replay and recovery |
| Replication | Copies of each partition on other brokers | Protects against server failure |
How Kafka works

- A producer sends an event. The event is assigned to a partition, often by hashing its key so related events stay in order.
- The broker appends it to a log. Events are written sequentially to disk, which is fast and durable.
- The event is replicated. Followers copy the data so a broker failure does not lose it.
- Consumers read the log. Each consumer group tracks its own offset and reads at its own speed.
- Events are retained. Kafka keeps events for a configured time or size, so new consumers can replay history.
- Processing and connectors extend it. Kafka Streams and other engines transform events, and Kafka Connect moves data to and from databases and applications.
Kafka compared with a traditional message queue
| Aspect | Message queue | Kafka |
|---|---|---|
| Model | Message is removed once consumed | Events stay in a log and can be read again |
| Consumers | Usually compete for messages | Many groups can read the same events independently |
| Ordering | Per queue | Per partition |
| Throughput | Moderate | Very high |
| Best for | Task distribution and simple messaging | Streaming, event sourcing and data pipelines |
Common Kafka use cases
| Use case | Example |
|---|---|
| Real-time analytics | Dashboards of clicks, payments or machine data. See what is real-time analytics |
| Data integration | Stream database changes to a warehouse using change data capture |
| Event driven microservices | Order service publishes events that inventory and billing consume |
| Activity tracking | Capture user actions across web and mobile |
| Log and metric collection | Centralise telemetry. See what is observability |
| Fraud detection | Score transactions as they stream through |
| Machine learning features | Feed fresh events into models. See what is machine learning |
Running Kafka well
- Choose partition counts based on throughput and consumer parallelism, and remember they are hard to reduce later.
- Use a replication factor of at least three for production topics.
- Choose keys carefully so related events share a partition and stay in order.
- Monitor consumer lag, broker health and disk use. See what is observability.
- Define schemas with a registry so producers and consumers can evolve safely.
- Secure the cluster with encryption, authentication and access control lists.
- Consider a managed service such as Confluent Cloud, Amazon MSK or Azure Event Hubs for Kafka to reduce operations work.
Common Kafka mistakes
- Using Kafka for a small, simple queue where a lighter tool would do.
- Too few or too many partitions, leading to bottlenecks or overhead.
- Not handling duplicates, since a consumer may process an event twice. Make processing idempotent.
- Ignoring schema management, so one change breaks many consumers.
- Treating Kafka as a database for ad hoc queries.
- Leaving retention and storage unmonitored until a disk fills.
Our system integration service designs event driven integrations on Kafka and similar platforms, and our data analytics service builds streaming analytics on top. For API based integration see our API development service.
A worked example: real-time order tracking
An online retailer wants customers to see live order status. Previously the order system called the warehouse, shipping and notification systems directly, and an outage in one of them slowed checkout. The team introduces Kafka. The order service publishes an order placed event. The warehouse system, the shipping system, the email service and an analytics pipeline each consume it independently and publish their own events when they finish, such as picked, shipped and delivered.
Checkout no longer waits for downstream systems, so a shipping outage does not affect sales, and the shipping team can catch up later by reading the backlog. A dashboard subscribes to all topics and shows order flow in real time. A new fraud check is added by simply reading the same events, with no change to the order service. The team spends time on idempotent consumers and schema rules, which prevent duplicate emails and broken readers when fields change.
Kafka ecosystem tools
| Tool | Purpose |
|---|---|
| Kafka Connect | Source and sink connectors for databases, storage and SaaS applications |
| Kafka Streams and ksqlDB | Process and query streams using code or SQL |
| Schema Registry | Stores and checks event schemas so changes are compatible |
| MirrorMaker and cluster linking | Replicate topics between clusters or regions |
| Apache Flink and Spark | Advanced stream processing. See what is Apache Spark |
Most production setups combine several of these. Connectors bring data in, a schema registry keeps formats under control, and a stream processor computes results such as running totals or alerts before writing them back to Kafka or to a warehouse.
Delivery guarantees
| Guarantee | Meaning | Trade-off |
|---|---|---|
| At most once | An event may be lost but is never repeated | Fast but risky for important data |
| At least once | No loss, but an event may be processed twice | Common default, requires idempotent consumers |
| Exactly once | Each event has its effect once within Kafka processing | More overhead and careful configuration |
Most teams choose at least once delivery and design consumers to handle duplicates, for example by recording the id of each processed event. This is simpler and more robust than depending on exactly once behaviour across several external systems.
Key takeaways
- Kafka is a distributed log for streaming events at high volume.
- Topics, partitions, brokers, producers and consumers are its core ideas.
- Consumers read independently and can replay events from the log.
- It excels at real-time pipelines and event driven systems, not simple queues.
- Plan partitions, schemas, security and monitoring from the start.
Quick glossary
| Term | Meaning |
|---|---|
| Topic | A named stream of events |
| Partition | An ordered slice of a topic |
| Offset | A consumer position in a partition |
| Consumer lag | How far a consumer is behind the latest event |
| Kafka Connect | A framework for moving data in and out of Kafka |
Read next: What Is Data Lineage? Types, Tools and Implementation · What Is Data Fabric? Architecture, Benefits and Limits · What Is a Data Product? Definition, Contracts and Design
Frequently asked questions
What is Apache Kafka used for?
Kafka is used to stream events between systems in real time, for pipelines, analytics, event driven applications, log collection and integration between services.
What is the difference between Kafka and a message queue?
A queue usually deletes messages once consumed. Kafka retains events in a log so multiple consumers can read them independently and replay history.
What is a Kafka topic?
A topic is a named stream of events, such as orders. It is divided into partitions that spread the load across brokers.
What is a Kafka consumer group?
A consumer group is a set of consumers that share the work of reading a topic. Each partition is read by one member, which scales processing.
Is Kafka a database?
Not in the traditional sense. It stores events durably and can be replayed, but it is designed for streaming, not for flexible ad hoc queries.
Is Kafka hard to run?
Running Kafka yourself needs expertise in capacity, security and monitoring. Managed services reduce the effort considerably.
Does Kafka guarantee order?
Kafka guarantees order within a partition, not across a whole topic. Use the same key for events that must stay in sequence.
When should I not use Kafka?
Avoid it for small, simple messaging needs or request and response patterns, where a simpler queue or an API would be easier to operate.
