Module 8: Review & Cheat Sheet
1. Interactive Flashcards
Test your knowledge. Click (or tap) the card to flip it.
2. Cheat Sheet
Messaging Tool Comparison
| Feature | RabbitMQ (Queue) | Kafka (Stream) | SQS (Cloud Queue) |
|---|---|---|---|
| Model | Push (Smart Broker) | Pull (Dumb Broker) | Pull |
| Persistence | Transient (Memory) | Durable Log (Disk) | Durable (Multi-AZ) |
| Throughput | High (~20k/sec) | Massive (~2M/sec) | High (Unlimited) |
| Ordering | FIFO | Per Partition | Best-Effort (FIFO optional) |
| Consumer State | Broker tracks Ack | Consumer tracks Offset | Hidden (Visibility Timeout) |
| Best For | Complex Routing, Jobs | CDC, Analytics, Event Sourcing | Simple Async Tasks |
Reliability Checklist
- Idempotency: Use UUID keys to deduplicate processing.
- Retries: Use Exponential Backoff + Jitter.
- DLQ: Configure a Dead Letter Queue for max retries.
- Backpressure: Implement Rate Limiting or Auto-scaling.
- Monitoring: Alert on Queue Depth and Consumer Lag.
Kafka Glossary
- Topic: A category of messages (e.g.,
logs). - Partition: A horizontal shard of a topic. Unit of parallelism.
- Offset: A unique ID for a message in a partition.
- Consumer Group: A set of consumers sharing the work of a topic.
- ISR: In-Sync Replicas. Must be > 1 for high durability.
- Log Compaction: Retaining only the last known value for each key.
3. Scenario Question: Flash Sale Notifications
Problem: You need to send “Deal Started” push notifications to 10 Million users in 5 minutes. Constraint: Users must receive it fast (Low Latency).
Design:
- Pattern: Pub-Sub (Fanout).
- Tool: Kafka (High Throughput). RabbitMQ might choke on 10M messages if not sharded.
- Optimization:
- Topic:
deals.flash_salewith 100 Partitions. - Consumers: 100 Workers (Consumer Group) reading from Kafka.
- Push Service: Workers call FCM/APNS (Apple/Google Push Service).
- Topic:
- Why?: Kafka handles the “Thundering Herd” of 10M events. The workers process at their own pace (Backpressure) without crashing the Push Service.