Cast some light on Task Queue execution. I am confused

79 views
Skip to first unread message

Naresh Pokuri

unread,
Dec 24, 2015, 8:38:32 AM12/24/15
to Google App Engine
I am using push queues and little confused with documentation. Lets a I have queue called 'push-task' and I have configured that as follows

       
<queue>
 
<name>push-task</name>
 
<rate>60/h</rate>
 
<bucket-size>120</bucket-size>
 
<max-concurrent-requests>1</max-concurrent-requests>
 
</queue>

Now if I add 5 tasks a to the same 'push-task' queue and each task has 1sec latency then 5 tasks will be completed in 5 sec.

What does it mean by above configuration
1. What is the bucket initial token size? On start bucket get initialized with 120 tokens?
2. 60/h means at any given minute only one token will be available in bucket. So, only one task will get executed in a minute? 

If possible please provide some example. Even if document has some example that would be helpful.

Zeehad (Cloud Platform Support)

unread,
Dec 24, 2015, 3:52:04 PM12/24/15
to Google App Engine

The 5 tasks in the ‘push-task’ queue will be completed after 5 seconds given that they each have 1 sec latency.


1. <bucket-size>120</bucket-size> means the bucket will have 120 tokens initially.

2.  <rate>60/h</rate> will mean a maximum of 60 tasks will be processed per hour.


For example, consider the following:


  • Your above mentioned configurations

  • 100 tasks in the queue

  • 1 second latency each


Due to max-concurrent-request being 1 and rate only allowing 60 tasks per hour, 60 tasks will complete in the first 60 seconds. Then no more tasks will be processed for the next 59 minutes of that hour. After the hour is over, the remaining 40 tasks will be processed in 40 seconds.


Hope that helps. Cheers!

Naresh Pokuri

unread,
Dec 28, 2015, 12:32:25 AM12/28/15
to Google App Engine
Thanks for the reply. When will be bucket refilled? what parameters impact bucket filling?

I have the same configuration in my project for a queue and I have a cron job which adds tasks per every five minutes to that queue. On google console I see one task getting executed in a minute. If I click on 'Run Now' on console all are getting executed in 5 sec. What makes my queue execute a task per minute. Am I missing something here? 

Alex Martelli

unread,
Dec 28, 2015, 1:23:11 PM12/28/15
to google-a...@googlegroups.com
On Sun, Dec 27, 2015 at 9:32 PM, Naresh Pokuri <poku...@gmail.com> wrote:
Thanks for the reply. When will be bucket refilled? what parameters impact bucket filling?

One token is added to the bucket every 1/rate -- so if your rate is 60/h, one token will be added every minute. However, no tokens are added if the bucket is already full (i.e it contains bucket-size tokens; default bucket-size is 5 unless explicitly specified).

No other parameter beyond rate and bucket-size constrain bucket filling.

A queued task will grab a token and execute IF there's at least a token available in the bucket AND this doesn't push the number of tasks concurrently executing on that queue beyond the max-concurrent-requests parameter (default for the latter, 1000, unless explicitly specified). However, max-concurrent-requests constrains task execution, NOT bucket filling.

I think wikipedia, at https://en.wikipedia.org/wiki/Token_bucket , does a good job of presenting the general idea of token-bucket algorithms, beyond the specific use of it in app engine task queues in push mode.


Alex

 

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/7d587334-72d9-42af-9fa7-616868838ac9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages