Messaging, Queues & StreamsAdvanced15 min read1 questions

Kafka Architecture and Delivery Semantics

How Kafka actually stores and delivers data, why partitions are the unit of both parallelism and ordering, and the operational realities - rebalances, lag and hot partitions.

Covers: Topics, partitions, offsets, consumer groups, replication and ISR, ordering guarantees, rebalancing, consumer lag

Kafka is the default answer to “we need an event backbone”, and it is asked about constantly. The whole model reduces to one idea: a topic is a set of partitions, and a partition is an append-only file. Every guarantee and every limitation follows from that.

Topics, partitions and consumer groups

Tap each node. Partitions are the unit of ordering, parallelism, and therefore of every scaling decision you will make.

ServiceQueueComputeTap a box for detail

Flow

  • ProducersPartition 0
  • ProducersPartition 1
  • ProducersPartition 2
  • Partition 0Consumer group A
  • Partition 1Consumer group A
  • Partition 2Consumer group A
  • Partition 0Consumer group B
  • Partition 1Consumer group B
  • Partition 2Consumer group B
Filter
0/1 mastered
AdvancedkafkapartitionsorderingAsked at Confluent, LinkedIn

30-second answer

Kafka guarantees ordering within a partition only - never across partitions. Messages with the same key always land in the same partition, so per-key ordering is achieved by keying on the entity that needs it, such as user ID or order ID. Partition count is the unit of consumer parallelism: you cannot have more useful consumers in a group than partitions. Size it from target throughput divided by per-consumer throughput, add headroom, and remember you can increase partitions later but never decrease them - and increasing them changes the key-to-partition mapping, breaking ordering for in-flight keys.

Showing 1 of 1 questions for kafka-architecture-and-delivery-semantics.

Check your understanding

4 questions · no sign-up, nothing stored

0/4 answered
Question 1

1.A topic has 8 partitions. You run a consumer group with 12 consumers. What happens?

Question 2

2.With replication.factor=3, what is the correct min.insync.replicas?

Question 3

3.How do you guarantee all events for one user are processed in order?

Question 4

4.Why is increasing a topic's partition count a one-way, disruptive change?

Hands-on challenge

Build it - this is what you talk about in a deep-dive round.

Design a Kafka topic layout for an e-commerce platform

Events: page views (500k/s), add-to-cart (10k/s), orders (1k/s), payments (1k/s). Consumers include analytics, fraud detection, inventory and the data warehouse.

Requirements

  • Define topics, partition counts and partition keys for each event type, with the throughput arithmetic.
  • State exactly which ordering guarantee each consumer needs and how the keying provides it.
  • Choose replication and acks settings per topic, justifying differences between page views and payments.
  • Set retention per topic and explain the storage implication.
  • Design the consumer-lag alerting, expressed in time, per consumer group.

Stretch goals

  • Handle a single merchant generating 20% of all add-to-cart events.
  • Design the migration to double partitions on the orders topic without breaking per-order ordering.