Data and messaging · 24 concepts
Messaging: Kafka, RabbitMQ, queues and Redis
How to move events and jobs between services safely: Kafka, RabbitMQ, SQS and EventBridge, the patterns that prevent lost and duplicate messages, and Redis beyond caching.
Asked in these mock interviews
Part 1 · 6 concepts
Kafka
- 01
Kafka topics, partitions, keys and ordering
A topic is split into partitions. Kafka keeps order only inside one partition, so the message key decides what stays in order. Good topic design starts from keys…
- 02
Kafka producers: acks, replicas and the idempotent producer
A send that reports success is not always safe. Durability depends on acks, the in-sync replicas and min.insync.replicas. The idempotent producer stops duplicates from…
- 03
Kafka consumers: offsets, commits and lag
A consumer saves its position by committing offsets. When you commit decides what you lose or repeat. Lag shows how far behind a group is, but you must read it correctly.
- 04
Consumer groups and rebalances
Every time a consumer joins or leaves, the group rebalances. With the old eager protocol, all consumers stop while partitions are reassigned. Autoscaling can turn this…
- 05
Kafka retention, compaction and lag that disappears
Retention is your recovery window. Delete policy removes old segments by time or size. Compaction keeps the latest record per key. A consumer that falls behind…
- 06
Kafka 4: KRaft and share groups
Current Kafka runs only in KRaft mode, without ZooKeeper. Share groups add queue-like consumption. Versions change quickly, so check the release notes of your version.
Part 2 · 4 concepts
RabbitMQ
- 07
RabbitMQ exchanges, bindings and routing keys
In RabbitMQ a producer sends to an exchange, not to a queue. Bindings route messages to queues, and the exchange type decides how.
- 08
RabbitMQ consumers: acks, prefetch, retries and dead-lettering
A consumer must acknowledge messages. Without a prefetch limit one consumer can hoard thousands of messages, and a requeue loop can burn CPU. Retries need delays and a…
- 09
RabbitMQ durability and queue types: classic, quorum and stream
Messages survive a restart only with a durable queue and persistent messages, and replication needs a quorum queue. Streams are a different tool: a log that many…
- 10
RabbitMQ resource alarms and blocked publishers
When RabbitMQ runs low on memory or disk, it blocks publishers across the cluster. A backlog in one queue can stop unrelated services, such as checkout.
Part 3 · 3 concepts
Cloud queues
- 11
SQS standard and FIFO queues, and polling cost
Standard queues give high throughput with at-least-once delivery and best-effort order. FIFO queues give order per message group. Polling style decides your bill.
- 12
SQS visibility timeout, dead-letter queues and workers
After a receive, a message is hidden for the visibility timeout and comes back if you do not delete it. Slow jobs, retries and dead-letter queues all depend on this one…
- 13
Fan-out with SNS, SQS and EventBridge
One SNS topic with one SQS queue per consumer gives each service its own buffer and retries. EventBridge adds content-based routing, archive and schedules, but has its…
Part 4 · 6 concepts
Messaging patterns
- 14
Where duplicates and losses really come from
Every queue promises at-least-once delivery at best. A message can be lost or duplicated at the producer, the broker and the consumer. The defence is idempotent…
- 15
Idempotent consumers and safe payments
A check of a processed table before the work is a race. Claim the event first with a unique constraint, and send an idempotency key to the payment gateway.
- 16
The outbox pattern and sagas
The outbox writes the event in the same database transaction as the change, and a relay publishes it later. A saga coordinates several services with steps and…
- 17
Retries, ordering and dead-letter replay
Retries can break ordering, and replaying a dead-letter queue can double-pay or overload a provider. Plan both before an incident.
- 18
Event design and schema evolution
Events are a contract between teams. A rename breaks consumers. Use additive changes, a schema registry with a compatibility rule, and a standard envelope.
- 19
Choosing Kafka, RabbitMQ or SQS
Choose from the needs: replay, throughput, routing, retries and what the team can run. Standardise on a short list, with reasons.
Part 5 · 5 concepts
Redis in depth
- 20
Redis counting and ranking: bitmaps, HyperLogLog and sorted sets
Pick the structure by the question and the memory cost. Bitmaps and HyperLogLog count users cheaply. Sorted sets rank them, but one huge key lives on one node.
- 21
Lua scripts and rate limiting in Redis
A Lua script runs as one unit, so a check and an update cannot race. It is the right tool for a sliding-window rate limiter, if you write it carefully.
- 22
Redis pub/sub or Streams
Pub/sub is fire-and-forget. Streams keep a log with ids and consumer groups. Choose by what a missed message costs.
- 23
Redis persistence, replication and Sentinel
Redis can lose data in several ways: a restart without persistence, the last seconds before a snapshot, and asynchronous replication during a failover. Match the…
- 24
Redis Cluster, memory and hot keys
Cluster shards keys over hash slots. Multi-key work needs keys in one slot. A cluster spreads keys, not the load of one key, and client buffers can fill memory.
Your first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.