Explain Pulsar's segment-centric storage versus Kafka's partition-centric log, and why it matters operationally.
answer
- Kafka: partition = pinned whole log
- Pulsar: topic = chain of ledgers (segments)
- segments stripe across bookies
- new bookie used instantly, no copy
- more metadata, fan-out reads
basics
~20 sIn Kafka a partition's whole log lives on the broker that leads it, so the partition is the storage unit. In Pulsar a topic is a sequence of small segments (BookKeeper ledgers) spread across many bookies, so no single node holds the whole topic.
solid answer
~50 sKafka is partition-centric: a partition is one contiguous log pinned to its leader broker (and replica brokers). The partition is both the unit of parallelism and the unit of storage, so a partition can't outgrow a single broker's disk, and rebalancing or expanding it means copying the whole log. Pulsar is segment-centric: a topic-partition is a chain of BookKeeper ledgers (segments); each new segment can be placed on a different set of bookies. The topic's data is therefore striped across the whole bookie cluster — no node owns the full topic. Operationally this means: (1) topic size isn't bounded by one node's disk; (2) when you add a bookie, new segments immediately use it — no rebalance/copy of old data; (3) recovery re-replicates only affected segments, not whole partitions. The cost is more metadata (every ledger tracked) and reads that may fan out across bookies.
go deeper
Grasp the headline: Kafka pins a whole partition to a broker; Pulsar breaks a topic into segments spread over storage nodes.
Explain that adding storage is copy-free in Pulsar and that recovery is per-segment, not per-partition.
Reason about disk-bound partitions, fast broker replacement, skew, and the metadata-store cost of many ledgers.
Weigh segment-centric elasticity against operational complexity and decide when the copy-free scaling is worth the extra storage-tier and metadata machinery.
**Definitions first.** - A **partition** in Kafka is an ordered, append-only log of messages identified by offsets. It has a leader broker and follower replicas; physically it is a directory of *segment files* (e.g. `0000…000.log`) — but crucially all those segment files for a partition live together on each broker that hosts that partition. - A **ledger** in Pulsar/BookKeeper is an append-only sequence of *entries* (BookKeeper's name for records). A ledger is the unit of storage placement: when it is created, BookKeeper chooses an *ensemble* of bookies to hold it. **Kafka — partition-centric.** The partition is the atom. The leader broker holds the entire partition log on its disk; replicas hold full copies. Therefore: - The whole partition must fit on one broker's disk (you can't stripe one partition across brokers). - Parallelism is bounded by partition count, and storage is bounded per-partition by one disk. - Moving a partition (reassignment, scaling out, replacing a broker) copies the entire log over the network — a heavy, throughput-affecting operation. **Pulsar — segment-centric.** A topic-partition in Pulsar is a *managed ledger*: a logically ordered chain of ledgers (segments). Pulsar rolls over to a new ledger periodically (by size, time, or on broker ownership change). Each new ledger gets a fresh bookie ensemble chosen by BookKeeper's placement policy. Consequences: - The topic's bytes are spread (striped) across the entire bookie cluster over time. No single bookie holds the whole topic, so a topic can be far larger than any one node's disk. - **Adding capacity is instant and copy-free:** a new bookie starts receiving newly created ledgers immediately; existing data is never moved to 'rebalance'. Contrast Kafka, where adding a broker means reassigning partitions and copying logs. - **Recovery is segment-scoped:** if a bookie dies, only the ledgers whose ensemble included it are under-replicated; BookKeeper's auto-recovery re-replicates just those ledger fragments to restore the *ack quorum*, rather than rebuilding whole partitions. - **Reads/tailing** are served by the broker from a write cache or by fetching entries from bookies; a long historical read can fan out across many bookies (good for parallel IO, but more connections/metadata). **Why it matters — concrete scenarios.** 1. *Sudden retention bump or a huge backlog.* In Kafka a backlogged partition can fill its leader's disk and you cannot spread it; in Pulsar the growing topic keeps allocating new segments on whichever bookies have room. 2. *Fast broker replacement.* Because brokers are stateless and storage is segmented, replacing a Pulsar broker doesn't move data. Replacing a Kafka broker means re-replicating its partitions. 3. *Skew.* Kafka can get hot/large partitions stuck on one broker; Pulsar avoids single-node topic-size skew but can still get *throughput* skew if one topic's traffic concentrates on the brokers that currently own it. **Costs / edge cases.** Segment-centric design multiplies metadata: every ledger has an entry in the metadata store, so very high topic/ledger counts pressure ZooKeeper/etcd. Placement policies (rack-aware, region-aware) must be configured or ensembles can land badly. And because data is striped, a historical replay touches many bookies — beneficial for parallelism but it means read latency depends on the slowest bookie in the ensemble for each entry (mitigated by BookKeeper's *speculative reads*).
- Why can a single Pulsar topic exceed any one node's disk capacity while a Kafka partition cannot?A Kafka partition's full log lives on its leader (and replica) brokers, so it's bounded by one disk. A Pulsar topic is a chain of ledgers, each placed on a different bookie ensemble, so its bytes stripe across the whole bookie cluster — no node holds the whole topic.
- What new operational pressure does segment-centric storage introduce that partition-centric storage doesn't?Metadata volume. Every ledger/segment is tracked in the metadata store (ZooKeeper/etcd). Very high topic and ledger counts increase metadata-store load and can become a scaling bottleneck distinct from raw data throughput.
saying these in an interview costs you the question
- Claiming Pulsar stripes a single topic across bookies but somehow keeps it on one broker
- Saying Kafka can split one partition across multiple brokers
- Ignoring the metadata-store cost of many ledgers
- Asserting Pulsar never needs any rebalancing of load (throughput skew still exists)