2

I need an explaination.

I use DriveAPI with a service account which has a domain-wide delegation of authority on my domain.

I send requests connected with the service account as a user like this:

credentials = SignedJwtAssertionCredentials(
    dico_account['client_email'],
    dico_account['private_key'],
    scope=['https://www.googleapis.com/auth/drive'],
    sub= "user_email@mydomain.fr")

I would like to know if the quota per second per user is for the service account or for the user?

Controlix
  • 437
  • 2
  • 11

1 Answers1

1

enter image description here

The Google Drive API default allows you to send 1 million requests per second per user. Now how do they decide what a user is. Well its the IP address normally and the authenticated user.

In the case of a service account you have only one authenticated user. So by default your application will be able to send 1 million requests a second. and it should be based upon the IP address so assuming that I am sending it and you are sending it from two different IPs there should be two different sets of quota. (If that made any sense at all.)

Now this can be tweaked. Standard Query Parameters If you have a way of knowing that your service account is requesting for me vs for yourself then you can send quotaUser. So when I run your application I am able to make a million requests a second and you are also able to make a million requests a second. QuotaUser just needs to be tacked onto the end of what ever request you are making.

The google drive API has such a big quota that I have never tested with it. However I have used quotauser to get around the quota in the Google Analytics API, all the APIs should be the same so this information should still be valid for you and Google Drive.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • I try to always send quota user you never know if you have two people at the same ip sending requests against your app. I have been known to send a random number sometimes as well :) – Linda Lawton - DaImTo Jan 08 '16 at 10:05
  • There is something that bother me, you have 1.000.000 requests/second/user but i have only 10. Is there something wrong with my configuration? – Controlix Jan 08 '16 at 13:34
  • click the little pencil thing on the right you should be able to increase it. Google has been messing around with / breaking the google developer console lately. Who knows what default is these days. – Linda Lawton - DaImTo Jan 08 '16 at 13:40
  • do you have billing enabled? – Linda Lawton - DaImTo Jan 08 '16 at 14:00
  • eheh nope... Is it necessary? On your screenshot it's written free quota. – Controlix Jan 08 '16 at 14:06
  • I tried to set it on another account it wont let me up it. Its either because I have billing enabled or that project is part of some beta testing special permission thing that I cant remember. Screen shot was taken from my test everything project which is what I uses for special access. looks like 10 is the max (when your not special) sorry for any confusion that may have caused. – Linda Lawton - DaImTo Jan 08 '16 at 14:17
  • Note that aside from the static quota limits above, there is a throughput quota which is orders of magnitude smaller and will rate limit your app with a 403 error after around 25 simultaneous requests. – pinoyyid Jan 09 '16 at 13:09
  • Ok. Is it the same for batch request? I mean, i have tried to use batch request as recommended in the drive api for big amount of permission changes. It's said that you can insert up to 1000 request in the same batch request but when i tried, i got "random" 403 User Rate Limit Exceeded. I want to mention that i use the API in python – Controlix Jan 11 '16 at 08:33
  • 1
    Batch unfortunately is under the same quota limits as normal requests. Which IMO defeats the purpose of having it batch. – Linda Lawton - DaImTo Jan 11 '16 at 08:49
  • Ok, So the tips in the documentation that say for a big amount of requests use batch request is wrong... :/ What would you recommended to me to do more that 1000 permissions changes? And to do it as fast as possible not one by one – Controlix Jan 11 '16 at 09:13
  • 1
    There documentation says for big number of request using batch will probably help with speed of your sending it and load on your server (HTTP wise) and their server. It doesn't say that it will prevent issues with quota. Batch them so that it only sends the 10 a second or play with the quota user a little to see if you can get some more speed out of it. – Linda Lawton - DaImTo Jan 11 '16 at 09:24
  • So. I use quotaUser as you said like this unicode(random.randint(1, 9999999999999999999999999999999999999999)) and i only send request to _files_ 20 by 20 and _permissions_ 50 by 50 and it'seems to work quite well. I also add the [exponential-backoff](https://developers.google.com/drive/v2/web/handle-errors#exponential-backoff) cause sometimes I continue to get a 403 user rate limit exceeded – Controlix Jan 11 '16 at 16:22