Skip to content

External Storage: Google Drive: 403 User Rate Limit Exceeded #20481

Closed

Description

@swurzinger

Steps to reproduce

  1. Set up Google Drive as external Storage. In my case I was accessing via a shared (sub)folder
  2. Upload a lot of files to that folder e.g. using the ownCloud client (probably also download?)
  3. Errors will occur if more than e.g. 10 requests/second

Expected behaviour

Files should be uploaded without errors.

Actual behaviour

Error: (403) User Rate Limit Exceeded

Google Drive has a limitation of maximum requests per second, that is set to 10 max according to Google's API documentation and the (max) value set in the Google Developer Console.

According to Google's documentation an application should implement exponential backoff when it gets that error, see https://developers.google.com/drive/web/handle-errors#implementing_exponential_backoff

Although owncloud/google returns a 403 error the upload succeeds sometimes, see also http://stackoverflow.com/questions/18578768/403-rate-limit-on-insert-sometimes-succeeds

Finally the owncloud client uploaded all my files successfully, I guess it has retried the ones that failed initially.

Server configuration

Operating system:
Linux af91f 2.6.32-504.8.1.el6.x86_64
Web server:
Apache (unknown version; shared hosting provider)
Database:
5.5.46 - MySQL Community Server
PHP version:
PHP Version 5.4.45
ownCloud version: (see ownCloud admin page)
ownCloud 8.2.0 (stable)
Updated from an older ownCloud or fresh install:
fresh install
List of activated apps:
default + external storage

The content of config/config.php:
config.txt

Are you using external storage, if yes which one: local/smb/sftp/...
Yes, Google Drive.

Are you using encryption: yes/no
No

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
No

Client configuration

Browser:
irrelevant

Operating system:
irrelevant; in my case it was a Windows XP Virtual Machine

Logs

Web server error log

empty

ownCloud log (data/owncloud.log)

owncloud.txt

Browser log

irrelevant

Activity

  1. PVince81 commented on Nov 16, 2015

    @PVince81
    Contributor

    The only way to fix this is trying to reduce the number of API calls.
    Currently it is likely that too many calls are made.

    Such repeated calls could be buffered/prevented by using a local stat cache, similar to #7897

  2. swurzinger commented on Nov 16, 2015

    @swurzinger
    Author

    I really like the idea of buffering the API requests. That would both improve speed and reduce the number of requests.

    Another way to deal with that behavior is to retry the request when it fails with that error as Google suggests. The question is whether that's the task of files_external or the client. For more abstract things I'd say this is the task of the client, for internal things I'd say this can be the task of files_external.

  3. PVince81 commented on Dec 23, 2015

    @PVince81
    Contributor

    A bit of research shows that the AWS library and others are referring to a curl plugin called "BackoffStrategy".

    That might be it: https://github.com/Guzzle3/plugin-backoff/blob/master/CurlBackoffStrategy.php
    It seems to react on some error codes and then will try again after a delay.
    That plugin isn't available in ownCloud / 3rdparty libs so might need to be included.

  4. swurzinger commented on Dec 23, 2015

    @swurzinger
    Author

    BackoffStrategy seems to implement what I mentioned in the first post and is recommended by Google. Here's the link again (it is from the REST API, but that applies to the other APIs as well): https://developers.google.com/drive/web/handle-errors#implementing_exponential_backoff

    Batching will probably not help in regard of this issue as "A set of n requests batched together counts toward your usage limit as n requests, not as one request." (from https://developers.google.com/drive/v2/web/batch)

  5. PVince81 commented on Dec 23, 2015

    @PVince81
    Contributor

    Unfortunately it seems the library OC uses doesn't use the Curl library but rather uses PHP's curl_xxx statements directly: https://github.com/owncloud/core/blob/v8.2.2/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Curl.php#L85

    So even if that plugin was added, I'm not sure it would fit in.
    We'd need to find another library that actually uses Guzzle

  6. added this to the milestone on Feb 19, 2016
  7. PVince81 commented on Feb 19, 2016

    @PVince81
    Contributor

    @davitol this is what you observed yesterday

  8. davitol commented on Feb 19, 2016

    @davitol
    Contributor

    @PVince81 thanks 😺

  9. PVince81 commented on Feb 29, 2016

    @PVince81
    Contributor

    Setting this to critical, it has been observed already 3-4 times in different environments.

  10. LukasReschke commented on Feb 29, 2016

    @LukasReschke
    Contributor

    Considering that the limit is 1000 requests per 100 seconds per user we probably need some change detection here. Otherwise this seems like something that one can easily fall into again.

  11. thefirstofthe300 commented on Mar 14, 2016

    @thefirstofthe300

    I too am experiencing this issue on OC 9. I am attempting to upload a music library to ownCloud so I have a lot of little files being synced. If you need any more logs, I will happily provide them.

  12. 31 remaining items

  13. Trefex commented on Nov 30, 2016

    @Trefex

    @PVince81 upload a lot of files to Google Drive and sync everything to your local machine.

    I guess that should do it. A lot of small files, and perhaps 100.000 files or so.

  14. stevenmcastano commented on Nov 30, 2016

    @stevenmcastano
  15. Trefex commented on Nov 30, 2016

    @Trefex
  16. stevenmcastano commented on Nov 30, 2016

    @stevenmcastano
  17. atlcell commented on Dec 13, 2016

    @atlcell

    I store my entire music Library in Google Drive (~65GB)

    This includes mixtapes and other shit you cannot find on Spotify and the likes. I also tend to keep high quality files like 320kbps MP3s and FLACs/ALACs

    I tried to use Drive as my MASTER copy but the Google Drive client along with syncing between NTFS+ and HFS has fucked it sometimes and created duplicates, doesn't sync files, etc.

    I'm paying for 1TB premium in Google

    I just got this error and I assumed I would, I have moved 500GB of data through Googles network they have to have some sort of internal guage for consumers, correct?

  18. modified the milestones: 9.1.5, 9.1.4 on Feb 6, 2017
  19. DejaVu commented on Mar 7, 2017

    @DejaVu

    Another way to put this to the test I've found is to upload/sync a folder with 1,000 files - any size and then rename them locally and resync.

    Expected behaviour is to simply rename remote files and the procedure is offered correctly.

    Trying to rename at the rate GoodSync does on Goohle Drive, although quick and we all prefer quick, these 403 User Limits are hit and no files that are already uploaded are renamed either.

  20. PVince81 commented on Mar 7, 2017

    @PVince81
    Contributor

    I suspect that GoodSync doesn't rename the way the desktop client renames. Instead of a single MOVE it might be doing a copy of every file first. Or maybe it does a MKCOL on the new folder and then recursively move every file there instead of doing just once. Looking at the web server access log should tell.

    In general I'd expect a simple Webdav MOVE to not cause any rate limit issue.

  21. PVince81 commented on Mar 29, 2017

    @PVince81
    Contributor

    Here you go, one liner to enable retries in the GDrive lib: #27530

  22. PVince81 commented on Mar 29, 2017

    @PVince81
    Contributor

    Please all help testing this and let us know if it solved your problem.

    You might still bump into API limits from time to time but it shouldn't be as bad as before.

  23. PVince81 commented on Apr 3, 2017

    @PVince81
    Contributor

    This will be in 9.1.5

  24. lmiol commented on Feb 18, 2019

    @lmiol

    Hi there
    i need explanation for some limits (thx in advance)
    Limit 1000 requests per 100 seconds
    i have api key requests to get files.

    and if i using this requests from 5 devices i will be like 1 user?
    or like 5 users?

  25. locked as resolved and limited conversation to collaborators on Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions