Skip to main content

Kafka-like Event Platform

1. Executive Summary​

A Kafka-like event platform is a distributed commit log providing durable, ordered, partitioned streams for publish-subscribe messaging and stream processing at millions of events per second. Principal-level design covers partition leadership, replication and ISR (in-sync replicas), consumer groups, offset management, exactly-once semantics, and tiered storage.

This chapter designs an Apache Kafka/Pulsar-class platform handling 10M+ messages/sec cluster-wide with configurable retention, at-least-once default delivery, and optional exactly-once transactions. Log segments, leader election, and rebalance protocol are mandatory interview topics.

2. Why This Topic Matters​

Event streaming is the backbone of microservices, ETL, and real-time analytics. Architects must explain:

  • Log vs queue semantics.
  • Partition ordering guarantees.
  • Consumer group rebalancing impact.
  • Replication and unclean leader election risks.
  • Backpressure and retention policies.

Failures include message loss, duplicate processing storms, and consumer lag incidents lasting hours. Review Kafka Architecture, Message Delivery Semantics, and Apache Kafka.

3. Problems Being Solved​

ProblemSolution
Durable messagingAppend-only partitioned log
High throughputSequential disk I/O; zero-copy
OrderingPer-partition order
Fan-outMultiple consumer groups
ReplayRetain log; reset offsets
Scale consumersPartition count ≥ max parallelism
Fault toleranceLeader-follower replication
Long retentionTiered storage to object store

4. Assumptions and System Model​

Functional:

  • Topics divided into partitions; producers append records.
  • Consumers in groups partition-assign consume with offsets.
  • Retention by time (7d) or size.
  • Compacted topics for changelog (key-based retention).
  • Admin: create topic, alter config, ACLs.

Non-functional:

  • 10M messages/sec aggregate (large cluster).
  • p99 produce latency < 10 ms same AZ.
  • Durability: no acknowledged write lost if min ISR met.
  • Availability 99.95% per cluster.
  • Message size max 1 MB default.
AssumptionImplication
Consumers idempotentAt-least-once default
Partition count plannedHard to change without rebalance pain
Ordering per keyKey → partition hash
Broker local storageDisk bandwidth matters
ZooKeeper/KRaft metadataController manages leaders

5. Essential Terminology​

TermDefinition
TopicNamed stream of records
PartitionOrdered immutable log shard
OffsetMonotonic position in partition
BrokerServer storing partitions
LeaderBroker handling reads/writes for partition
FollowerReplica fetching from leader
ISRIn-sync replicas eligible for leader
Consumer groupCooperative consumers sharing load
RebalancePartition reassignment among consumers
RetentionTime/size bound on log
CompactionKeep latest record per key
HW (high watermark)Offset visible to consumers
LEOLog end offset on replica

6. Core Mechanism​

6.1 Architecture​

Figure 1: Producers write to partition leaders; followers replicate; multiple consumer groups read independently.

6.2 APIs​

Produce(topic, partition|key, value, headers)
Fetch(topic, partition, offset, max_bytes)
OffsetCommit(group, topic, partition, offset)
CreateTopics(name, num_partitions, replication_factor)
ListOffsets(topic, partition, timestamp)

6.3 Data Model​

Record:

{ offset, timestamp, key, value, headers, crc }

Log segment files:

topic-partition/
00000000000000000000.log
00000000000000000000.index (offset → file position)
00000000000000000000.timeindex

Consumer offset (internal topic __consumer_offsets):

group_id, topic, partition → committed_offset

6.4 Deep Dives​

Produce path:

  1. Producer picks partition: hash(key) % num_partitions or explicit.
  2. Send to leader broker for partition.
  3. Leader appends to log segment; replicate to ISR followers.
  4. Ack when acks=all and min ISR replicas persisted.
  5. Advance high watermark when all ISR caught up.

Consume path:

  1. Consumer joins group; coordinator assigns partitions (range or cooperative sticky).
  2. Fetch from leader at committed offset.
  3. Process batch; commit offset synchronously or async.
  4. On rebalance: revoke partitions; commit; reassign.

