← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

Topics & Partitions

Messaging Intermediate
debt(d9/e7/b7/t7)
d9 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d9). The detection_hints state automated=no, with only a code_pattern hint for partition|partition_key. Over-partitioning, missing replication, or wrong partition counts produce no compile/lint errors — problems only surface as consumer lag, rebalancing storms, or data loss in production.

e7 Effort Remediation debt — work required to fix once spotted

Closest to 'cross-cutting refactor across the codebase' (e7). The why_it_matters field explicitly states partition count 'can't easily be reduced after creation.' Changing partition count requires updating consumers (a noted common_mistake), potentially re-keying producers, and coordinating replication changes — this spans multiple services and infrastructure config, not a single-file fix.

b7 Burden Structural debt — long-term weight of choosing wrong

Closest to 'strong gravitational pull' (e7). Partition count is called 'the most important Kafka sizing decision' and applies to cli and queue-worker contexts. Every consumer group, ordering guarantee, and parallelism decision is shaped by initial partition topology. Wrong choices impose a persistent tax across all producers and consumers until a painful migration.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap' (t7). The misconception field explicitly states 'More partitions is always better' — a belief that contradicts how most scaling knobs work (more = better). Increasing partitions also silently breaks key-based routing for existing consumers, a non-obvious cross-cutting side effect documented in common_mistakes.

About DEBT scoring →

TL;DR

Kafka topics are divided into partitions — the unit of parallelism and ordering. More partitions = more parallelism; partition key determines which partition a record lands in.

Explanation

Topic: a named stream of records. Partition: an ordered, immutable log. Records appended with offset. Multiple partitions per topic: parallel reads/writes. Partition assignment: by key hash (same key → same partition → ordering), round-robin (no key → load balanced → no ordering), custom partitioner. Replication: each partition has one leader and N-1 followers. Leader handles reads/writes; followers replicate. Partition count: set at creation (can increase, never decrease). More partitions → more parallelism → more overhead (file handles, memory). Typical: 3-12 partitions for throughput, 1 for strict ordering.

Common Misconception

More partitions is always better — each partition has overhead (file handle, memory, rebalancing cost). Start with 3-6 and increase if needed.

Why It Matters

Partition count determines maximum parallelism — it's the most important Kafka sizing decision and can't easily be reduced after creation.

Common Mistakes

  • Too many partitions for the workload — overhead without benefit.
  • Changing partition count without updating consumers — key routing changes.
  • No replication in production — single partition leader = single point of failure.

Code Examples

✗ Vulnerable
# 1 partition — no parallelism:
kafka-topics --create --topic orders --partitions 1 --replication-factor 1
# 1000 partitions — unnecessary overhead
✓ Fixed
# Balanced: 6 partitions, 3 replicas:
kafka-topics --create --topic orders --partitions 6 --replication-factor 3

# PHP producer with partition key:
$conf->set('partitioner', 'consistent_random'); // Same key = same partition
$producer->produce(RD_KAFKA_PARTITION_UA, 0, $payload, $orderId); // Key = orderId

Added 23 Mar 2026
Views 81
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 2 pings S 2 pings S 4 pings M 0 pings T 1 ping W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 2 pings W 0 pings T 0 pings F 0 pings S 1 ping S 1 ping M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Amazonbot 18 Perplexity 12 Google 6 Scrapy 6 ChatGPT 5 Unknown AI 5 Ahrefs 5 SEMrush 4 Meta AI 3 Claude 2 Bing 2 PetalBot 1
crawler 62 crawler_json 4 pre-tracking 3
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: Medium
⚡ Quick Fix
Start with 3-6 partitions per topic. Set replication-factor=3 for production. Use entity ID as partition key for ordering. Monitor partition lag per consumer group.
📦 Applies To
cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
partitions|partition_key
Auto-detectable: ✗ No
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: File


✓ schema.org compliant