Merge lp:~cprov/adt-result-checker/qos into lp:adt-result-checker

Proposed by Celso Providelo
Status: Merged
Approved by: Celso Providelo
Approved revision: 10
Merged at revision: 10
Proposed branch: lp:~cprov/adt-result-checker/qos
Merge into: lp:adt-result-checker
Diff against target: 13 lines (+4/-0)
1 file modified
adt_result_checker/__init__.py (+4/-0)
To merge this branch: bzr merge lp:~cprov/adt-result-checker/qos
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+253736@code.launchpad.net

Commit message

Set a fair QoS to our multi-worker environment (prefetch_count=1)

Description of the change

Set a fair QoS to our multi-worker environment (prefetch_count=1)

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

I think the default is prefetch_count=0 right? Is the performance gain of setting this to 1 really helpful for us? I'm not super familiar with the impacts of various qos options in rabbit, so I'm mostly just curious that this is not going to impact us in some other way. Otherwise I'm fine with this.

review: Approve
Revision history for this message
Celso Providelo (cprov) wrote :

Paul,

prefetch_count=0 (along with default prefetch_size=0) means the consumer is telling rabbit to "reserve as many messages as you can for me", which is bad for our multi-worker environment, because workers will compete to reserve messages, but will take quite a long time to process (acknowledge)them. Other workers will starve and be idle most of the time.

prefetch_count=1, means that only one single message will be given to workers at time. So until the test is done, other messages in the queue will be available to other workers to pick them up.

See a more appropriate description at https://www.rabbitmq.com/consumer-prefetch.html

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'adt_result_checker/__init__.py'
2--- adt_result_checker/__init__.py 2015-03-20 02:23:17 +0000
3+++ adt_result_checker/__init__.py 2015-03-20 19:18:06 +0000
4@@ -54,6 +54,10 @@
5
6 def get_consumers(self, Consumer, channel):
7 """Return consumers instances for all configured queues."""
8+ # Set a fair QoS for a multi-worker environment with
9+ # late-acknowledgement. Each worker should only be fed a single
10+ # message at time (prefetch_count).
11+ channel.basic_qos(prefetch_size=0, prefetch_count=1, a_global=False)
12 queues = [kombu.Queue('adt.results.{}'.format(API_VERSION))]
13 return [Consumer(queues=queues, callbacks=[self.process])]
14

Subscribers

People subscribed via source and target branches