Apache Pulsar
medium 28 minApache Pulsar separates serving from storing: brokers talk to clients and keep no data of their own, Apache BookKeeper stores each topic as many small replicated segments.
See it run
Publish to two bookies, lose a broker without copying data, and see which ledgers may be deleted.
Operations
One publish
The broker owns the topic, the bookies keep the message.
Step 1 of 4
Send
The producer looked up the owner of the topic and sends to broker 1.
Step 1: Send
entry = next_entry()for bookie in write_quorum(entry): bookie.append(ledger, entry, data)wait_for(ack_quorum)confirm(producer)- Delay
- Two hops and a disk write
- Protects
- Two copies
- Broker with its own disk
- one hop less, data is tied to it
With three copies and an ack quorum of two, one slow bookie does not delay you.
In the real world
The same apache pulsar doing real jobs. Pick one and step through it.
A test consumer ran once and never came back.
Step 1 of 3
One test
- Backlog of mail
- 4%
- Backlog of test
- 10%
- Bookie disk
- 30%
Somebody subscribed with the name test and stopped the program.
Step 1: One test
Common mistakes
The bugs interviewers watch for, with the fix beside each.
No subscription before the first message
criticalWithout a subscription and without retention, nothing is kept.
Wrongproducer.send(msg) # consumers come laterRightcreate the subscription firstor set-retention on the namespaceKey_Shared with default batching
criticalA batch is routed by its first key, so other keys reach the wrong consumer.
Wrongcreate_producer(topic)Rightcreate_producer(topic, batching_type=BatchingType.KeyBased)Trusting negative acks for dead letters
majorThe counter is in memory and resets when the topic moves.
Wrongconsumer.negativeAcknowledge(msg)RightenableRetry(true)consumer.reconsumeLater(msg, 30, SECONDS)Leaving test subscriptions behind
majorA durable subscription holds every ledger until it is deleted.
Wrongsubscribe(topic, "test") # and forget itRightpulsar-admin topics unsubscribe --subscription test TOPIC
Interview tips
How to explain it
- Brokers serve, bookies store.
- A topic is a chain of ledgers.
- A new owner opens a new ledger.
Memory trick
- The desk speaks.
- The vault remembers.
- Sealed tapes never move.
Reach for it when
- Many tenants share a platform.
- The same events feed queues and streams.
- Regions must replicate.
Be careful when
- Nobody can operate three layers.
- You rely on the Kafka ecosystem.
- Subscriptions are not cleaned up.