← all systems · see it in The System
Event streaming: the distributed log
| boundary | Inside: the topics and their partitioned logs (segment files, offsets, indexes), the brokers that keep and replicate them, the controller and group and transaction coordinators, and the client libraries producers and consumers link in (src:kreps-2011; src:kafka-docs-design). Outside: the applications that produce and consume, the databases and indexes fed from the log, the stream processors that run on it, the coordination service it used (ZooKeeper), and the machines, operating systems and networks it runs on. The broker does not know what a payload means: 'A message is defined to contain just a payload of bytes' (src:kreps-2011). |
| nested level | Built from brokers, partitions, segment files, offsets, replicas and coordinators; carried by computers, operating systems (page cache, sendfile) and networks; embedded in organizations' data infrastructure, where it sits between the systems that make data and those that use it ('a central log for real-time subscription', src:kreps-2013-log). Stream processing (Kafka Streams, Samza, Storm, Flink, the Dataflow model) runs on it. |
| scale | technological |
From the walk
The New York Times keeps all the text it has published since the paper's founding in 1851 in a single, ordered Kafka log, and its search index, cached pages and reader notifications are all fed by reading that one log (src:kleppmann-2019).
Definition. Producers append records to a durable, ordered, partitioned log kept by a cluster of brokers, and many readers each read it at their own position (offset); in Kreps's words a log is 'an append-only, totally-ordered sequence of records ordered by time', and Kafka, its reference system, is 'a distributed event store and stream-processing platform'. Definition drawn from the encyclopedia entries listed under Sources (Wikipedia, CC BY-SA).
On this page: Properties 2 · Measures 35 · Open contentions 4 · Cross-scale patterns 25 · Valence partners 16 · Partners and parts 70 · Notes 4 · Layers 83 · Sources 26
Properties published scienceour proposal
Sourced fields, and our own readings.
| born at | 2010 (implemented at LinkedIn); open-sourced January 2011; Apache top-level project October 2012 |
| born precision | year |
Measures (35) published science
| characteristic clock: end-to-end pipeline latency (LinkedIn 2011) | about 10 s |
| characteristic clock: wait for a committed write | on the order of 10 ms |
| characteristic clock: retention period (typical, 2011) | 7 days |
| characteristic clock: Kafka Streams commit interval (benchmark setting) | 100 ms |
| characteristic clock: KafkaSpout offset checkpoint to ZooKeeper (Twitter default) | 2 s per partition per topology |
| segment file size (example) | about 1 GB |
| producer throughput, batch 1 (one broker, 2011) | 50000 messages/s |
| producer throughput, batch 50 (one broker, 2011) | 400000 messages/s |
| consumer throughput (one consumer, 2011) | 22000 messages/s |
| storage overhead per message | 9 (Kafka) against 144 (ActiveMQ) bytes |
| data copies per message sent to a consumer | 4 copies and 2 system calls; sendfile avoids 2 copies and 1 call |
| messages per day (LinkedIn 2011) | close to a billion messages/day |
| storage per production Kafka server (LinkedIn 2013) | up to 5 TB |
| linear against random disk writes | about 600 MB/s against about 100 kB/s (over 6000x) bytes/s |
| cost of fsync on every write | two to three orders of magnitude slower ratio |
| throughput gain from batching, broker stage | 51.7x (producer 3.2x, consumer 20.1x) ratio |
| consumer latency when reading from cache, at least once with replication | 1 ms median, 30 ms 99.9th percentile |
| consumer latency when reading from disk | around 100 ms |
| throughput cost of exactly-once against at-least-once (Kafka Streams test) | about 10 to 20 percent |
| exactly-once overhead at Bloomberg | 6 to 10 percent |
| Bloomberg MxFlow scale | 160 cores, 2 TB RAM, more than one billion market records a day |
| Jepsen 2013: acknowledged writes lost under a partition | 520 of 987 acknowledged (1000 attempted) writes |
| share of ZooKeeper writes made by KafkaSpout (Twitter) | 67 percent |
| network-partition failures studied | 136 failures in 25 systems; 88% triggered by isolating one node; 21% leave lasting damage |
| ZooKeeper capacity (target workloads) | tens to hundreds of thousands transactions/s |
| sustainable throughput, Flink windowed aggregation | 1.2 million events/s (2, 4 and 8 nodes) |
| replicas needed to tolerate F failures | F+1 (primary-backup, Kafka's ISR) against 2F+1 (majority quorum) replicas |
| default min.insync.replicas | 1 replicas |
| default producer acks | all |
| default log.flush.interval.messages | 9223372036854775807 (the largest long: no count-based forced flush) messages |
| default auto-commit interval | 5000 ms |
| characteristic clock: broker heartbeat interval (KRaft default) | 2000 ms |
| KRaft controller metadata provisioning (typical cluster) | 5 GB memory and 5 GB disk |
| controllers needed to tolerate f failures (KRaft) | 3 tolerate 1; 5 tolerate 2 controllers |
| quota measurement windows (example) | 30 windows of 1 second each |
Open contentions (4) open contention
Where sources or readings disagree. Both stay on the map.
- C-4587 When a program reading from Kafka (a system that stores streams of messages) records its place automatically, can messages be lost after a crash?
booked: The map keeps both readings side by side and rules on neither.
the other reading: auto-commit commits offsets of the latest poll and can lose messages on a crash (Confluent documentation as quoted by src:kingsbury-2024); auto-commit commits the penultimate poll's offsets, so it does not lose data; clients differ (readers and Buf as reported by src:kingsbury-2024, which withdrew its claim: 'more research is warranted'); unsourced, the specialist's: the Java consumer commits inside poll() the position the previous poll reached, so auto-commit is at-least-once when each batch is finished before the next poll and can lose records when they are handed to another thread; both readings hold under different application structures. The consumer documentation read says only 'periodically committed in the background' (src:kafka-docs-consumer-configs) - C-4588 Can a messaging system really deliver each message exactly once, or is that always 'at least once' with duplicates filtered out?
booked: The map keeps both readings side by side and rules on neither.
the other reading: the Kafka transaction protocol, with the official Java client, allows lost writes, aborted reads and torn transactions under process pauses (KAFKA-17754), and write cycles (G0) at read_committed (src:kingsbury-2024; src:kingsbury-2022); exactly-once is two different promises, 'on state' and 'on output'; output to external stores stays at-least-once without a heterogeneous atomic commit (src:fragkoulis-2023; src:kleppmann-2019); 2011: exactly-once needs two-phase commit and was not needed; applications de-duplicate (src:kreps-2011); opt-in on both ends: consumers default to read_uncommitted, which returns aborted transactional messages (src:kafka-docs-consumer-configs); the booked guarantee needs a transactional producer and read_committed consumers - C-4589 For keeping copies of data safe across servers, is Kafka's way of choosing which copies count as good as the usual majority-vote way?
booked: The map keeps both readings side by side and rules on neither.
the other reading: majority quorums are provably optimal in availability for small replica counts; letting the ISR shrink to one node lost acknowledged writes (src:kingsbury-2013); the two need the same number of acknowledgements to survive f failures; majority avoids waiting on the slowest server (src:kafka-docs-design); both: Kafka runs a majority quorum for metadata (ZooKeeper, then KRaft's Raft controllers: 'A majority of the controllers must be alive') and ISR primary-backup for data (src:wang-2015; src:kafka-docs-kraft); with replication factor 3 and min.insync.replicas 2 'a majority of replicas must persist a write' (src:kafka-docs-broker-configs); the disagreement is about the default (min ISR 1); any ISR member can lead 'without consent from the majority' (src:alagappan-2016) - C-4590 Is a stored message log such as Kafka a kind of message queue, or a different thing that sits beside queues?
booked: The map keeps both readings side by side and rules on neither.
the other reading: a message queue: 'Kafka is the most popular message-queueing system' (src:alquraan-2018); 'a topic is like a queue' (src:toshniwal-2014); a kind of publish/subscribe system (src:dobbelaere-2017; src:wang-2015), which itself is 'a sibling of the message queue paradigm' (src:wp:publish-subscribe-pattern); since 2025 both: share groups add queue semantics to Kafka (src:kafka-docs-design; src:wp:apache-kafka)
Cross-scale patterns seen here (25) our proposal
Shapes that recur when the same kind of problem is solved at different scales, and how each shows in Event streaming: the distributed log. Each links to every other system that shows it.
- borrowed-then-held (structural)
Coordination first borrowed, then held: in 2011 ZooKeeper kept the consumer and broker registries, ownership and offsets; 'Around v0.8.2, consumer management was transferred from Zookeeper to a coordinator inside the broker' (src:dobbelaere-2017), offsets became appends to an internal topic (src:wan - causal ceiling (structural)
No reader can know it has seen all the data: 'we will never know if or when we have seen all of our data' and the system 'lacks sufficient knowledge to establish a 100% correct watermark' (src:akidau-2015); a producer 'cannot be sure if this error happened before or after the message was committed' - holding / entrainment (structural)
The group decides which member reads which partition, re-divides on joins and deaths, and fences 'zombie' members by epoch so only one instance per transactional id may write (src:wang-2021; src:kreps-2011). - same role, different builds (structural)
One job, different builds: durability by fsync to disk (RabbitMQ confirms) or by copies on several machines without fsync (Kafka, src:dobbelaere-2017); knowing what was consumed kept by the broker (queues) or by the consumer as one integer (Kafka, src:kafka-docs-design); exactly-once by barrier snap - symmetry breaking (name the cut) (structural)
Concurrent writes have no order until the leader appends them: 'the simplest and fastest is with a leader who chooses the ordering of values provided to it' (src:kafka-docs-design); the key hash cuts a topic's records into partitions. The cut is named: the leader's append. - templating (structural)
One module swapped and still working: 'a standardized binary message format that is shared by the producer, the broker, and the consumer' (src:kafka-docs-design); Redpanda and Bufstream speak Kafka's wire protocol and run with regular Kafka clients ('Redpanda uses regular Kafka clients', src:kingsbu - The carry (structural)
All three faces: overflow passed on ('the excess data is simply buffered persistently in the repartition topic', src:wang-2021); the wait (read_committed consumers wait for the commit marker, so latency grows with the commit interval; lag grows when production outruns consumption, src:landau-2022); - The Payment to Entropy (structural)
Every hand-off pays: 9 bytes of framing per message (efficiency 200/209 = 0.957 for a 200-byte message; ActiveMQ 200/344 = 0.58, src:kreps-2011); 4 data copies per read without sendfile; exactly-once costs 10-20% of throughput (src:wang-2021); in 2013 a partition turned 987 acknowledged writes into - the whole sets the local reference (structural)
Each partition has its own total order and each group its own offset per partition, but 'there is no guarantee on the ordering of messages coming from different partitions' (src:kreps-2011): local orders that do not close into one global order. The whole also sets what readers may see: the last stab - trade one property for another (structural)
Durability for throughput (acks, no fsync: 'it is desirable to trade durability for throughput', src:kreps-2011); latency for throughput (batching, commit intervals, src:wang-2021); consistency for availability (unclean leader election, min ISR, src:kafka-docs-design); order for parallelism (partiti - who opens the door (structural)
Every door is opened by the receiver ahead of time: a consumer subscribes and pulls from its own position ('the consumer always pulls all available messages after its current position', src:kafka-docs-design); a group's member is assigned a partition before records reach it; a producer reaches a lea - barrier-gates-complexity (partial)
Transaction markers and read_committed isolation hide aborted and open transactions; with the barrier lowered (read_uncommitted) consumers 'may read values written by transactions which actually aborted' (src:kingsbury-2024). The without-the-barrier case is shown for correctness; that exactly-once p - lightning (partial)
A stored difference released at once: an ISR shrunk to the leader stores writes on one node; when the leader loses ZooKeeper, an election throws them away in one step ('two well-timed failures ... can cause the loss of arbitrary writes', src:kingsbury-2013). Partial: since 0.11 the default waits (th - namespace completeness (the map predicts its gaps) (partial)
The total order predicts its own gaps: fault testers build a dense order of each partition's values and call a record lost when a higher index was polled: 'it should be impossible to poll index n unless some poller has already seen index n − 1' (src:kingsbury-2024). Gaps with predicted properties (a - nested ladder (partial)
Delivery promises as a ladder: at most once (no duplicates), at least once (no loss), exactly once ('guarantees no-loss and no-duplicates', src:dobbelaere-2017); the producer's acks 0, 1, all; read_uncommitted below read_committed. The order splits at the bottom: at-most-once and at-least-once are n - outside-to-inside (partial)
Readers' positions kept outside first (2011: a persistent ZooKeeper path, 'The offset registry stores for each subscribed partition, the offset of the last consumed message'), inside later (appends to an internal Kafka topic, src:wang-2021). The outside phase comes first. The reverse is also seen: t - red-queen (partial)
An attack-defend loop between outside fault testers and Kafka's designers, at least one full turn shown: 2013 partition test loses acknowledged writes; Kafka adds min.insync.replicas and makes unclean election off by default (0.11); 2022 and 2024 tests find write cycles, aborted reads and torn trans - same shape, opposite sign (partial)
One transfer of a batch from broker to reader, with the initiative reversed: push (Scribe, Flume: 'the broker forwards data to consumers') against pull (Kafka: the consumer asks from its offset) (src:kreps-2011). Second sighting: the database's internal log turned outward into a shared external log - same toolkit, independent builds (partial)
The same parts (a replicated log, a leader, a quorum service) built into separate systems: Kafka's ISR with ZooKeeper, Redpanda's Raft, Bufstream's etcd and object store, CORFU, PacificA (src:wang-2015, src:kingsbury-2022, src:kingsbury-2024). Partial: these systems cite one another, so shared ances - seed (partial)
The log as a small abstraction that unpacks many systems: replication, data integration, stream processing, event sourcing and 'a lego version of distributed data system engineering' ('You can piece these ingredients together to create a vast array of possible systems', src:kreps-2013-log). Partial: - Umwelt: each system carves its own slice of one shared medium (partial)
Each part carves its own slice of one stream: the broker sees only bytes ('A message is defined to contain just a payload of bytes', src:kreps-2011) and no consumer progress; Bufstream can 'introspect Protocol Buffer records' (src:kingsbury-2024); each consumer group sees its own offsets; Flink and - cephalization (surface)
Every write meets the partition leader first, and ordering is concentrated there ('All writes go to the leader of the partition', src:kafka-docs-design). Surface: the leader is placed by election and balancing, not because it meets input first. - conservation law plus closure (surface)
The at-least-once guarantee leaves duplicates open and needs a second rule to close it: 'If an application cares about duplicates, it must add its own deduplication logic' (src:kreps-2011), later closed in the broker by idempotent sequence numbers. Surface: a guarantee plus a fix, not a balance law - not-diluting wins (surface)
In a compacted topic the latest value per key is always kept while older updates are purged, so over time the log is made of latest values (src:kafka-docs-design). Surface: it is a retention rule, not one component holding its density as others thin. - partner-becomes-part (surface)
ZooKeeper, a separate system Kafka partnered with, saw its jobs taken inside the broker; but ZooKeeper itself did not fuse into Kafka. Surface: a role moved inside, the partner did not become a part.
Valence: what it trades, and with whom (16) published science
Each exchange with a neighbour, read from both sides: who gains, who pays, and what carries it.
- Write-ahead logging via Written record (durable external marks: texts, archives, canon) · Event streaming: the distributed log gain
- Message queue and work queue via Written record (durable external marks: texts, archives, canon) · Event streaming: the distributed log mixed
- Human (Homo sapiens) via The world through the senses (sensory environment) · Event streaming: the distributed log gain
- Software via Written record (durable external marks: texts, archives, canon) · Event streaming: the distributed log gain
- Operating system via Computer hardware · Event streaming: the distributed log gain
- Organization via Human society (from local community up to societies) · Event streaming: the distributed log gain
- Computer hardware via Computer hardware · Event streaming: the distributed log gain
- Database via Written record (durable external marks: texts, archives, canon) · Event streaming: the distributed log gain
- Data warehouse via Written record (durable external marks: texts, archives, canon) · Event streaming: the distributed log gain
- Computer network via Computer network · Event streaming: the distributed log mixed
- Cloud computing via Computer hardware · Event streaming: the distributed log gain
- Fraud via Written record (durable external marks: texts, archives, canon) · Event streaming: the distributed log gain
- Byzantine fault via Computer network · Event streaming: the distributed log even
- Stream processing via Written record (durable external marks: texts, archives, canon) · Event streaming: the distributed log gain
- ZooKeeper (coordination service) via Computer network · Event streaming: the distributed log gain
- Fault-injection testing (Jepsen and partition studies) via Written record (durable external marks: texts, archives, canon) · Event streaming: the distributed log gain
Partners and parts published science
Built from / builds (10)
- Broker
- Topic partition (a logical log of segment files)
- Offset
- Consumer group
- In-sync replica set (ISR)
- Controller
- Transaction coordinator and transaction log
- Producer client
- Consumer client
- Distributed logs, message queues and log aggregators competing to carry organizations' data
Sits inside / holds (3)
expressed by (26)
- Generation/Synthesis
- Recombination/Composition
- Scaffolding/Enablement (Meta-Tooling)
- Templating / Standardization
- Interoperability/Transduction (Bridging)
- Encapsulation & Modularity (Abstraction)
- Amplification/Scale-Up (Manufacture & Distribution)
- Evolvability/Plasticity Engineering (Design for Future Variation)
- Distributed Autonomy/Decentralized Execution (Subsidiarity)
- Internal Coordination/Regulation
- Sensing/Scanning
- Mapping/Modeling
- Navigation/Pathfinding
- Trail-Marking / Externalized Memory (Stigmergy)
- Reactive Response
- Proactive Defense
- Physical/Virtual Barrier
- Self-Monitoring
- Validation of Identity/Intention
- Validation of Effectiveness
- Enclave/Segregation
- Resilience & Repair
- Redundancy & Diversity
- Quality Control & Error Correction
- Positional Identity (Body Map)
- Bridging Supply Gaps (Store & Dormancy)
floor filled by (20)
- Human (Homo sapiens)
- Operating system
- Organization
- Computer hardware
- Database
- Data warehouse
- Computer network
- Broker
- Topic partition (a logical log of segment files)
- Offset
- Consumer group
- In-sync replica set (ISR)
- Controller
- Transaction coordinator and transaction log
- Producer client
- Consumer client
- Stream processing
- ZooKeeper (coordination service)
- Log compaction
- Segment file
Kinds (11)
- Message oriented middleware
- NATS JetStream
- Apache Kafka
- Kafka share group
- Redpanda
- Bufstream
- CORFU
- Apache Pulsar
- LogDevice (Facebook)
- Amazon Kinesis
- Yahoo! Message Broker
Notes published science
- The New York Times keeps all the text it has published since the paper's founding in 1851 in a single, ordered Kafka log, and its search index, cached pages and reader notifications are all fed by reading that one log (src:kleppmann-2019).
- In a 2013 test, an early version of Kafka's replication said yes to 987 of 1,000 writes, then, after a network cut and a leader election, lost 520 of those acknowledged writes. Kafka later added a setting that refuses writes when too few copies are in sync and made the safer leader election the default; the minimum-copies setting still defaults to 1, so the safe set-up is the operator's choice (src:kingsbury-2013; src:kafka-docs-design; src:kafka-docs-broker-configs).
- At Twitter, two-thirds of all writes to the shared coordination service came not from the stream processor itself but from one library noting how far each reader had got in Kafka, every 2 seconds per partition (src:toshniwal-2014).
- A single flipped bit in one copy of a Kafka log could, in 2017 tests, become data loss for the whole cluster: the damaged machine treated the corruption as an interrupted write, cut off its log, stayed eligible to lead, and told the healthy copies to cut theirs too (src:ganesan-2017).
Layers
The ways it takes in its world, where they meet, and how it acts back, each from L1 (where it meets the world) up.
the boardroom (shared floors)
- L4: The partitioned log: topics, partitions, segment files, offsets, retention and compaction; reads and writes are sequential
- L5: Replication and coordination: leader and followers per partition, the ISR, commit when all ISR members have a record, the controller and leader election (ZooKeeper, later a built-in controller)
- L6: The consumption contract: groups, assignment, rebalancing, committed offsets, delivery promises, transactions and isolation levels, order per partition
- L7: The log in use: an organization's central pipeline and source of truth, stream processing on top, replicas and views derived from it, the people who run it
the event stream as distributed-systems engineers describe it: things happening in the world written down as records, up to the organizations and programs that run on the log (reader's view)
- L1: The world the records come from: user activity (logins, page views, clicks, likes, searches), operational metrics, database changes, market data, sensor readings; each a thing that happened, at an event time
- L2: The clients: producers serialize records (Avro with a schema id), batch them into message sets and choose the partition (at random or by hashing a key); consumers iterate over message streams
- L3: The wire and the broker's front door: a binary TCP protocol of produce and fetch requests sent straight to the partition leader; one binary format shared by producer, broker and consumer; sendfile from page cache to socket
- L4: The partitioned log: topics split into partitions, each an append-only ordered log of segment files; records addressed by offset; an in-memory offset index; retention by time or size, key-based compaction
- L5: Replication and coordination: each partition has a leader and followers; the in-sync replica set (ISR); a write is committed when all ISR members have it; a controller elects leaders from the ISR. In ZooKeeper mode the controller was a broker (the 'broker controller') with metadata in ZooKeeper; in KRaft mode a quorum of controllers keeps the metadata as a Raft-replicated log, a majority of them alive for availability
- L6: The consumption contract: consumer groups and the assignment of partitions to members, rebalancing, the committed offset each group keeps, delivery promises (at most once, at least once, exactly once with idempotent and transactional appends), order within a partition only
- L7: What the log is for: the organization's data integration hub and source of truth ('a central log for real-time subscription'), stream processing on top (Kafka Streams, Samza, Storm, Flink, the Dataflow model), event-driven applications, database and index replicas, warehouse loads, and the people who build and run them
the replicated partition on the brokers: disks and page cache up to the controller that elects leaders
- L1: Disks and the operating system's page cache on each broker: data written to the page cache and flushed later; no fsync per write; with tiered storage (off by default) completed segments move to a remote tier such as HDFS or S3, while tail reads stay in the page cache
- L2: Segment files and the per-message CRC; recovery removes messages with inconsistent CRCs after an I/O error
- L3: The leader's log and the followers that fetch from it like consumers, batching what they apply
- L4: The ISR and the commit point: followers that fall behind more than replica.lag.time.max.ms are dropped; min.insync.replicas sets a floor
- L5: The controller: broker registration and liveness, leader election from the ISR, batched leadership changes; unclean leader election off by default since 0.11; from 4.0, Eligible Leader Replicas let some non-ISR replicas be elected safely (default on for new clusters from 4.1)
way in: Brokers' sessions and heartbeats (liveness)
- L1: broker processes that may crash or be cut off
- L2: periodic heartbeats to the controller (KRaft); earlier, ephemeral ZooKeeper nodes removed when a session ends
- L3: a missed heartbeat within broker.session.timeout.ms marks the node offline
- L4: the broker registry: which brokers hold which partitions
way in: Consumers joining, leaving and heartbeating in their groups
- L1: consumer processes started, stopped, crashed, redeployed
- L2: a consumer registry (2011: ZooKeeper; later: the group coordinator in the broker); from 4.0 (opt-in on the client) the broker also computes the assignment
- L3: a watcher or coordinator notices the change
- L4: membership known: who subscribes to which topics
- L5: group state stored and replicated like other internal topics
way in: Database change feeds (change data capture)
- L1: a write commits in a data store (Espresso, MySQL, an OLTP database)
- L2: an embedded producer publishes the store's change log, one topic per table partitioned by shard
- L3: sent to the local Kafka cluster
way in: Faults arriving from outside: crashes, process pauses, clock skew, network partitions
- L1: network partitions, as often as weekly in production networks; pauses and crashes
- L2: a partition looks like a crash: unreachability is read as failure
- L3: writes to a cut-off follower time out; the leader drops it from the ISR
- L4: the ISR shrinks, possibly to the leader alone
way in: Fetch requests from consumers, each carrying the offset to read from
- L1: a consumer application wants the records after its position
- L2: a pull request naming the offset and an acceptable number of bytes; long poll when no data
- L3: the broker finds the segment through its in-memory sorted list of offsets
way in: Follower replicas fetching from the leader
- L1: brokers hosting follower replicas of a partition
- L2: followers send fetch requests like ordinary consumers
- L3: batches copied over the network into the follower's log
- L4: the leader tracks how far each follower has caught up
way in: Offset commits: each group's record of how far it has read
- L1: a consumer has processed records up to some offset
- L2: a commit request (or automatic commit) for the group's position
- L3: 2011: written to a persistent ZooKeeper path; later sent to the broker
- L4: appended to an internal Kafka topic
- L5: replicated like any partition
way in: Operators' and developers' settings (acks, min.insync.replicas, unclean leader election, retention, isolation level)
- L1: people weighing durability against availability and latency
- L2: per-topic and per-client configuration properties
- L3: dynamic settings stored in the metadata log and taken up by brokers without restart (since 1.1); read-only settings need a restart
- L4: retention set per topic: by time or size, or by compaction
way in: Records from producers (activity events, metrics, application events)
- L1: something happens: a page view, a click, a call's latency, a market tick
- L2: the producer client serializes, batches up to a size or latency bound and picks the partition
- L3: a produce request over TCP to the leader; the message set kept in one shared binary format
way in: The disks' and page cache's own state (I/O errors, corrupt messages, cache hits and misses)
- L1: disks and page cache; disks fail and 'often do not leave data intact'
- L2: per-message CRC checked; an I/O error starts a recovery that drops messages with bad CRCs
- L3: reads served from page cache when consumers are caught up, from disk when they lag
way in: Time: record timestamps, retention clocks, session and lag timeouts
- L1: event time (when it happened) and processing time (when it is seen); clocks are not assumed synchronized
- L2: each record carries a timestamp producers may set to event time
- L3: time-based retention (typically 7 days) and timeouts on sessions and replica lag
way in: Transactional producers' control requests (register id, add partitions, commit or abort)
- L1: a read-process-write cycle that must take effect once
- L2: the producer registers its transactional id; the coordinator bumps the epoch
- L3: AddPartitionsToTxn and EndTxn requests travel separately from data and may be reordered
- L4: the coordinator writes transaction state to the transaction log topic
- L5: the transaction log is replicated; a new leader rebuilds coordinator state by replay
way out: Acknowledge producers (acks 0, 1 or all)
- L2: the producer frees the batch, or retries on error (idempotently since 0.11)
- L3: the produce response returns the offset
- L5: commit when all ISR members have the write (acks=all), or ack at once (0) or after the leader (1)
way out: Assign partitions to the members of a group (rebalance)
- L2: each consumer starts a thread pulling its partitions from the stored offset
- L6: partitions divided among the group's consumers; on a clash a consumer releases all and retries (2011 ZooKeeper protocol; since 4.0 an incremental protocol with server-side assignors, opt-in)
way out: Copy the leader's log to followers
- L1: into the followers' page cache and disks
- L4: followers append the same records at the same offsets
- L5: the leader serves followers' fetches
way out: Deliver records to consumers (fetch responses)
- L1: the application acts: updates an index, a cache, a recommendation, a dashboard
- L2: the consumer's iterator hands records to the application, blocking when none are left
- L3: sendfile sends it to the socket without the two extra copies
- L4: the broker reads the chunk from page cache or disk
- L6: only committed messages are given out; read_committed consumers also skip aborted transactions
way out: Derived streams, views and replicas written back into the world
- L1: a search index, a database, a cache, a warehouse, a push notification, a price
- L2: an embedded producer appends results, changelogs and repartitioned streams
- L6: read-process-write cycles, committed together with their input offsets
- L7: stream processors and subscribers turn the log into derived feeds and materialized views
way out: Fence zombies: reject writes from an older epoch
- L2: writes from producers with the older epoch are rejected
- L6: the coordinator bumps the epoch for a transactional id
way out: Retire old data: delete expired segments, compact keyed logs
- L1: disk space freed
- L4: segments past the retention time or size deleted; compaction keeps the last value per key and swaps cleaned segments in