-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Internal: message processing is now event-based (#500)
Problem: the pending message fetcher and processor use a polling loop to look for messages to fetch/process. This leads to some latency when the pending_messages table is empty as the task sleeps while waiting for new pending messages. Solution: add an exchange + queue in RabbitMQ to signal the arrival of new messages. To avoid modifying the message processor too much and avoid depending on coherency between the DB and RabbitMQ, the fetcher and processor simply spawn a new task that looks for messages and sets an asyncio Event object. The main fetching/processing loop waits on this event (with a timeout). Note that this system is not used for retries as this would require another task that posts messages to the MQ on their next attempt. Retried messages simply wait for the next iteration of the loop (every second). This solution has the following advantages and drawbacks: + No more arbitrary latency when processing new messages + No major modification of the pipeline, even if the MQ system fails for some reason the pending message processor will still process messages every second + No dependency on the state of the message queue, if the RabbitMQ queue is deleted for any reason the processor will keep on working - RabbitMQ overhead (one more exchange + queue).
- Loading branch information
1 parent
9732aa5
commit c4543fa
Showing
12 changed files
with
193 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.