Overview

Apache Kafka is an open-source, distributed streaming platform that facilitates the building of real-time data pipelines and streaming applications. Developed at LinkedIn and open-sourced in 2011, Kafka is designed to handle high volumes of data with low latency and high fault tolerance. Its core architecture revolves around a distributed commit log, which allows producers to send messages (records) to topics and consumers to read messages from those topics. This design enables Kafka to serve as a central nervous system for data, connecting various applications and systems.

Kafka is primarily used for three key capabilities: publishing and subscribing to streams of records, storing streams of records in a fault-tolerant durable way, and processing streams of records as they occur. It is well-suited for scenarios requiring real-time data ingestion, such as collecting user activity data, aggregating application logs, and managing sensor data from IoT devices. The platform's distributed nature allows it to scale horizontally, processing millions of events per second across multiple servers.

Developers and technical buyers utilize Kafka to implement robust data architectures. For instance, it can underpin microservices communication, where services exchange messages asynchronously, enhancing system decoupling and resilience. Another common application is stream processing, where data is transformed or analyzed in real time using components like Kafka Streams or external stream processing frameworks. Its ability to durably store data streams for a configurable period also makes it suitable for replaying events, supporting disaster recovery, and enabling retrospective analysis.

While Kafka provides the fundamental components for distributed streaming, its operational complexity can be a consideration. Setting up, managing, and scaling a Kafka cluster often requires specialized expertise in distributed systems and infrastructure management. Organizations frequently deploy Kafka in conjunction with other tools for monitoring, security, and schema management to build a complete streaming ecosystem. For example, commercial offerings like Confluent Platform provide additional tools and services to simplify Kafka deployments and operations.

Key features

  • Publish-Subscribe Messaging: Enables producers to send messages to topics and consumers to subscribe to topics, facilitating decoupled communication between applications.
  • Distributed and Scalable Architecture: Designed to run as a cluster of brokers, allowing horizontal scaling to handle high data volumes and throughput.
  • Fault Tolerance: Replicates data across multiple brokers to ensure data availability and durability even if a broker fails.
  • Durability: Persists message logs to disk, providing configurable retention periods for historical data access and replay capabilities.
  • High Throughput: Optimized for high-performance data ingestion and processing, capable of handling millions of messages per second.
  • Kafka Streams API: A client library for building stream processing applications that transform and analyze data stored in Kafka topics.
  • Kafka Connect: A framework for connecting Kafka with external systems such as databases, key-value stores, search indexes, and file systems, simplifying data integration.
  • Client Libraries: Offers official client libraries for Java and Scala, with community-supported clients available for other languages.

Pricing

Apache Kafka is an open-source project under the Apache 2.0 License, making it free to download and use. Organizations incur costs primarily through the operational expenses associated with deploying and maintaining Kafka clusters.

Component Cost Model Details As-of Date
Software License Free Apache 2.0 License; no direct software cost. 2026-05-28
Infrastructure Variable Costs for servers (on-premises or cloud), storage, networking, and related cloud services. 2026-05-28
Operational Overhead Variable Personnel costs for setup, monitoring, maintenance, and troubleshooting. 2026-05-28
Managed Services Subscription/Usage-based Third-party providers (e.g., Confluent Cloud, AWS MSK) offer managed Kafka services with their own pricing structures. 2026-05-28

For detailed information on the open-source project, refer to the Apache Kafka homepage.

Common integrations

  • Databases: Integration with relational databases (e.g., PostgreSQL, MySQL) and NoSQL databases (e.g., MongoDB, Cassandra) via Kafka Connect for CDC (Change Data Capture) and data loading.
  • Big Data Ecosystems: Connects with Apache Spark, Apache Flink, and Apache Storm for advanced stream processing and analytics.
  • Cloud Services: Integrates with cloud object storage (e.g., Amazon S3, Google Cloud Storage) and cloud data warehouses (e.g., Snowflake, Google BigQuery).
  • Monitoring and Alerting: Tools like Prometheus, Grafana, and ELK Stack (Elasticsearch, Logstash, Kibana) are used for monitoring Kafka cluster health and performance.
  • Schema Registry: Confluent Schema Registry (often used with open-source Kafka) manages Avro, Protobuf, and JSON Schema for data governance.
  • Microservices Frameworks: Used as a messaging backbone for microservices architectures built with frameworks like Spring Boot or Quarkus.

