Using Queues and Concurrency to Control Performance
Suppose you are measuring the business function of order creation, specifically how long a user must wait to see confirmation that the system has their order. This timing is based on how long the CompleteOrderJob takes to complete. Imagine that Sidekiq is processing only one job at a time: each new CompleteOrderJob must wait for all existing jobs to finish before it is processed.
The following diagram shows how this might play out over a short period of time. You can see that when the first CompleteOrderJob completes, two new jobs are queued, and while the second CompleteOrderJob can be processed next, a third one that comes in must wait for the SendOrderNotificationEmailJob and RequestOrderFulfillmentJob ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access