Figure 2: Produce with ISR replication; consumer fetch and offset commit.

Leader election:

  • Controller detects leader failure via metadata heartbeat.
  • Elect new leader from ISR preferred.
  • Unclean election (non-ISR leader): risk data loss—disable for critical topics.

Consumer rebalance:

  • Triggered: member join/leave, partition count change.
  • Cooperative sticky reduces stop-the-world vs eager rebalance.
  • Mitigate: static membership, incremental cooperative protocol.

Figure 3: Partition reassignment when consumer group scales.

Exactly-once (EOS):

  • Idempotent producer (PID + sequence per partition).
  • Transactions: atomic write to multiple partitions + consumer offsets.
  • Cost: higher latency; use only when necessary.

Tiered storage:

  • Old segments moved to S3; fetch transparently.
  • Retention 30d hot local + 1y cold object store.

7. Step-by-Step Walkthrough​

7.1 Ordered order events​

  1. Producer sends order_id as key; always partition 7.
  2. All events for order strictly ordered in partition 7.
  3. Consumer processes sequentially; no cross-order interleaving.

7.2 Broker failure​

  1. Leader broker for P3 crashes.
  2. Controller elects follower from ISR as new leader.
  3. Producers metadata refresh; resume in seconds.
  4. Unclean election disabled—brief unavailability vs data loss.

7.3 Consumer lag incident​

  1. Slow consumer falls 10M messages behind.
  2. Alert on lag > 100K for 15 min.
  3. Scale consumers up to partition count (12).
  4. If still lagging: optimize processing or add partitions (requires planning).

7.5 Compacted topic consumer bootstrap​

  1. New user-profile-cache consumer joins group.
  2. Reads compacted topic from offset earliest—gets latest profile per user_id key.
  3. Builds local cache without snapshot DB—changelog pattern from Event-Driven Architecture.

7.6 Transactional consume-process-produce​

  1. Consumer reads order event, updates DB, publishes shipment event.
  2. Kafka transaction: offsets + output topic commit atomically.
  3. Failure rolls back offset—reprocess without duplicate shipment if DB idempotent.

7B. Partition Reassignment Impact​

Increasing partitions from 12 → 24 does not split existing data—only new messages distribute. Plan partition count before production; increasing requires dual-consume migration or accept uneven historical distribution.

10A. Broker Disk Sizing​

Retention: 7 days
Ingest: 500 MB/sec/cluster
Storage: 500 × 86400 × 7 ≈ 302 PB raw before replication
RF=3 → ~900 PB—illustrates why tiered storage mandatory at scale

Interview: show math even if hypothetical—principal thinks in orders of magnitude.

PhaseKey decisions
Requirementsdurable log, ordering per key, fan-out
Scalepartitions, brokers, disk
APIsproduce, fetch, offset commit
Datalog segments; consumer offsets
Deep divesISR, rebalance, EOS optional

8. Invariants and Guarantees​

PropertyGuarantee
Partition orderTotal order within partition
Durabilityacks=all + min.insync.replicas
DeliveryAt-least-once default with manual commit
RetentionRecords deleted per policy
ISR safetyLeader only committed up to min ISR offset

9. Failure Scenarios​

ScenarioMitigation
Broker disk fullRetention; tiered storage; alert
ISR shrink below minStop writes; alert ops
Rebalance stormStatic membership; cooperative protocol
Poison messageDLQ pattern; skip with manual offset
Zombie consumersession.timeout.ms eviction
Split brain leaderKRaft consensus; fencing

10. Performance Characteristics​

Sequential write ~500 MB/sec per broker disk
10M msg/sec × 500 bytes = 5 GB/sec cluster → 10+ brokers
Zero-copy sendfile reduces CPU
Batch produce linger.ms=5 improves throughput
Partition count: start 2× peak consumer count

11. Scalability Limits​

LimitMitigation
Partition count too highMetadata overhead; file handles
Hot partitionKey skew; salt keys
Single broker diskMore brokers; tiered storage
Consumer > partitionsidle consumers
Cross-region mirrorMirrorMaker; lag SLA

