FlashcardsRecall, then flip

Print · Kafka

Back to study

32 cards · 4 sheets · 8 pages.

Print double-sided, flipping on the long edge, at 100% scale with no margins added by the browser. Answer columns are already mirrored, so each answer lands on the back of its own question. Cut along the dashed lines.

Preview

Kafka flashcards — questions (cards 1-8)Print double-sided, flip on long edge, cut along dashed lines
CARD 1 · QUESTION

What is Kafka, in one line?

CARD 2 · QUESTION

Define broker, partition and topic.

CARD 3 · QUESTION

Topic vs partition - the actual difference?

CARD 4 · QUESTION

What are the fields of a Kafka message?

CARD 5 · QUESTION

What does the message key do, and what if you omit it?

CARD 6 · QUESTION

What is an offset?

CARD 7 · QUESTION

What is a consumer group and what does it guarantee?

CARD 8 · QUESTION

Kafka as a message queue vs as a stream?

Kafka flashcards — answers (cards 1-8)Columns mirrored so answers align with question backs
CARD 2 · ANSWER

A broker is a server in the cluster. A partition is an ordered, immutable, append-only log on a broker. A topic is a logical grouping of partitions. id: 8271ae2f-f90f-435e-a468-2fc34531cb64

CARD 1 · ANSWER

A distributed event streaming platform - a durable, partitioned, append-only commit log usable as either a message queue or a stream. id: ef4fcf93-ad99-41d0-96eb-07d5f7343518

CARD 4 · ANSWER

Value (payload), key, timestamp and headers - all technically optional. Headers are key-value metadata, like HTTP headers. id: a4a48271-4068-4b53-ba64-e6dfd7d6b633

CARD 3 · ANSWER

A topic is a logical grouping; a partition is the physical one. Partitions are the unit of parallelism and the only place ordering is guaranteed. id: afe12183-dcaf-40d6-800c-74654f19c720

CARD 6 · ANSWER

A sequential ID marking a message's position within a partition. Consumers commit offsets so they can resume where they left off after a restart. id: 8a2d7768-62e9-429f-9ba3-2d76ff4e9fe2

CARD 5 · ANSWER

It is hashed to pick the partition, so equal keys stay together and stay ordered. With no key, modern clients use a sticky partitioner and you lose related-message ordering. id: a86b124b-728c-4edf-b163-1cc642c93b78

CARD 8 · ANSWER

Same mechanics, different consumption pattern: a queue has one consumer per message; a stream retains the log for replay and multiple independent groups. id: 7fa0f7f4-9e5d-45dd-b961-a3a02d99ffc3

CARD 7 · ANSWER

Consumers sharing a topic's partitions - each partition goes to exactly one consumer in the group. Separate groups read the same topic independently. id: 61dcc3d1-2774-4860-86ff-b8e0367f1445

Kafka flashcards — questions (cards 9-16)Print double-sided, flip on long edge, cut along dashed lines
CARD 9 · QUESTION

What two steps happen when a producer publishes?

CARD 10 · QUESTION

Why is an append-only log the right structure?

CARD 11 · QUESTION

How does Kafka replicate a partition?

CARD 12 · QUESTION

What is the ISR, and what does acks=all buy you?

CARD 13 · QUESTION

Watch-outs when using Kafka from a Node/Next.js app?

CARD 14 · QUESTION

Do consumers push or pull? Why?

CARD 15 · QUESTION

What ordering guarantee does Kafka actually give?

CARD 16 · QUESTION

Default delivery semantics, and how do you get exactly-once?

Kafka flashcards — answers (cards 9-16)Columns mirrored so answers align with question backs
CARD 10 · ANSWER

Immutability simplifies replication and recovery, appending avoids disk seeks, and the simplicity makes scaling by adding partitions straightforward. id: f23f1aaa-a870-4d52-b50b-cf4a809bc7ee

CARD 9 · ANSWER

Partition determination (hash the key, or default partitioner), then broker assignment - the client uses cluster metadata to reach that partition's leader. id: 40a7e1f8-7363-4df3-837d-6b2591ca6669

CARD 12 · ANSWER

In-sync replicas are the followers fully caught up. acks=all acknowledges only once every ISR has the message - strongest durability, at the cost of latency. id: bc17a2c4-9c7a-4bd0-af19-a0318f321fe4

CARD 11 · ANSWER

Leader-follower: one replica takes writes, followers on other brokers sync passively. The controller promotes an in-sync follower when a leader dies. id: 84f9936f-ec3d-4568-b570-1094042de155

CARD 14 · ANSWER

Pull - consumers poll at their own rate. Slow consumers self-limit, failure handling is simpler, and batching becomes efficient. id: 25751c6d-d9c6-4617-8089-56c82fb883b8

CARD 13 · ANSWER

Clients hold long-lived connections and group membership, which fits badly with serverless handlers. Run producers and consumers in a persistent process or behind a REST proxy. id: eaa802a0-ecf2-48c3-878f-536ef669f2d0

CARD 16 · ANSWER

At-least-once by default. Exactly-once needs idempotent producers plus the transactional API - usually better to assume duplicates and make consumers idempotent. id: 1d36be4b-d5d6-4716-9f4d-9fd635bae586

CARD 15 · ANSWER

Ordering within a partition only, by offset - not by timestamp, not across a topic. Global ordering means one partition, which means no parallelism. id: d1d67056-53a0-446c-b8c4-d7cae26371bb

