Sharded Queue Delayed Message Delivery
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing message queue systems face challenges in scaling performance due to contention for 'hot' messages and excessive interconnect communication, especially when enqueue and dequeue sessions are distributed across multiple systems, and they struggle with precise delivery of delayed messages without dedicated resources and latency issues.
Innovation Solution
A database management system (DBMS) maintains delayed and non-delayed messages within a pair of shards, staging non-delayed messages in a non-delay shard and delayed messages in time bucket child shards, allowing for correct interleaved ordering and efficient bulk deletion by using a sub-routine that virtually orders delayed messages by delivery time, eliminating the need for background processes and reducing latency.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If delayed messages are stored interleaved with non-delayed messages in the same shard, then delivery precision is improved, but bulk deletion efficiency deteriorates due to inability to delete non-delayed messages before delayed ones
Solution Approach 1:
The patent divides the message queue into separate shards: delay shards store only delayed messages while non-delay shards store only non-delayed messages. This segmentation allows independent bulk deletion operations in each shard type, resolving the contradiction by enabling efficient bulk deletion in non-delay shards without being blocked by delayed messages, while maintaining precise delivery tracking in delay shards.
2Measurement precision
If delayed messages are moved from staging area to message queue at delivery time, then delivery precision is improved, but system complexity increases due to need for background processes and time tracking
Solution Approach 1:
The patent performs preliminary classification of messages into delay shards or non-delay shards at enqueue time based on whether they have a delay. Delayed messages are staged in delay shards with their delivery time recorded, and made visible to subscribers at the predetermined delivery time without requiring background processes to move them. This eliminates the need for complex background processes while maintaining precise delivery timing.
3Productivity
If message queue is sharded horizontally across multiple systems, then scalability is improved, but interconnect communication increases
Solution Approach 1:
The patent applies local quality by creating dedicated delay shards and non-delay shards with specific functionalities. Each shard type is optimized for its purpose: non-delay shards enable efficient bulk deletion operations, while delay shards handle time-based message visibility. This local optimization within shards reduces the need for complex coordination and interconnect communication across distributed systems, improving scalability while minimizing communication overhead.
Data Source
AI summary
A DBMS maintains delayed and non-delayed messages within a non-delay shard and a delay shard that function as a pair. The DBMS stages non-delayed messages in enqueue-time order within the non-delay shard, and maintains a non-delay dequeue pointer that moves in physical order of the enqueued non-delay messages. The DBMS stages delayed messages in enqueue-time order within bucket shards of the delay shard. Each bucket shard, of a delay shard, represents a time span of delivery times, and messages are assigned thereto based on message delivery time. The delay dequeue pointer comprises a sub-routine to determine the message with the minimum delivery time within a current bucket shard with a time span that includes the current time. The DBMS delivers the next available message out of the delayed and non-delayed shards by comparing the delivery time of the next available message from each shard and delivering the earliest available message.


