用量限额
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
由于 Google Workspace Events API 是一项共享服务,因此我们会设置配额和限制,以确保所有用户都能公平地使用该服务,并保护 Google Workspace 的整体性能。
如果您超出了配额,则会收到 429: Too many requests
HTTP 状态代码响应。Google Workspace Events API 后端的其他速率限制检查也可能会生成相同的错误响应。如果发生此错误,您应使用指数退避算法,然后稍后重试。只要您不超出下表中列出的每分钟配额,每天可以发出的请求数量就没有限制。
每个项目的配额
按项目配额会限制 Google Cloud 项目的查询速率,因此会应用于针对每个配额调用指定 Google Workspace Events API 方法的单个应用。
下表详细介绍了每个项目的查询限制。您也可以在 Google Cloud 控制台的配额页面上找到这些限制。
每个项目的配额 |
Google Workspace Events API 方法 |
限制 |
每分钟写入次数 |
Subscriptions.create
Subscriptions.patch
Subscriptions.delete
Subscriptions.reactivate
|
600 |
每分钟每个用户的写入次数 |
Subscriptions.create
Subscriptions.patch
Subscriptions.delete
Subscriptions.reactivate
|
100 |
每分钟读取次数 |
Subscriptions.get
Subscriptions.list
|
600 |
每位用户每分钟的读取次数 |
Subscriptions.get
Subscriptions.list
|
100 |
解决基于时间的配额错误
对于所有基于时间的错误(每 X 分钟最多发出 N 个请求),我们建议您的代码捕获异常并使用截断的对数回退,以确保您的设备不会产生过多负载。
指数退避算法是网络应用的标准错误处理策略。指数退避算法以指数方式重试请求(不断增加各次请求之间的等待时间,直到达到最大退避时间)。如果请求仍未成功,请务必让请求之间的延迟时间随着时间的推移而增加,直到请求成功为止。
示例算法
指数退避算法以指数方式重试请求(不断增加各次重试之间的等待时间,直到达到最大退避时间)。例如:
- 向 Google Workspace Events API 发出请求。
- 如果请求失败,请等待 1 +
random_number_milliseconds
秒后再重试请求。
- 如果请求失败,请等待 2 +
random_number_milliseconds
秒后再重试请求。
- 如果请求失败,请等待 4 +
random_number_milliseconds
秒后再重试请求。
- 依此类推,等待时间上限为
maximum_backoff
。
- 继续等待并重试,直至达到重试次数上限,但不会增加重试之间的等待时间。
其中:
- 等待时间为
min(((2^n)+random_number_milliseconds), maximum_backoff)
,其中,n
会在每次迭代(请求)后增加 1。
random_number_milliseconds
是一个小于或等于 1,000 的随机毫秒数。这有助于避免出现以下情况:许多客户端在某些情况下全部同步进行处理并同时执行重试操作,导致同步发送每一波请求。每次重试请求后,系统都会重新计算 random_number_milliseconds
值。
maximum_backoff
通常为 32 或 64 秒。最适当的值取决于用例。
客户端在达到 maximum_backoff
时间后可以继续重试。此后执行的重试不需要继续增加退避时间。例如,如果客户端使用的 maximum_backoff
时间为 64 秒,则在达到此值后,客户端可以每 64 秒重试一次。到了特定时间点后,客户端应停止无限重试。
重试之间的等待时间和重试次数取决于您的用例和网络条件。
申请提高每个项目的配额
根据项目的资源使用情况,您可能需要申请增加配额。服务账号的 API 调用会被视为使用单个账号。我们无法保证您的增加配额请求一定会得到批准。而增加大量配额的请求可能需要更长时间才能获得批准。
并非所有项目的配额都完全相同。随着您的 Google Cloud 使用量逐步增加,您可能需要增加配额。如果您预计自己的用量即将显著增加,可以在 Google Cloud 控制台的配额页面中主动申请调整配额。
如需了解详情,请参阅以下资源:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-22。
[null,null,["最后更新时间 (UTC):2024-12-22。"],[[["\u003cp\u003eGoogle Workspace Events API uses quotas and limitations to ensure fair usage and system performance, resulting in a \u003ccode\u003e429: Too many requests\u003c/code\u003e error if exceeded.\u003c/p\u003e\n"],["\u003cp\u003ePer-project quotas limit the rate of API calls, with separate limits for reads/writes per minute and reads/writes per minute per user, as detailed in the provided table.\u003c/p\u003e\n"],["\u003cp\u003eUpon encountering quota errors, utilize an exponential backoff algorithm with increasing wait times between retries to avoid excessive load.\u003c/p\u003e\n"],["\u003cp\u003eConsider requesting a quota increase via the Google Cloud console if your project's resource usage necessitates higher limits.\u003c/p\u003e\n"]]],["The Google Workspace Events API enforces per-project quotas to ensure fair usage and performance. Exceeding quotas results in a `429` error, requiring an exponential backoff retry strategy. Per-minute limits for `Subscriptions` methods are: 600 writes/reads, and 100 writes/reads per user. The exponential backoff algorithm involves retrying requests with increasing wait times, calculated as `min(((2^n)+random_number_milliseconds), maximum_backoff)`. Users can request quota increases through the Google Cloud console.\n"],null,["# Usage limits\n\nBecause the Google Workspace Events API is a shared service, we apply quotas and\nlimitations to make sure that it's used fairly by all users and to protect the\noverall performance of Google Workspace.\n\nIf you exceed a quota, you'll receive a `429: Too many requests` HTTP status\ncode response. Additional rate limit checks on the\nGoogle Workspace Events API backend might also generate the same error\nresponse. If this error happens, you should use an [exponential backoff\nalgorithm](https://en.wikipedia.org/wiki/Exponential_backoff#Binary_exponential_backoff_/_truncated_exponential_backoff)\nand try again later. As long as you stay within the per-minute quotas listed in\nthe following tables, there's no limit to the number of requests you can make\nper day.\n\nPer-project quotas\n------------------\n\nPer-project quotas limit the rate of queries for a Google Cloud project, and thus\napply to a single app calling the specified Google Workspace Events API\nmethods for each quota.\n\nThe following table details per-project query limits. You can also find\nthese limits on the [Quotas](https://console.cloud.google.com/iam-admin/quotas) page in the\nGoogle Cloud console.\n\n| Per-project Quota | Google Workspace Events API methods | Limit |\n|----------------------------|------------------------------------------------------------------------------------------------|-------|\n| Writes per minute | `Subscriptions.create` `Subscriptions.patch` `Subscriptions.delete` `Subscriptions.reactivate` | 600 |\n| Writes per minute per user | `Subscriptions.create` `Subscriptions.patch` `Subscriptions.delete` `Subscriptions.reactivate` | 100 |\n| Reads per minute | `Subscriptions.get` `Subscriptions.list` | 600 |\n| Reads per minute per user | `Subscriptions.get` `Subscriptions.list` | 100 |\n\nResolve time-based quota errors\n-------------------------------\n\n\nFor all time-based errors (maximum of N requests per X minutes), we recommend\nyour code catches the exception and uses a *truncated exponential backoff* to make sure your\ndevices don't generate excessive load.\n\n\nExponential backoff is a standard error handling strategy for network applications. An\nexponential backoff algorithm retries requests using exponentially increasing wait times\nbetween requests, up to a maximum backoff time. If requests are still unsuccessful, it's\nimportant that the delays between requests increase over time until the request is successful.\n\n### Example algorithm\n\n\nAn exponential backoff algorithm retries requests exponentially, increasing the wait time\nbetween retries up to a maximum backoff time. For example:\n\n1. Make a request to Google Workspace Events API.\n2. If the request fails, wait 1 + `random_number_milliseconds` and retry the request.\n3. If the request fails, wait 2 + `random_number_milliseconds` and retry the request.\n4. If the request fails, wait 4 + `random_number_milliseconds` and retry the request.\n5. And so on, up to a `maximum_backoff` time.\n6. Continue waiting and retrying up to some maximum number of retries, but don't increase the wait period between retries.\n\n\nwhere:\n\n- The wait time is `min(((2^n)+random_number_milliseconds), maximum_backoff)`, with `n` incremented by 1 for each iteration (request).\n- `random_number_milliseconds` is a random number of milliseconds less than or equal to 1,000. This helps to avoid cases in which many clients are synchronized by some situation and all retry at once, sending requests in synchronized waves. The value of `random_number_milliseconds` is recalculated after each retry request.\n- `maximum_backoff` is typically 32 or 64 seconds. The appropriate value depends on the use case.\n\n\nThe client can continue retrying after it has reached the `maximum_backoff` time.\nRetries after this point don't need to continue increasing backoff time. For\nexample, if a client uses a `maximum_backoff` time of 64 seconds, then after reaching\nthis value, the client can retry every 64 seconds. At some point,\nclients should be prevented from retrying indefinitely.\n\n\nThe wait time between retries and the number of retries depend on your use case\nand network conditions.\n\nRequest a per-project quota increase\n------------------------------------\n\n\nDepending on your project's resource usage, you might want to request a quota\nadjustment. API calls by a service account are considered to be using a\nsingle account. Applying for an adjusted quota doesn't guarantee approval. Quota adjustment\nrequests that would significantly increase the quota value can take longer to be approved.\n\n\nNot all projects have the same quotas. As you increasingly use Google Cloud over\ntime, your quota values might need to increase. If you expect a notable upcoming\nincrease in usage, you can proactively\n[request quota adjustments](https://cloud.google.com/docs/quota#requesting_higher_quota)\nfrom the [Quotas page](https://console.cloud.google.com/iam-admin/quotas)\nin the Google Cloud console.\n\nTo learn more, see the following resources:\n\n- [About quota adjustments](https://cloud.google.com/docs/quotas/overview#about_increase_requests)\n- [View your current quota usage and limits](https://cloud.google.com/docs/quota#viewing_your_quota_console)\n- [Request a higher quota limit](https://cloud.google.com/docs/quota#requesting_higher_quota)"]]