Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 429: Insufficient tokens (DefaultGroupUSER-100s) What defines a user?

tl/dr do 100 devices all using the same Client ID count as 100 users, with their own limits, or one user sharing limits?

I have a webpage which reads and writes to a Google Sheet.

Because the webpage needs to know if a cell has changed, it polls the server once every 1000ms:

var pollProcId = window.setInterval(pollForInput, 1000);

where pollForInput does a single:

gapi.client.sheets.spreadsheets.values.get(request).then(callback);

When I tried to use this app with a class of 100 students I got many 429 error codes (more than I got successful reads) in response to google.apps.sheets.v4.SpreadsheetsService.GetValues requests:

Error code 429-a-thon

Many of my users never got as far as seeing even the first request come back.

As far as I can make out, these are AnalyticsDefaultGroupUSER-100s errors which, according to the error responses page:

Indicates that the requests per 100 seconds per user per project quota has been exhausted.

But with my app only requesting once per 1000 milliseconds, I wouldn't expect to see this many 429s as I have a limit of 100 requests per 100 seconds (1 per second) so only users whose application didn't complete in 100 seconds should have received a 429.

I know I should implement Exponential Backoff (which I'll do, I promise) but I'm worried I'm misunderstanding what a "user" in this context is.

Each user is using their own device (so presumably has a different IP address) but they are all using my "Client ID".

Does this scenario count as many users making one request per second, or a single user making a hundred requests per second?

like image 208
LondonRob Avatar asked Nov 08 '22 03:11

LondonRob


1 Answers

Well, the user in the per user quota means that a single user making a request. So let's take the Sheets API, it has a quota of 100 for the Read requests per 100 seconds per user. So meaning only a single user can make a request per second. Note that Read request has a same set of quota as the Write request. But these two sets of quotas have their own set of quota and didn't share the same limit quota.

If you want a higher quota than the default, then you can apply for a higher quota by using this form or by visiting your developer console, then click the pencil icon in the quota that you want to increase.

I also suggest you to do the Exponential Backoff as soon as possible, because it can help you to avoid getting this kind of error.

Hope it helps you.

like image 135
KENdi Avatar answered Dec 20 '22 15:12

KENdi