12. Operational Considerations​

  • Metrics: under-replicated partitions, ISR shrink, consumer lag, request rate.
  • Alerts: offline partitions; disk > 85%.
  • Runbooks: preferred leader election; expand cluster.
  • Topic creation governance: default RF=3, min ISR=2.

13. Security Considerations​

  • TLS + SASL authentication.
  • ACL per topic produce/consume.
  • Encrypt sensitive payloads at application layer.
  • Network isolation for inter-broker traffic.
  • Audit admin operations.

14. Cost Considerations​

Disk and cross-AZ replication bandwidth dominate. Tiered storage cuts retention cost. Right-size partitions—over-partitioning wastes resources. Managed Kafka (MSK/Confluent) vs self-hosted ops.

15. Production Implementations​

SystemNotes
Apache KafkaIndustry standard log
Apache PulsarBookKeeper storage separation
Amazon MSKManaged Kafka
Confluent PlatformEnterprise Kafka ecosystem
RedpandaC++ Kafka-compatible

16. Alternatives and Tradeoffs​

ApproachProsCons
Kafka logReplay; throughputOps complexity
RabbitMQ queueSimple task queuesNo replay log
SQSManagedNo ordering (except FIFO)
PulsarStorage/compute splitSmaller ecosystem
DB changelogTransactionalLower throughput
gRPC streamingLow latency RPCNot durable log

16A. Topic Naming and Governance Standards​

Enforce org-wide conventions:

  • {domain}.{entity}.{event} e.g. orders.payment.captured
  • Version suffix in payload not topic name (v2 in Avro schema)
  • Owner team in topic registry; on-call rotation required for approval
  • Max retention documented per topic class (events 7d, changelog compacted forever)

Ad-hoc topic sprawl causes consumer coupling and orphan topics nobody dares delete.

16B. Stream Processing Placement​

ProcessingTool
Windowed aggregation metricsFlink / Kafka Streams
Simple filter/map routingConsumer app
Join two streamsStream processor with state store
Long-running sagaWorkflow Engine

Kafka is the log—not every computation belongs in broker. Principal defines platform boundaries clearly for engineering teams.

| "More consumers always faster" | Capped by partition count | | "Global ordering" | Only per-partition | | "Queues delete on read" | Log retains per policy | | "Unlimited partitions free" | Metadata and file cost |

18.1 Event Schema Evolution Playbook​

  1. Add optional Avro field with default—backward compatible.
  2. Deploy new consumers reading optional field.
  3. Deploy producers writing field.
  4. Remove old field only after all consumers upgraded—forward compatibility window.
  5. Never rename field without new schema version—consumers break silently.

Schema Registry CI gate blocks incompatible changes. Principal owns cross-team schema council for shared topics like orders.events—adhoc JSON blobs become integration debt within quarters.

18. Principal Architect Perspective​

  • Partition count is capacity plan—hard to reduce later.
  • Key design drives fairness—skew breaks hot partitions.
  • Consumer idempotency mandatory unless EOS justified.
  • min.insync.replicas=2 with RF=3 for production durability.
  • Rebalance is incident source—monitor and tune protocols.

19. Architecture Review Exercise​

Scenario: Single partition topic; 50 consumers; massive lag.

Review: Increase partitions to ≥ consumer parallelism; fix key strategy; batch consume.

20. Whiteboard Explanation​

"Topics split into ordered partitions stored as append-only logs on brokers. Each partition has a leader handling produce/fetch; followers replicate to ISR. Producers hash keys to partitions for ordering. Consumer groups coordinate partition assignment; each partition consumed by one consumer in group. Offsets track progress in internal topic. Controller manages leader election via KRaft. Retention trims old segments; compaction keeps latest per key. acks=all with min ISR for durability."

