Messaging Queues
Mechanism for asynchronous communication between components by persisting and delivering messages in a decoupled, ordered manner.
Classification
- ComplexityMedium
- Impact areaTechnical
- Decision typeArchitectural
- Organizational maturityIntermediate
Technical context
Principles & goals
Use cases & scenarios
Compromises
- Message loss due to misconfiguration
- Queue overload leads to increasing latency
- Incorrect delivery semantics cause inconsistencies
- Implement idempotent consumers
- Configure dead-letter queues and retries
- Set up metrics and alerts for queue length and latency
I/O & resources
- Produced messages/events
- Message formats and schemas
- Authentication and authorization data
- Processed messages by consumers
- Monitoring and metrics for observability
- Error and dead-letter entries
Description
Messaging queues are architectural components that decouple producers and consumers by persisting messages for asynchronous delivery. They enable load leveling, resilience to failures, and scalable event-driven integrations across services. Typical concerns include delivery semantics, ordering guarantees, capacity management, and operational complexity.
✔Benefits
- Increased resilience through asynchronous processing
- Improved load distribution and scalability
- Decoupling enables independent development
✖Limitations
- Additional infrastructure and operational overhead
- Latency due to persistence and queue processing
- Complexity around ordering and transactional guarantees
Trade-offs
Metrics
- Queue length
Number of unprocessed messages per queue; indicator of backlog.
- Throughput (messages/s)
Number of processed messages per second; measures capacity.
- Delivery times / latency
Time from creation to processing; important for SLAs.
Examples & implementations
RabbitMQ in microservice architecture
Use of RabbitMQ for reliable task distribution and command synchronization between services.
Kafka for event streaming
Apache Kafka as a distributed log-based platform for high throughput and durable event storage.
AWS SQS in serverless flows
AWS SQS to decouple Lambda-based consumers and to level load in serverless architectures.
Implementation steps
Determine throughput and delivery guarantees requirements
Select appropriate broker or managed service
Introduce schema registry and monitoring, implement consumers
⚠️ Technical debt & bottlenecks
Technical debt
- Quickly implemented retry logic without idempotency checks
- Growing dependence on proprietary broker features
- Missing schema versioning for messages
Known bottlenecks
Misuse examples
- Using a queue for immediate user wait times instead of direct communication
- Persisting sensitive data in messages without encryption
- Excessive partitioning without a consistency strategy
Typical traps
- Undersized broker capacity leads to backlogs
- Lack of observability hampers problem diagnosis
- Unclear delivery semantics between components
Required skills
Architectural drivers
Constraints
- • Broker message count or size limits
- • SLAs for delivery and latency
- • Regulatory requirements for persistence and data protection