bucket size for task.

155 views
Skip to first unread message

Trez Ertzzer

unread,
Nov 17, 2015, 12:09:36 PM11/17/15
to Google App Engine
Hello.
I have been reading a lot of things about tasks and rate and bucket size but I cannot figure out how it works.

suppose the rate is 10/s and the bucket size is 5.
suppose that I never added any task yet.

now I add 20 tasks.
can you describe how the tasks will be executed?

I understood, that 5 tasks will execute immediatly.
then what will happen...?
After how long another task will start? (and how many will start...)


thank you.


PS: I read this:
https://groups.google.com/forum/#!searchin/google-appengine/bucket$20task/google-appengine/A1vC7raLfuY/h0Bi82Y5HCcJ
and this
https://groups.google.com/forum/#!searchin/google-appengine/bucket$20size/google-appengine/4qBjwhvp_kU/wUlZAOJmOK8J

but the information are really not clear

Patrice (Cloud Platform Support)

unread,
Nov 17, 2015, 2:10:26 PM11/17/15
to Google App Engine
Hi,

Since you have a bucket size of 5, the system will immediately start the 5 tasks you've asked. Then, because of the rate of your queue, over time (each tenth of a second) your queue should get a new "token" that can be used by your tasks. Depending on a lot of factor, the system can decide to "hold" onto your token to only give you a significant amount (so instead of a new token every tenth of a second, you may get a group of 5 tokens each half-second). 

For more information, I would suggest reading the official doc (I linked the section about processing rates, but the whole doc is helpful here)

Cheers!

Jason Collins

unread,
Nov 17, 2015, 2:15:53 PM11/17/15
to Google App Engine
I think of it this way:

- a task will execute if there is a token in the bucket (by consuming the token)
- the bucket size can be defined to hold a particular number of tokens
- the bucket will refill tokens at the queue rate

So, when the bucket is "empty", you are effectively processing at your queue rate (i.e., the rate at which the bucket is being refilled). The max bucket size is 100, so this allows you to have a small burst in processing if desired. 

This is the clearest description from the docs:


The task queue uses token buckets to control the rate of task execution. Each named queue has a token bucket that holds a certain number of tokens, defined by the bucket_size directive. Each time your application executes a task, it uses a token. Your app continues processing tasks in the queue until the queue's bucket runs out of tokens. App Engine refills the bucket with new tokens continuously based on the rate that you specified for the queue.

Reply all
Reply to author
Forward
0 new messages