21. Interview Questions​

  1. Design Kafka. — Signals: log, partitions, ISR. Red flags: single queue DB.
  2. Ordering guarantees? — Signals: per-partition only. Follow-up: key choice.
  3. acks=all meaning? — Signals: ISR persisted before ack.
  4. Consumer group purpose? — Signals: parallel consume; partition assign.
  5. Rebalance problem? — Signals: stop-the-world; cooperative sticky.
  6. Hot partition fix? — Signals: key salting; more partitions.
  7. At-least-once vs exactly-once? — Signals: idempotent consumer vs transactions.
  8. Log retention vs compaction? — Signals: time/size vs key changelog.
  9. Why not RabbitMQ for replay? — Signals: queue deletes; no log rewind.
  10. Broker failure handling? — Signals: ISR leader election.
  11. Partition count sizing? — Signals: max consumer parallelism.
  12. Consumer lag mitigation? — Signals: scale to partitions; optimize handler.
  13. Unclean leader election risk? — Signals: data loss. Follow-up: when disable.
  14. Tiered storage benefit? — Signals: long retention cheap on S3.

21B. Extended Interview Question Deep Dives​

Q15 (Principal): Finance requires exactly-once ledger entries from Kafka consumer.

Strong signals: Idempotent consumer with DB unique constraint on event_id; or transactional consume-process-produce; compare EOS cost. Red flags: "Kafka is exactly-once end-to-end always." Rubric: 5/5 distinguishes broker EOS vs application ledger correctness.

Q16 (Principal): Topic with 6 partitions, peak lag 2 hours during Black Friday.

Strong signals: Pre-scale consumers to partition count; load test; consider temporary partition increase (requires planning); optimize handler batch size; add standby consumer group. Prevention: capacity review before known events.

  1. Schema Registry. — Avro evolution; compatibility modes.
  2. Kafka Streams vs Flink. — Library vs cluster processing.

22A. Production Low-Level Design (Interview + Game Day)​

Event log LLD: partition leaders + ISR replication; producers/consumers as clients of the data plane; controller as metadata control plane.

Context diagram​

Step-by-step flow:

StepAction
1–2Append + replicate to ISR
3Consumers read ≤ HW
4Controller manages failover

Production stack​

LayerChoiceRole
BrokersKafka / PulsarLog segments
MetadataKRaft / ZKMembership
DiskLocal SSD + tieredRetention
SchemaRegistryCompatibility
SecurityACL + TLSTenancy

API + schema​

produce(topic, partition|key, records[], acks)
fetch(topic, partition, offset, max_bytes)
commit_offset(group, topic, partition, offset)
StructureFields
Topicpartitions, RF, minISR, retention
Recordoffset, key, value, ts, headers
Groupmembers, assignment, offsets

Happy-path produce (acks=all)​

Failure — under-replicated​

Observability + SLO​

SLIIdea
Produce error rate
URP / ISR size
Consumer lag
Under-minISR time

22B. Game Day Playbooks​

Catalog​

IDDrillInjectSignal
GD-1Leader killKill brokerFailover < RTO
GD-2minISR pressureSlow followerProduce block
GD-3Consumer rebalance stormBounce membersLag spike
GD-4Disk fullFill log dirProduce fail
GD-5Unclean elect attemptedConfig driftPrevent
GD-6Poison messageBad payloadSkip/DLQ pattern

GD-1 — Leader failover (detailed)​

GD-2 — Produce under minISR (detailed)​

Pass criteria: no unclean election; critical topics never ack without ISR.

23. Strong Answer Example​

Question: "How ensure no message loss on produce?"

Answer this as a 45-minute design discussion using the PRACTICE framework. Below is how a strong student sounds aloud—acks=all + ISR + outbox, not just "Kafka is durable."

PRACTICE interview answer map for no message loss on produce

Figure A: PRACTICE map — Problem → Requirements → Assumptions → Capacity → Topology → Invariants → Constraints → Evolution.


Student interview script (PRACTICE)​

P — Problem framing​

"'No message loss on produce' means: if the application believes an event was published—or if the business write committed—that record must not vanish because a broker died, the producer crashed, or we dual-wrote carelessly.

Loss happens in three places: (1) producer gets an ack that wasn't durable enough (acks=0/1), (2) app commits DB then dies before Kafka publish (dual-write), (3) unclean leader election promotes a lagging replica that never saw the write.