Kafka flashcards — questions (cards 17-24)Print double-sided, flip on long edge, cut along dashed lines
CARD 17 · QUESTION

What happens when a consumer crashes?

CARD 18 · QUESTION

When should you commit the offset?

CARD 19 · QUESTION

How do producer retries work, and what is the gotcha?

CARD 20 · QUESTION

What does Kafka give you for consumer-side retries?

CARD 21 · QUESTION

Rough single-broker capacity for back-of-envelope maths?

CARD 22 · QUESTION

Two ways to scale Kafka.

CARD 23 · QUESTION

How is a partition chosen from a key?

CARD 24 · QUESTION

Four ways to fix a hot partition.

Kafka flashcards — answers (cards 17-24)Columns mirrored so answers align with question backs
CARD 18 · ANSWER

Only after the work is durably done, or you silently drop messages. The more a consumer does per message, the more is redone on failure - so keep consumers small. id: 25a97ecf-42e8-4aa8-ba63-c8a7312b33f2

CARD 17 · ANSWER

It resumes from its last committed offset on restart, and the group rebalances so remaining consumers pick up the orphaned partitions. Nothing is missed; some work is redone. id: 7434e18b-9e0a-44c9-a68f-a707c11fcd85

CARD 20 · ANSWER

Nothing built in, unlike SQS. The pattern is a retry topic consumed separately, then a dead letter queue after N failures - a fair reason to pick SQS for simple worker queues. id: 6e26d304-6252-4cb5-b713-e5e8f6e1ea39

CARD 19 · ANSWER

Producers retry transient failures automatically. Enable idempotent mode alongside retries, or a retried send that actually succeeded becomes a duplicate. id: 974896ab-58b4-4b7e-868f-3a94f0640776

CARD 22 · ANSWER

Add brokers, and partition properly. Brokers alone do nothing if topics are under-partitioned - scale the topic, not just the cluster. id: 4305bd52-29cc-4a84-8e67-d74b43e45950

CARD 21 · ANSWER

Very hand-wavy, but ~1TB storage and up to ~1M messages/sec on good hardware, with messages under ~1MB. Below that, scaling is not the conversation. id: 4c7af18c-4472-466b-aad2-92d49311db66

CARD 24 · ANSWER

Drop the key and spread load (losing ordering); salt the key with a random suffix; use a compound key such as ad ID + region; or apply back pressure and slow the producer. id: f79a2b13-9898-48bb-aef9-9f5bcb2398d3

CARD 23 · ANSWER

partition = hash(key) % num_partitions, murmur2 by default. Changing the partition count therefore reshuffles which partition a key maps to. id: b05959f5-ad81-46ec-b997-c665ee61b229

Kafka flashcards — questions (cards 25-32)Print double-sided, flip on long edge, cut along dashed lines
CARD 25 · QUESTION

Why are large payloads an anti-pattern, and what instead?

CARD 26 · QUESTION

How does retention work, and what is log compaction?

CARD 27 · QUESTION

What is KRaft?

CARD 28 · QUESTION

What is tiered storage (KIP-405)?

CARD 29 · QUESTION

Two producer-side performance levers?

CARD 30 · QUESTION

When do you reach for Kafka as a queue in an interview?

CARD 31 · QUESTION

When do you reach for it as a stream?

CARD 32 · QUESTION

"Always available, sometimes consistent" - so what?

Kafka flashcards — answers (cards 25-32)Columns mirrored so answers align with question backs
CARD 26 · ANSWER

Messages expire by retention.ms (7 days default) or retention.bytes. Compaction instead keeps the latest value per key forever, making the topic a replayable snapshot. id: 33a07f7c-24c1-4f16-b95f-a99ed03fad62

CARD 25 · ANSWER

Kafka is not a blob store - big messages hurt memory and network throughput. Write the object to S3 and put a pointer in the message: the claim-check pattern. id: acac941e-5132-4c0d-a306-4a1484d3376a

CARD 28 · ANSWER

Brokers keep recent segments on local disk and offload older ones to object storage, so retention is no longer bounded by broker disk. GA in Kafka 3.9. id: db5ee616-49de-45f0-af4d-07993250f9f4

CARD 27 · ANSWER

Kafka's own Raft-based metadata quorum, replacing ZooKeeper. Production-ready since 3.3 and ZooKeeper was removed entirely in Kafka 4.0. id: ea87c892-b2df-4b07-a241-6afd1ffa6504

CARD 30 · ANSWER

Asynchronous work such as transcoding after upload, work that must stay ordered such as a waiting queue, or when producer and consumer must scale independently. id: b532cdc5-dd3d-4fe5-869d-4b4360ea00c4

CARD 29 · ANSWER

Batching (group records per send to amortise network overhead) and compression (GZIP, Snappy, LZ4). Both trade a little latency for a lot of throughput. id: 67758d0f-5870-4df6-b488-0094605ddd6a

CARD 32 · ANSWER

Replication and leader failover make cluster-wide outage an unrealistic premise; redirect the question. The interesting failure is a consumer dying.

CARD 31 · ANSWER

Continuous real-time processing, such as aggregating ad clicks as they arrive, or fan-out where many independent consumers need the same messages. id: 161ffec7-8ec2-4585-8199-5d9bb3b70f79