Task queue: Allow only one task at a time per user

1 view
Skip to first unread message

Rookie via StackOverflow

unread,
Mar 4, 2015, 2:33:03 AM3/4/15
to google-appengin...@googlegroups.com

In my application, I need to allow only one task at a time per user. I have seen that we can set max_concurrent_requests: 1 in queue.yaml. but this will allows only one task at a time in a queue.

When a user click a button, a task will be initiated and it will add 50 task to the queue. If 2 user click the button in almost same time total task count will be 100. If i give max_concurrent_requests: 1 it will run only one task from any of these user.

How do i handle this situation ?



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/28848740/task-queue-allow-only-one-task-at-a-time-per-user

David McElhaney via StackOverflow

unread,
Mar 4, 2015, 3:12:57 AM3/4/15
to google-appengin...@googlegroups.com

You can specify as many queues as you like in queue.yaml rather than just using the default push queue. If you feel that no more than, say, five users at once are likely to contest for simultaneous use of them then simply define five queues. Have a global counter that increases by one and wraps back to 1 when it exceeds five. Use it to assign which queue a given user gets to push his or her tasks to at the time of the request. With this method, when you have six or more users concurrently adding tasks, you are no worse off than you currently are (in fact, likely much better off).

If you find the server overloading, turn down the default "rate: 5/s" to a lower value for some or all of the queues if you have to, but first try lowering the bucket size, because turning down the rate is going to slow things down when there are not multiple users. Personally, I would first try only turning down the four added queues and leave the first queue fast to solve this if you have performance issues that you can't resolve by tuning the bucket sizes.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/28848740/task-queue-allow-only-one-task-at-a-time-per-user/28849410#28849410
Reply all
Reply to author
Forward
0 new messages