Short answer: For durability-critical topics use RF=3, acks=all, min.insync.replicas=2, idempotent producer + retries, unclean.leader.election.enable=false, and—when the event must match a DB change—transactional outbox. Prefer fail the produce when ISR is too small over silent under-replication."

R — Requirements​

RequirementDesign
Ack'd produce survives broker lossacks=all + min ISR ≥ 2, RF=3
No lost event after business commitOutbox in same DB TX
Retries don't create unbounded dupes on brokerIdempotent producer (PID + seq)
Never elect a stale leader for money topicsDisable unclean election
Ops visibilityAlert on URP / ISR shrink / produce errors

"I'd ask: is this fire-and-forget telemetry or order/payment events? Same answer shape, different strictness."

A — Assumptions (state aloud)​

AssumptionWhy it matters
Multi-broker Kafka-like clusterSingle broker = single point of loss
App also writes a databaseDual-write is the hidden loss path
Same-AZ / same-region produceCross-region sync produce hurts p99
Duplicates OK at consumerALO produce retries → consumers idempotent
Disk is not infiniteFull disk → produce fails; must alert

"I'd say: broker durability ≠ end-to-end exactly-once—consumers still need idempotency."

C — Capacity​

acks=all + min ISR=2 → higher produce latency; required for no-loss
acks=1 → faster; can lose on leader crash — reject for critical
Outbox + relay → small DB cost; eliminates dual-write gap
Idempotent producer → negligible overhead; enables safe retries
Batching linger.ms → recovers throughput under acks=all

"I'd pay the ISR latency tax on money/order topics; use weaker acks only for disposable metrics—and document that."

T — Topology (draw this)​

Produce path with no message loss

Figure B: DB+outbox atomic intent → relay produce with acks=all to RF=3 / min ISR=2 leaders.

Where produce loss happens

Figure C: Weak acks, dual-write, unclean election, and disk/ISR failures—and the controls that close them.

ControlSetting / pattern
Replicationreplication.factor=3
Produce ackacks=all
Quorum floormin.insync.replicas=2
Leader safetyunclean.leader.election.enable=false
Producerenable.idempotence=true, retries, sensible delivery.timeout.ms
App↔broker atomicityTransactional outbox (not publish-after-commit)
OpsUnder-replicated partitions, ISR shrink, disk, produce error rate

I — Invariants (safety)​

"Non-negotiable for 'no loss on produce':

  1. Never treat produce as success until acks=all completes (for durable topics).
  2. min ISR must be met—otherwise fail the write; don't pretend durability.
  3. No unclean leader election on those topics.
  4. Business commit ⇒ outbox row in the same transaction.
  5. Retries are required; idempotent producer keeps broker-side duplicates bounded.
  6. Monitoring URP/ISR is part of the durability contract."

C — Constraints (second C)​

ConstraintDesign response
ISR shrinks below minProduce fails—page ops; restore replicas
Producer timeout / ambiguous errorRetry with idempotence; don't invent "maybe lost, insert again" without key
Dual-write temptationOutbox / CDC only
Full diskAlert early; block produces safely vs corrupt
Multi-DC sync producePrefer regional produce + async mirror for DR
Schema break poisoningSchema Registry compatibility—not durability but related reliability

E — Evolution (prove it)​

Phased delivery:

PhaseDeliverable
M1Topic standards: RF=3, min ISR=2, no unclean election
M2Producer defaults: acks=all, idempotence, retries
M3Outbox for DB-coupled events
M4Dashboards/alerts: URP, ISR shrink, produce failures, outbox lag
M5Chaos: kill leader mid-produce; kill app after DB commit—assert no loss
M6Runbook: disk full, ISR recovery, forbidden unclean election

Failure modes:

FailureMitigation
acks=1 "for speed"Reject for durable topics
Publish after DB commitOutbox
Unclean election enabledDisable; accept brief unavailability
Ignore produce errorsTreat as retryable failure
No URP alertsSilent under-replication

Observability: produce success/fail, request latency, URP count, ISR size, outbox pending age, disk usage.


Closing line (interview)​

