LeetDezine — System Design and Internals
Messaging
Initializing search
    • Home
    • Start Here
    • Concepts
    • Estimation
    • Foundation
    • Ascent
    • Expedition
    • Summit
    • Battleground
    • Home
    • Start Here
    • Concepts
      • Fundamentals
          • Introduction
          • Latency
          • Throughput
          • Latency vs Throughput
          • Bandwidth
          • Bandwidth vs Latency vs Throughput
          • Percentiles
          • Interview Cheatsheet
            • SDE-1
            • SDE-2
            • SDE-3
          • Introduction
          • SLI
          • SLO
          • SLA
          • Error Budget
          • Interview Cheatsheet
            • SDE-1
            • SDE-2
            • SDE-3
          • Availability
          • SPOF
          • N+1 Redundancy
          • Availability Patterns
          • Nines of Availability
          • Series vs Parallel
          • Interview Cheatsheet
            • SDE-1
            • SDE-2
            • SDE-3
          • Reliability
          • MTBF & MTTR
          • RTO & RPO
          • MTTR vs RTO
          • Reliability vs Availability
          • Interview Cheatsheet
            • SDE-1
            • SDE-2
            • SDE-3
          • Scalability
          • Interview Cheatsheet
            • Load Balancing
            • Algorithms
            • Hybrid In Production
            • Interview Cheatsheet
              • Fundamentals
              • How It Works
              • Connection Tables
              • Real World
              • Fundamentals
              • Request Flow
              • API Gateway
            • Auto Scaling
            • Connection Draining
            • Cold Start
            • Interview Cheatsheet
          • Fault Tolerance
          • Graceful Degradation
          • Bulkhead
          • Timeout, Retry & Backoff
          • Circuit Breaker
          • Interview Cheatsheet
          • Durability
          • WAL
          • Replication
          • Backups
          • Interview Cheatsheet
          • Race Conditions
          • Pessimistic Locking
          • Optimistic Locking
          • Read/Write Locks
          • MVCC
          • Distributed Locking
          • Idempotency
          • Interview Cheatsheet
          • Authentication & JWT
          • Encryption
          • Interview Cheatsheet
          • What Is A State Machine
          • Implementing In Database
          • Timeout-Driven Transitions
          • Audit Trail vs Overwrite
          • Interview Cheatsheet
          • Functional vs Non-Functional
          • NFRs & Design Decisions
          • Conflicting NFRs
      • Distributed Systems
        • General Problem
        • Network Partitions
        • During Partition
        • Split Brain
        • Quorum vs Consensus
        • Interview Cheatsheet
        • CAP Theorem
        • CP vs AP
        • Interview Cheatsheet
        • PACELC Theorem
        • PA/EC — The Middle Ground
        • System Examples
        • Interview Cheatsheet
        • Consistency Models
        • When To Use
        • Interview Cheatsheet
        • What Is Replication
        • Sync vs Async
        • Replication Lag
        • Failover
        • Multi-Primary
        • Interview Cheatsheet
        • What Is Sharding
        • Shard Key
        • Sharding Strategies
        • Consistent Hashing
        • Cross-Shard Joins
        • Resharding
        • Over-Sharding
        • Relational DBs
        • Interview Cheatsheet
        • What Is Consensus
          • What Is Raft
          • Leader Election
          • Term Numbers
          • Log Replication
          • Log Replication Failures
          • Fencing Tokens
          • ZooKeeper Election
          • Redis Distributed Locks
          • What Is Paxos
          • Paxos Phases
          • Paxos Retry Cases
          • Paxos Livelock
        • Clock Drift
        • NTP
        • Lamport Clocks
        • Vector Clocks
        • GPS & Atomic Clocks
        • TrueTime Uncertainty
        • The Problem
        • Why Locks Fail
        • G-Counter
          • Insert
          • Delete
          • OT vs CRDT
        • Heartbeats
        • Gossip Protocol
        • Phi Accrual Failure Detector
        • The Problem
        • Hashing & Buckets
        • The Tree
        • Anti-Entropy
        • The Problem
        • What Is etcd
        • Leases & TTL
        • Fencing Tokens
        • Lock vs Job Tracking
      • Caching
          • Fundamentals
          • Quick Decision Map
          • Read Strategies
          • Write Strategies
          • Interview Cheatsheet
          • Eviction vs TTL
          • LRU
          • LFU
          • FIFO & TTL
          • Interview Cheatsheet
          • Warming vs Refresh-Ahead
          • Refresh Ahead
          • Cache Warming
          • Interview Cheatsheet
          • Choosing a Strategy
          • TTL-Based
          • Event-Driven
          • Write-Through
          • Cache Versioning
          • Stale-While-Revalidate
          • Interview Cheatsheet
          • Why Single Node Fails
          • Consistent Hashing
          • Cache Coherence
          • Replication
          • Two-Level Caching
          • Node Failure
          • Interview Cheatsheet
          • Diagnosing the Problem
          • Cache Stampede
          • Cold Start
          • Cache Penetration
          • Cache Avalanche
          • Interview Cheatsheet
          • Data Structures
          • Patterns
          • Persistence
          • Streams
          • Single-Threaded Event Loop
          • SDE-1
          • SDE-2
          • SDE-3
      • Storage & Databases
        • Why Not Files
        • How Files Store Data
        • How DBs Store Data
        • Row-Oriented Storage
        • Column-Oriented Storage
        • The Problem
        • Atomicity
        • Consistency
        • Durability
        • ACID vs BASE
        • Interview Cheatsheet
          • Isolation Problems
          • Isolation Levels
          • Choosing Isolation
          • Pessimistic vs Optimistic Locking
          • Interview Cheatsheet
          • External Locking Strategies
          • The Problem
          • 2PC vs Saga
          • Interview Cheatsheet
            • Working
            • Failures
            • Solutions
            • 2PC In Practice
            • What Is Saga
            • Choreography
            • Orchestration
          • SDE-1
          • SDE-2
          • SDE-3
        • Relational Model
        • Normalisation
        • Denormalisation
        • Joins
        • Views
        • Indexes
        • Hash Index
        • B+ Tree
        • LSM Tree Writes
        • LSM Tree Reads
          • The Problem
          • Why Composite Index Fails
          • Geohash
          • S2 Cells
          • Interview Cheatsheet
        • What Is CDC
        • Outbox Pattern
        • Interview Cheatsheet
        • Offset Pagination
        • Cursor Pagination
        • Interview Cheatsheet
        • Cost Of A Connection
        • Connection Pool
        • Interview Cheatsheet
        • The Problem
        • How It Works
        • Replication Lag
        • Interview Cheatsheet
      • Database Types
        • Redis
        • Memcached
        • KV Positioning
        • Interview Cheatsheet
        • Document Model
        • Indexes
        • Embedding vs Referencing
        • Replication & Sharding
        • Limitations
        • Interview Cheatsheet
          • Why Column Family
          • Column-Oriented Storage
          • Row Keys
          • Mental Model
          • Ring Architecture
          • Write Path
          • Read Path
          • Replication & Consistency
          • Tombstones
          • Interview Cheatsheet
          • Query-First Modeling
          • Architecture
          • Cassandra vs Bigtable
          • Data Model
          • Consistency
          • Query API & Indexes
          • Redis vs DynamoDB
          • TTL & Sessions
          • Interview Cheatsheet
        • Problem With SQL Search
        • Inverted Index
        • Indexing Pipeline
        • Ranking TF-IDF BM25
        • Elasticsearch Architecture
        • Where It Fits
        • Interview Cheatsheet
        • Why Not SQL
        • Graph Data Model
        • Cypher Query Language
        • Use Cases
        • Interview Cheatsheet
        • Object Storage Model
        • Presigned URLs
        • Multipart Upload
        • Content-Addressable Storage
        • Chunk-Level Deduplication
        • Storage Classes
        • Interview Cheatsheet
        • The Problem
        • Spanner TrueTime
        • Spanner Transactions
        • When To Use
        • Interview Cheatsheet
        • The Problem
        • OLTP
        • OLAP
        • ETL vs CDC
        • Interview Cheatsheet
        • Decision Framework
        • DB Cheatsheet
        • The Process
        • Entities & Relationships
        • Access Patterns
        • Instagram Schema
        • Red Flags
      • Messaging
        • Message Queues
        • Task Queue
        • What Is a Broker
        • Pub/Sub
        • Delivery Guarantees
        • Dead Letter Queue
        • Message Ordering
        • Delay Queues
        • Priority Queues
        • Fan-Out on Write
        • Fan-Out on Read
        • What Is SQS
        • Standard vs FIFO
        • Timeout & Retries
        • Idempotency & DLQ
        • Scaling
        • Retention & Replay Limits
        • Delay Queues
        • Producer/Consumer Model
        • SNS Fan-Out
        • What Is RabbitMQ
        • Direct vs Fanout Exchange
        • Topic Exchange
        • Headers Exchange
        • ACK/NACK/Requeue
        • Crash & Redelivery
        • Prefetch & Fairness
        • Durable Queues
        • Delivery Guarantees
        • Retries & DLQ
        • Message Ordering
        • Bottlenecks
        • Scaling
      • Event Broker
        • Why Kafka Exists
        • Writes & Page Cache
        • Topics
        • Partitions
        • Brokers
        • Replication
        • ISR
        • Hot Partitions
        • Partitioners
        • Batching
        • Compression
        • Pull Model
        • Offsets
        • Offset Storage
        • Before vs After
        • Consumer Groups
        • Rebalancing
        • Retention
        • Exactly-Once Processing
        • Consumer Lag
        • Scaling Consumers
        • Load Shedding
        • Backpressure Signals
        • Fundamental Difference
        • After Read
        • Retention
        • Routing & Fanout
        • Ordering & Throughput
        • When To Choose What
      • Event-Driven Patterns
        • Event Sourcing
        • What Is CQRS
        • Read Models
        • Consistency
        • Dual Write
        • Outbox Pattern
        • What Is CDC
        • Debezium
        • What Is Inbox Pattern
        • Inbox + Outbox Combined
        • Full Flow
      • Data Processing
        • Why Stream Processing
        • Window Types
        • Watermarks
        • Statefulness
        • Crash Recovery
          • Why Batch Processing
          • MapReduce
          • Map Phase
          • Shuffle Phase
          • Reduce Phase
          • Combiner
          • Hot Keys
          • Why Spark
          • Spark Architecture
          • DAG Optimization
        • Lambda Architecture
        • Kappa Architecture
        • Lambda vs Kappa
        • Why Schema Evolution
        • Schema Registry
        • Protobuf
        • Avro Basics
        • Avro Flow
    • Estimation
      • Latency Numbers
      • Database Numbers
      • Message Streams
      • Data Sizes
      • Bandwidth & Servers
      • Estimation Framework
    • Foundation
      • Unique ID Generator
          • System Overview
          • Functional Requirements
          • Estimation
          • Non-Functional Requirements
          • API Design
          • Base Architecture
        • Deep Dives
          • Single Server Counter
          • Multi-Server Problem
          • UUID
          • Ticket Server
          • Pre-Generated Key Pool
          • Snowflake
          • Comparison
          • Clock Skew
          • Fault Isolation
          • SLI / SLO Connection
          • Measuring Latency
          • Measuring Availability
          • Alerting
          • Error Budget
          • Unique ID Generator Architecture
      • URL Shortener
          • Functional Requirements
          • Estimation
          • Non-Functional Requirements
          • API Design
          • Base Architecture
        • Deep Dives
            • Raw IDs
            • Hashing
            • Random + Collision Check
            • UUID Base64 Trim
            • Snowflake Base64
            • UUID Snowflake Base62
            • Truncation Problem
            • DB Choice
            • Schema
            • Why Sharding
            • Sharding Key
            • Consistent Hashing
            • How Many Shards
            • Replication
            • Read Your Own Writes
            • Why Caching
            • Cache Size
            • Cache Strategy
            • Eviction Policy
            • Updated Flow
            • The Spike Problem
            • Hot Key — Detection
            • Hot Key — Local App Cache
            • Hot Key — Redis Key Replication
            • Hot Key — Broadcast Promotion
            • Load Balancing
            • API GW SPOF
            • Updated Architecture
            • Collision At Scale
            • Bloom Filter
            • Key Pool
            • KGS Sequential Generation
            • Redis INCR vs KGS
            • The Problem
            • Tiered Storage
            • Detecting Cold URLs
            • Fault Isolation
            • Redis Down
            • DB Shard Primary Down
            • KGS Down
            • Other Failures
          • SLI / SLO Connection
          • Measuring Latency
          • Measuring Availability
          • Alerting
          • Error Budget
          • URL Shortener Architecture
    • Ascent
      • Notification System
          • System Overview
          • Functional Requirements
          • Estimation
          • Non-Functional Requirements
          • API Design
          • Base Architecture
        • Deep Dives
            • DB Selection
            • Schema
            • Queue Selection
            • Kafka Design
            • Push Worker
            • SMS Worker
            • Email Worker
            • Problem And Naive Approach
            • Scheduler DB
            • Jitter
            • Dispatch Flow
            • Retry Strategy
            • DLQ
            • Failure Handling
            • Rate Limiting
            • APNs Down
            • Cassandra Down
            • Kafka Down
            • Redis Down
            • Scheduler Down
        • Notification System Architecture
          • SLI / SLO Connection
          • Measuring Latency
          • Measuring Availability
          • Alerting
          • Error Budget
      • Pastebin
          • Functional Requirements
          • Estimation
          • Non-Functional Requirements
          • API Design
          • Base Architecture
        • Deep Dives
            • Requirements
            • Approaches
            • Redis Counter
            • Custom Alias
            • DB Choice
            • Content-Addressable Storage
            • Ref Counting
            • Schema And Indexes
            • Write Read Delete Flows
            • Sharding
            • Why Cache
            • What To Cache And How
            • Cache Sizing
            • Cache Invalidation
            • Hot Key Problem
            • Why Fault Isolation
            • Service Split
            • DB Standby
            • Circuit Breaker
            • Why Async Upload
            • Failure Problem
            • State Machine
            • Retry Strategy
            • Read Path Behaviour
            • Why Cleanup Job
            • Cleanup Flow
            • Distributed Workers
            • Watchdog
            • Indexing Strategy
          • SLI / SLO Connection
          • Measuring Latency
          • Measuring Availability
          • Alerting
          • Error Budget
        • Pastebin Architecture
    • Expedition
      • Rate Limiter
          • Functional Requirements
          • Estimation
          • Non-Functional Requirements
          • API Design
          • Base Architecture
        • Deep Dives
            • Fixed Window Counter
            • Sliding Window Log
            • Sliding Window Counter
            • Token Bucket
            • Leaky Bucket
            • Algorithm Comparison
            • Atomicity Problem
            • Redis Cluster
            • Rule Storage
            • Rate Limiter Node Down
            • Redis Node Down
            • Rule DB Down
            • API Gateway Down
            • DDoS And Defense Layers
        • Rate Limiter Architecture
          • SLI / SLO Connection
          • Measuring Latency
          • Measuring Availability
          • Alerting
          • Error Budget
    • Summit
      • KV Store
          • Functional Requirements
          • Estimation
          • Non-Functional Requirements
          • API Design
          • Why Base64
          • Why Not Single Leader
          • Why Not Multi Leader
          • Why Leaderless
          • Base Design
        • Deep Dives
            • Terminology
            • How The Ring Works
            • Quorum Writes
            • Hinted Handoff
            • Read Repair
            • Anti-Entropy
            • B+Tree vs LSM Tree
            • LSM Tree Internals
              • What Is Compaction
              • Size-Tiered Compaction
              • Leveled Compaction
            • Bloom Filters
            • Putting It All Together
            • The Problem
            • Gossip Protocol
            • Failure Detection
            • The Problem
            • Solution
            • How TTL Works
            • Node Failure
              • The Problem
              • Silent Corruption
              • Disk Full
            • Network Partition
            • Cascading Failures
            • Coordinator Failure
          • SLI / SLO Connection
          • Measuring Latency
          • Measuring Availability
          • Alerting
          • Error Budget
        • Key-Value Store Architecture
      • Netflix
          • System Overview
          • Functional Requirements
          • Bitrate
          • Estimation
          • Non-Functional Requirements
          • API — Home Feed
          • API — Stream
          • API — Search
          • Homepage Browse
          • Download
          • Streaming
          • Search
            • Transcoding
            • Adaptive Bitrate
            • Manifest
            • HLS vs DASH
            • The Problem
            • CDN
            • Updated Architecture
            • Content Metadata DB
            • User Data DB
            • The Problem
            • Elasticsearch
            • Search Architecture
            • Write Pattern
            • Cross-Device Sync
            • Updated Architecture
            • Peak Traffic
            • Circuit Breaker
            • Cache Failure
            • CDN Failure
          • SLI / SLO Connection
          • Measuring Latency
          • Measuring Availability
          • Alerting
          • Error Budget
        • Netflix Architecture
    • Battleground
      • WhatsApp
          • Functional Requirements
          • Estimation
          • Non-Functional Requirements
          • API Design
          • The Problem
          • Short Polling
          • Long Polling
          • SSE
          • WebSockets
          • Comparison
          • Overview
          • WebSocket Connection Flow
          • Message Send Flow
          • Chat History Flow
          • API GW And LB
        • Deep Dives
            • DB Choice
            • Schema
            • Tiered Storage
            • Sharding
            • Hot Partition — Overview
            • Hot Partition — Detection
            • Hot Partition — Salting
            • Hot Partition — Dynamic N
            • Hot Partition — Read Query
            • Hot Partition — Registry
            • Hot Partition — Edge Cases
            • Updated Architecture
            • The Problem
            • Client Timestamps
            • Time Machine Problem
            • Server Timestamps
            • Dedicated Timestamp Service
            • Per-User Sequence
            • Per-Conversation Sequence
            • Redis INCR
            • Full Ordering Flow
            • Schema Update
            • Display Time
            • Updated Architecture
            • The Problem
            • Detecting Offline
            • Naive Mailbox
            • Message ID Only
            • Why Not Kafka
            • Last Delivered Seq
            • Pending Deliveries Table
            • Write Flow
            • Push Notifications
            • Notification Payload
            • Internet Turns On
            • Notification Reply
            • Updated Architecture
            • The Three Ticks
            • Naive Status Column
            • Status Table
            • Delivered Ack
            • Read Receipt Flow
            • APNs Not Reliable
            • Notification Banner
            • Phone Off Three Days
            • Offline Status Sync
            • Read Receipts — Mutual Rule
            • Read Receipts — Where To Store Flag
            • Read Receipts — Client vs Server Check
            • Read Receipts — How Mutual Rule Enforces
            • Last Seen — What Is It
            • Last Seen — How It Gets Recorded
            • Last Seen — How Alice Sees It
            • Last Seen — Privacy And Mutual Rule
            • Last Seen — vs Read Receipts
            • Updated Architecture
            • Inbox Load Flow
            • N+1 And Denormalization
            • Conversations Table Schema
            • LSM Tree And Immutable Keys
            • Option A vs Option B
            • Redis Sorted Set
            • Unread Count
            • Updated Architecture
            • Message History Cache
            • Profile Cache
            • Cache Invalidation
            • Cold Start And Coalescing
            • Updated Architecture
            • Thundering Herd — Redis Sharding
            • Connection Storm — The Problem
            • Connection Storm — Kafka Queue Delay
            • Connection Storm — Offline Delivery Fallback
            • Rate Limiting — Why Not API Gateway
            • Rate Limiting — Connection Server Limit
            • Rate Limiting — Centralised Redis Counter
            • Rate Limiting — Client Notification
            • Backpressure — The Problem
            • Backpressure — In-Memory Queue
            • Backpressure — Thread Pool vs MQ
            • Backpressure — Load Shedding
            • Updated Architecture
            • Connection Server Failure — Client Reconnect
            • Connection Server Failure — Registry Cleanup
            • Connection Server Failure — Stale Registry Fallback
            • Connection Server Failure — Reconnect Storm
            • DynamoDB Failure — Circuit Breaker
            • DynamoDB Failure — Fallback And Message Loss
            • Redis Failure — Inbox
            • Redis Failure — Profile Cache
            • Redis Failure — Other
        • WhatsApp Architecture
          • SLI / SLO Connection
          • Measuring Latency
          • Measuring Availability
          • Alerting
          • Error Budget
    1. Home
    2. Concepts
    3. Messaging
    leetdezine.com
    06

    Concepts

    Messaging

    Queues, brokers, and delivery semantics. The layer between services that determines whether your system is reliable or just fast.

    Fundamentals
    Message queues, task queues, pub/sub, delivery guarantees, DLQs, ordering, delay queues, and fan-out patterns.
    Pub/SubDelivery GuaranteesDLQFan-Out
    Open topic →
    SQS
    Standard vs FIFO queues, visibility timeouts, idempotency, DLQ wiring, scaling, and SNS fan-out patterns.
    Standard vs FIFOVisibility TimeoutSNS Fan-OutDLQ
    Open topic →
    RabbitMQ
    Exchange types, ACK/NACK, prefetch, durable queues, retry strategies, and where RabbitMQ beats simpler queues.
    ExchangesACK/NACKPrefetchDurable Queues
    Open topic →
    Previous
    Red Flags
    Next
    Message Queues