简体   繁体   English

Google Vault Api 的速率限制是多少?

[英]What is the rate limit on Google Vault Api?

I'm attempting to create an export request for all my users in my organization with Google Vault API in python我正在尝试使用 python 中的 Google Vault API 为我组织中的所有用户创建导出请求

I have tried slowing my API requests with time.sleep(x).我尝试使用 time.sleep(x) 减慢我的 API 请求。 I have tried modifying the script to do one account at a time, with manual running of said script.我曾尝试修改脚本一次只做一个帐户,手动运行所述脚本。

if not result:
        print('No matters found.')
    else:
        #error checking for user list
        if not emails:
            print("missing users list")
        else:
            for user in emails:
                req = {
                        "name":user,
                        "query":{
                            "corpus":'DRIVE',
                            "dataScope":'ALL_DATA',
                            "searchMethod":'ACCOUNT',
                            "accountInfo":{
                                "emails":[user]
                                }
                            }
                        }
            #create drive export request
                userReq = vaultservice.matters().exports().create(matterId=matters[0]['matterId'],body=req).execute()
                print ("completed request: {0}".format(user))
                time.sleep(10)

When I did an export of the entire org, it creates a gigantic zip file that's not useful because I don't know what belongs to who.当我导出整个组织时,它会创建一个没有用的巨大 zip 文件,因为我不知道什么属于谁。 So I then attempted to create individual export requests.因此,我尝试创建单独的导出请求。

With current script, I see this error "Quota exceeded for quota metric 'vault.googleapis.com/export_writes' and limit 'ExportWritesPerMinutePerProject' of service 'vault.googleapis.com'"使用当前脚本,我看到此错误“配额指标'vault.googleapis.com/export_writes'的配额超出并限制服务'vault.googleapis.com'的'ExportWritesPerMinutePerProject'”

Sometimes I get one export successfully done, sometimes two, but then it errors out.有时我会成功完成一次导出,有时会成功完成两次,但随后会出错。 What is the rate limit for Google Vault, or how else should I accomplish my task? Google 保险柜的速率限制是多少,或者我应该如何完成我的任务?

Update I just got up and running on the API dashboard, and found out that the default quota limit for export writes is 20 per minute.更新我刚刚在 API 仪表板上启动并运行,发现导出写入的默认配额限制为每分钟 20 个。 However, I don't understand then why I am running into a limit problem.但是,我不明白为什么我会遇到限制问题。 Even with a modified sleep(60) before the export create, it peaks at 20 requests and limits me.即使在导出创建之前修改了 sleep(60),它也会在 20 个请求时达到峰值并限制我。 I guess I don't understand why my script is creating so many requests in a second, when I believe it should only create one.我想我不明白为什么我的脚本会在一秒钟内创建这么多请求,而我认为它应该只创建一个。

It looks like Google has a problem in request measurement.看起来 Google 在请求测量方面存在问题。 They count per request sent 10 requests.他们计算每个请求发送 10 个请求。 So you have to stay below 2 requests/minute.所以你必须保持低于 2 个请求/分钟。 For instance use a 31 seconds delay in your code.例如,在您的代码中使用 31 秒的延迟。

This is indeed an issue with Google's API meter and the issue is easily reproduced.这确实是 Google 的 API Meter 的问题,并且很容易重现该问题。 Using Google's own sample code and running it 3x will results in the limit of 20 ExportWritesPerMinutePerProject being reached after only 3 attempts.使用 Google自己的示例代码并运行 3 次将导致在 3 次尝试后达到 20 ExportWritesPerMinutePerProject 的限制。

Google Issue Tracker has been open for over 2 years - https://issuetracker.google.com/issues/131206384 Google 问题跟踪器已开放 2 年多 - https://issuetracker.google.com/issues/131206384

This is because you have reached the limit.这是因为你已经达到了极限。 Export write operations are not counted as one API hit for each hit.导出写入操作不计为每次命中的一次 API 命中。 It considers 10 export write hit when you create an export using API.So after 2 hits you use up the quota of 20 export write and for third request you will get quota exceed response You can check the the following link to check how Google counts each API hit for each Quota [1]: https://developers.google.com/vault/limits当您使用 API 创建导出时,它会考虑 10 次导出写入命中。因此,在 2 次命中后,您会用完 20 次导出写入的配额,对于第三次请求,您将获得配额超出响应您可以查看以下链接以检查 Google 如何计算每个每个配额的 API 命中 [1]: https ://developers.google.com/vault/limits

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM