Repository navigation
Description
Steps to reproduce
- Set up Google Drive as external Storage. In my case I was accessing via a shared (sub)folder
- Upload a lot of files to that folder e.g. using the ownCloud client (probably also download?)
- 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)
Browser log
irrelevant
Activity
PVince81 commentedon Nov 16, 2015
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
swurzinger commentedon Nov 16, 2015
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.
PVince81 commentedon Dec 23, 2015
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.
PVince81 commentedon Dec 23, 2015
there's also batching: https://developers.google.com/api-client-library/php/guide/batch
swurzinger commentedon Dec 23, 2015
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)
PVince81 commentedon Dec 23, 2015
Unfortunately it seems the library OC uses doesn't use the Curl library but rather uses PHP's
curl_xxxstatements directly: https://github.com/owncloud/core/blob/v8.2.2/apps/files_external/3rdparty/google-api-php-client/src/Google/IO/Curl.php#L85So 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
PVince81 commentedon Feb 19, 2016
@davitol this is what you observed yesterday
davitol commentedon Feb 19, 2016
@PVince81 thanks 😺
PVince81 commentedon Feb 29, 2016
Setting this to critical, it has been observed already 3-4 times in different environments.
LukasReschke commentedon Feb 29, 2016
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.
thefirstofthe300 commentedon Mar 14, 2016
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.
31 remaining items
Trefex commentedon Nov 30, 2016
@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.
stevenmcastano commentedon Nov 30, 2016
Trefex commentedon Nov 30, 2016
stevenmcastano commentedon Nov 30, 2016
atlcell commentedon Dec 13, 2016
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?
DejaVu commentedon Mar 7, 2017
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.
PVince81 commentedon Mar 7, 2017
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.
PVince81 commentedon Mar 29, 2017
Here you go, one liner to enable retries in the GDrive lib: #27530
PVince81 commentedon Mar 29, 2017
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.
PVince81 commentedon Apr 3, 2017
This will be in 9.1.5
lmiol commentedon Feb 18, 2019
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?