Alternatives

  • Confluent Platform: A commercial enterprise streaming platform built on Apache Kafka, offering additional features, tools, and managed services for easier deployment and operations.
  • RabbitMQ: An open-source message broker implementing the Advanced Message Queuing Protocol (AMQP), suitable for general-purpose message queuing and smaller-scale event communication.
  • Apache Pulsar: A distributed pub-sub messaging system also designed for high-throughput, low-latency messaging, offering a unified messaging and streaming platform with built-in tiered storage.

Getting started

To get started with Apache Kafka, you typically need to set up a Kafka broker and then create producer and consumer applications. The following Java example demonstrates a basic producer sending messages and a basic consumer receiving them. This example assumes you have a Kafka broker running locally (e.g., via Docker or a local installation).

import org.apache.kafka.clients.producer.*;
import org.apache.kafka.clients.consumer.*;
import org.apache.kafka.common.serialization.StringSerializer;
import org.apache.kafka.common.serialization.StringDeserializer;
import java.util.Properties;
import java.util.Collections;

public class KafkaQuickstart {

    private static final String BOOTSTRAP_SERVERS = "localhost:9092";
    private static final String TOPIC_NAME = "my-test-topic";

    public static void main(String[] args) throws InterruptedException {
        // Start producer in a separate thread
        new Thread(KafkaQuickstart::runProducer).start();

        // Give producer a moment to send messages
        Thread.sleep(2000);

        // Start consumer in a separate thread
        new Thread(KafkaQuickstart::runConsumer).start();
    }

    static void runProducer() {
        Properties props = new Properties();
        props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
        props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());

        try (KafkaProducer<String, String> producer = new KafkaProducer<>(props)) {
            for (int i = 0; i < 10; i++) {
                String key = "key-" + i;
                String value = "hello kafka " + i;
                ProducerRecord<String, String> record = new ProducerRecord<>(TOPIC_NAME, key, value);
                producer.send(record, (metadata, exception) -> {
                    if (exception == null) {
                        System.out.printf("Sent record (key=%s, value=%s) to topic=%s partition=%d offset=%d\n",
                                key, value, metadata.topic(), metadata.partition(), metadata.offset());
                    } else {
                        exception.printStackTrace();
                    }
                });
            }
            producer.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static void runConsumer() {
        Properties props = new Properties();
        props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
        props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
        props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
        props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
        props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); // Start reading from the beginning of the topic

        try (KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props)) {
            consumer.subscribe(Collections.singletonList(TOPIC_NAME));
            System.out.println("Consumer subscribed to topic: " + TOPIC_NAME);

            while (true) {
                ConsumerRecords<String, String> records = consumer.poll(java.time.Duration.ofMillis(100));
                if (records.isEmpty()) {
                    // System.out.println("No records received. Polling again...");
                    continue;
                }
                for (ConsumerRecord<String, String> record : records) {
                    System.out.printf("Received record: Key = %s, Value = %s, Partition = %d, Offset = %d\n",
                            record.key(), record.value(), record.partition(), record.offset());
                }
                // For demonstration, break after receiving some records. In real apps, this loop would run indefinitely.
                if (!records.isEmpty()) {
                    // Optionally commit offsets manually if auto.commit is false
                    // consumer.commitSync();
                    // For quickstart, let's just break after first batch for clarity
                    // break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

This code snippet demonstrates how to configure a Kafka producer to send messages and a Kafka consumer to read messages from a specific topic. The producer sends 10 messages, and the consumer continuously polls for new messages. For more detailed guides and setup instructions, consult the official Apache Kafka documentation.