-
-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added long polling support #506
Conversation
introduce new parameter in broker sqs block parameter for long polling is receive_message_wait_time_seconds eg : Q_CLUSTER = { 'name': 'test-queue', 'sqs': { 'aws_region': AWS_S3_REGION_NAME, 'aws_access_key_id': AWS_ACCESS_KEY_ID, 'aws_secret_access_key': AWS_SECRET_ACCESS_KEY, 'receive_message_wait_time_seconds':20 } }
Before I can merge this it needs to be covered in the tests. Just adding the new receive_message_wait_time_seconds parameter would probably fix the coverage. Would also be great if you can add this parameter to the docs. |
receive_message_wait_time_seconds in which file i have to add this parameter for coverage. |
Just find the Let me know if you are having issues with this. |
Thanks a lot for taking the time to do this. |
Alas I think the patch is broken. I'm trying to use it to upgrade may Mailman/django installation. In get_connection, you have:
I think you are doing this as Session() is only expecting the arguments which create an AWS API session, and this isn't a parameter to that call, rather it's a parameter to receive_message(), which is the subsequent call. So without it, the call to create the Session will fail. But the way the code is written, the del config[] affects the global Conf.SQS object, which means by the time it gets to the first call to dequeue, the receive_message_wait_time_seconds attribute has been deleted, and therefore the WaitTimeSeconds is never applied to the params. Net result is I think the merge as stated has ZERO effect. :o( I considered two fixes, and went with the safest, but there may be a better one where you deep copy the config object and pass that to create the Session object, but I'm not a python Guru, so was concerned that the Session(**config) was some kind of call by reference, meaning it may want to add state into that object as a side-effect of the call, so opted for the safer fix. I'm about to move to test the following in production:
Ideally this would have been caught by a test. |
The fix seems to have worked. The CPU floor of my ECS Task (Docker Task) has now reduced from 5.4% to 1.9%; and the SQS calls from 2K/min to 3/min. FYI this represented ~$35/month direct SQS costs plus indirect costs (from the EC2 capacity needed to maintain 3.5% CPU of a t2a.medium instance). I think django_q should consider turning on long polling by default. |
@NigelSwinson i have created a pull request for this issue |
introduce new parameter in broker sqs block
parameter for long polling is receive_message_wait_time_seconds
eg :
Q_CLUSTER = {
'name': 'test-queue',
'sqs': {
'aws_region': AWS_S3_REGION_NAME,
'aws_access_key_id': AWS_ACCESS_KEY_ID,
'aws_secret_access_key': AWS_SECRET_ACCESS_KEY,
'receive_message_wait_time_seconds':20
}
}