热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

Chapter 3

Topics, Partitions, Offsets, Ordering, and Retention

Build a solid Kafka foundation by understanding how records are organized, how ordering works, and how retained event history supports replay.

Inside this chapter

  1. Why Topics Matter
  2. Partitions and Parallelism
  3. Offsets
  4. Retention and Replay
  5. Key-Based Partitioning
  6. Real-Time Example

Series navigation

Study the chapters in order for the clearest path from Kafka basics and local setup to stream processing, platform operations, cloud usage, and advanced event-driven architecture thinking. Use the navigation at the bottom to move smoothly through the full tutorial series.

Tutorial Home

Chapter 3

Why Topics Matter

A topic is a logical stream of records. Teams often create topics around important business events such as orders, payments, shipments, user-signups, device-metrics, or inventory-changes. Topic naming and ownership are important because they shape how events are discovered and used across the organization.

Chapter 3

Partitions and Parallelism

Each topic can be split into partitions. A partition is an ordered append-only log. Kafka uses partitions to scale reads and writes horizontally.

Ordering is guaranteed within a partition, not automatically across all partitions of a topic. This is one of the most important concepts students must understand early.

Chapter 3

Offsets

An offset is the position of a record inside a partition. Consumers track offsets so they know what they have already processed and where to resume after restart or failure.

Partition 0:
offset 0 -> order-created
offset 1 -> order-paid
offset 2 -> order-shipped
Chapter 3

Retention and Replay

Kafka keeps records for a configurable retention period or based on size limits. This is powerful because consumers can replay old events for recovery, debugging, backfill jobs, or onboarding new downstream systems.

Chapter 3

Key-Based Partitioning

If a producer sends records with the same key, Kafka can route them consistently to the same partition. This is how teams preserve ordering for a specific entity such as order id, customer id, or account id.

Chapter 3

Real-Time Example

In a bank, events for one account should usually stay ordered relative to that account. Key-based partitioning makes this possible while still allowing other accounts to be processed in parallel on different partitions.

版权所有 © 2026,WithoutBook。