Kafka
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Kafka: the 60-second story

    Kafka

    Each parcel event lands in one of 12 books, chosen by PIN code.

    Lines are only added at the bottom. Each team keeps its own bookmark, so slow analytics never holds up billing.

    Topic → partitions → offsets. The key picks the partition.

    murmur2(key) % partitions keeps a key on one partition, in order, until the partition count changes. Order exists only within a partition.

    Read it, and it’s gone?

    Bad: Like a queue

    Acknowledged messages are deleted: nothing left to replay.

    Good: A log kept 7 days

    Reads delete nothing; retention drops old segments. Any group can rewind and replay.

    acks=all waits for the in-sync replicas, however few.

    With min.insync.replicas=2 and three replicas, losing one broker loses nothing. Lose two and writes stop rather than live on one disk.

    100

    partitions, set by consumers, not bytes

    A Flipkart-style sale peaks at 50,000 order events/s. At 10 MB/s per partition, the bytes need 5. A 2 ms database write per event needs 100.

    One consumer per partition per group. Extras sit idle.

    Groups keep separate offsets, so fraud-check lagging 9,400 on P2 never slows analytics. Scale reads by adding partitions.

    Exactly-once is on. Your processor writes ledger entries, then sends an SMS.

    The catch

    The SMS can go twice. Transactions cover only Kafka topics and offsets; a replay repeats anything outside. Use idempotency keys.

    Pick it, or not

    1. Pick: fan-out, per-key order, replay, high volume
    2. Not: job queues needing per-task retry, delay, DLQ
    3. Not: request/response, big payloads, lookups by key
    4. Not: low volume, atomic with a DB write

    Say it like this

    Pick Kafka when many consumers need the same events in per-key order, with replay. Key by order_id; RF 3, min.insync.replicas=2, acks=all survives a broker loss. Idempotent consumers. Not for job queues.