"So to ensure no message loss on produce, I combine broker durability—RF=3, acks=all, min.insync.replicas=2, no unclean election—with an idempotent retrying producer, and I close the app gap with a transactional outbox so a committed business write always has a durable publish intent. I'd rather fail produces when ISR is unhealthy than ack and lose data. Then I monitor under-replicated partitions and prove it with leader-kill chaos tests."

Scoring signals​

StrongWeak / red flag
acks=all + min ISR + RF"Kafka is durable" / acks=0
Outbox for DB+eventDual-write after commit
Disable unclean electionAccept any leader
Idempotent producer + retriesFire-and-forget
URP / ISR monitoringNo ops story
Prefer unavailable write over silent lossAlways prioritize availability

Compact outline (if time-boxed to 2 minutes)​

"RF=3, acks=all, min.insync.replicas=2, no unclean election. Idempotent producer with retries. Outbox so DB commit can't orphan events. Fail produce if ISR too small. Alert on URP. Chaos-kill the leader."

24. Weak Answer Example​

Question: "How ensure no message loss on produce?"

"Kafka stores everything on disk, so once we call send() we're fine. We use acks=1 for speed."

Why weak / red flags: Ignores ISR/acks=all, dual-write loss after DB commit, unclean election, and produce error handling—acks=1 can lose data on leader crash.

25. Hands-On Exercise​

  1. Create topic 12 partitions; produce with keyed messages.
  2. Run consumer group; observe partition assignment.
  3. Kill leader broker; measure failover time.
  4. Demonstrate consumer lag under slow processing.
  5. Extension: Enable idempotent producer; count duplicates without it.

25A. Extended Hands-On Lab​

  1. Produce with idempotence enabled; kill producer mid-batch; verify no dupes on broker.
  2. Increase partitions; observe that historical messages do not rebalance.
  3. Configure compacted topic; produce tombstone; verify old keys removed after compaction.
  4. Principal lab: Topic registry YAML in Git with owner and retention per topic.

25B. Production Readiness Review Questions​

  • Is unclean leader election disabled on payment topics?
  • Can consumer lag page before customer-visible backlog?
  • Are ACLs audited quarterly for stale produce permissions?
  • What is disk headroom policy before auto retention trim?

Kafka cluster full disk is catastrophic—monitor bytes in per broker daily.

  1. Max parallel consumers per group?
  2. HW vs LEO?
  3. When use compaction?

27. Flashcards​

FrontBack
ISRReplicas caught up with leader
OffsetPosition in partition log
Consumer groupCooperative partition consumers
High watermarkLast offset safe to read
RebalancePartition reassignment event
Log compactionLatest record per key retained
acks=allWait for ISR replication
Hot partitionKey skew overloads one shard
KRaftKafka metadata consensus (no ZK)
Idempotent producerPID+sequence dedup on broker

28. Cheat Sheet​

REQUIREMENTS: durable log, fan-out, replay, ordering per key
SCALE: partitions ≥ consumers; RF=3; 10M msg/sec
APIs: produce, fetch, offset commit, admin
DATA: log segments; offset index; __consumer_offsets
ARCH: producers → leaders → followers; consumer groups
DEEP: ISR ack; rebalance; compaction; tiered storage
RELIABILITY: min ISR=2; no unclean election
SECURITY: TLS; SASL; topic ACLs
OPS: lag; under-replicated; disk usage

17A. Failure Scenario Drill​

Topic orders has 3 partitions but consumer group scales to 30 consumers—27 idle; lag on hot partition unfixable by scale. Mitigation: partition count planning 2× peak consumer parallelism; key salting for skew. Principal reviews partition count at topic creation—not after production lag incident.

18.1 Schema Evolution with Consumers​

Avro backward compatible: add optional field OK; remove field breaks old consumers. CI compatibility check against Schema Registry before deploy producer.

19A. Extended Review Scenario​

Scenario B: enable.auto.commit=true with slow processing—messages lost on crash mid-batch.

Review: Manual commit after successful processing; idempotent consumer; consider transactional read-process-write.

