Delay Queue Architecture for Scalable Timely Message Delivery
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing message queuing systems face limitations in scalability due to memory capacity constraints in memory queue/time wheel schemas and inflexibility in delay queue schemas, leading to inefficient message delivery and potential transaction failures.
Innovation Solution
A variable and scalable delay queue architecture with ordered sequences of delay queues, each with adjustable fixed delay times, allowing messages to be assigned and moved based on target delivery times, ensuring efficient message delivery and high throughput.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If memory queue/time wheel schema is used to store and sort messages by delay time, then messages can be delivered in order of delay time, but memory capacity is limited and scalability is restricted
Solution Approach 1:
The message queue is segmented into multiple delay queues, each handling a specific time range. This divides the large-scale sorting problem into smaller, manageable segments that can be independently handled, enabling scalability while maintaining delivery order within each segment's time range.
Solution Approach 2:
Instead of sorting messages in a single dimension (by delay time in one large queue), the system introduces a new dimension by creating multiple delay queues organized in a hierarchical structure with levels and groups, allowing messages to be routed based on both delay time and queue position.
2Productivity
If delay queues are created for specific fixed delay times (e.g., 5, 10, 15 minutes), then messages can be delivered at predetermined intervals, but the system becomes inflexible when different delay times are needed
Solution Approach 1:
The delay queue structure is made dynamic by organizing queues in levels and groups rather than using fixed, static delay times. Each delay queue has an associated time range, and the system can adapt to different delay requirements by routing messages to appropriate queues based on their target delivery time within those ranges.
Solution Approach 2:
The system changes the parameter representation from fixed delay times to time ranges associated with each delay queue. This allows the same queue infrastructure to handle variable delay requirements by matching messages to queues whose time ranges encompass the desired delivery time.
3Reliability
If all delayed messages are stored in memory and sorted by delay time, then complete control over message delivery timing is achieved, but memory resources are wasted and throughput is limited
Solution Approach 1:
By segmenting messages into multiple delay queues organized in levels and groups, the system can process and deliver messages in batches from different queues simultaneously, increasing overall throughput while maintaining timing control within each segment's designated time range.
Solution Approach 2:
Multiple delay queues at the same level are merged in terms of processing logic, allowing the system to handle messages from various queues concurrently. This combining approach enables higher throughput by parallelizing message delivery across multiple queues while maintaining individual timing constraints.
Data Source
AI summary
A method of creating a delay queue architecture for relaying messages between a producer and a consumer is provided. The method includes creating an ordered sequence of delay queues. Each delay queue is assigned in the ordered sequence based on a fixed delay time associated with each delay queue. A first message is assigned to a first delay queue of the delay queues in the ordered sequence and a second message is assigned to a second delay queue of the delay queues. The first and second messages have time delays and are assigned to the first and second delay queues based on the time delays. A passage of a first-time delay is detected and the second message is moved to the first delay queue based on the passage of the first-time delay.