21A. Additional Interview Questions​

  1. MirrorMaker lag SLA for DR? — Signals: RPO measured in replication lag seconds; alert > 60s.
  2. Compacted topic disk still growing? — Signals: tombstone retention; duplicate keys with null value.

28A. Principal Interview Deep Dive​

Producer tuning cheat sheet​

SettingEffect
linger.ms=5Batch more; +latency
compression.type=lz4CPU vs bandwidth
batch.sizeMax batch bytes

Consumer fetch tuning​

max.poll.records vs processing time—must process batch within max.poll.interval.ms or rebalance eviction.

When EOS worth it​

Money movement exactly-once across topic + DB—yes. Analytics pipeline—at-least-once + idempotent sink usually sufficient and cheaper.

28B. Extended BOE Walkthrough​

Interviewer: "10M messages/sec, 7 day retention."

Strong candidate:

"10M × 500B = 5 GB/sec—cluster of 100+ brokers with NVMe.

Partition for parallelism—start 1000+ partitions for consumer scale.

RF=3 min ISR=2 acks=all. Tiered storage day 3 to S3 for cost.

Consumer lag alert per group. Hot partition: salt keys.

Feed Logging Platform and Workflow Engine as downstream patterns."

30. References​

  • Kreps, Rao, Schubert — Kafka design paper (LinkedIn origin).
  • Apache Kafka documentation — replication and consumer protocols (official).
  • Kleppmann, DDIA — stream processing and logs.

Distinction: Kafka paper describes core log model; KRaft and tiered storage are later implementation evolution.

30A. Further Reading Paths​

Connect to Event-Driven Architecture patterns. Outbox pattern in Transactional Outbox often publishes to Kafka.

30B. Topic Design Checklist​

  • Partition count ≥ max consumer parallelism
  • RF=3, min.insync.replicas=2
  • Key strategy avoids hot partition
  • Retention aligned with replay requirements
  • ACLs least privilege produce/consume
  • DLQ strategy for poison messages documented

30D. Principal Architecture Review Checklist​

  • Partition count documented at topic creation with consumer parallelism justification
  • acks=all and min.insync.replicas=2 on durability-critical topics
  • Consumer idempotency or EOS decision documented per consumer
  • Rebalance protocol: cooperative sticky enabled; static membership where applicable
  • Under-replicated partition alert wired to paging
  • DLQ or skip strategy for poison messages defined
  • Tiered storage or retention limits prevent unbounded disk growth
  • ACLs least privilege—no shared admin client in applications

Kafka operations excellence is measured in lag, ISR health, and rebalance frequency—not only throughput benchmarks.

30F. Closing Principal Note​

Kafka won the log abstraction war because replay, fan-out, and retention are fundamental to modern distributed systems—not because messaging was unsolved before.

30G. KRaft and ZooKeeper Migration​

New clusters should use KRaft metadata mode per current Kafka project direction—ZooKeeper deprecation reduces operational moving parts. Migration from ZK to KRaft is planned downtime exercise—include in multiyear platform roadmap; verify steps against official Kafka documentation at migration time.

30H. Broker Sizing Quick Reference​

WorkloadBroker profile
High throughputNVMe, 10 GbE+, fewer larger brokers
Long retentionMore disk per broker; tiered storage
Many partitionsHigher CPU for request handling
Cross-AZ RF=33× write amplification—budget network

Right-size before partition explosion—adding brokers later is easier than repartitioning topics with production traffic. For interview back-of-envelope: if each broker sustains 100 MB/sec write and cluster needs 2 GB/sec ingest, plan ~20 brokers minimum before replication overhead and headroom—then validate with load test rather than trusting napkin math alone. Document consumer lag SLO per consumer group in service catalog—on-call routes to owning team not Kafka platform for business logic slowness. Include broker disk utilization forecast in quarterly capacity review—log growth is predictable until it is not. Producers must handle MESSAGE_TOO_LARGE with client-side split or compression—document max message size in API standards for all teams publishing to shared cluster. Broker defaults near 1 MB are not suggestions—they are hard limits that reject oversize payloads at the protocol layer.