Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >为什么我收到配额限制错误?Google Cloud Platform Compute Engine VM

为什么我收到配额限制错误?Google Cloud Platform Compute Engine VM
EN

Stack Overflow用户
提问于 2020-12-05 04:56:44
回答 1查看 5.9K关注 0票数 1

因此,我在Google Cloud Compute engine中设置了一个python脚本,该脚本设置为在一天中使用cron选项卡定期运行。但是最近,脚本返回了这个错误,

gspread.exceptions.APIError:{‘代码’:429,‘消息’:“超出了服务'sheets.googleapis.com‘for consumer’项目的配额指标'Read requests‘和limit 'Read requests per user’的配额_编号:583704109550‘.“,’状态‘:’资源_耗尽‘,’详细信息‘:

{'@type':'type.googleapis.com/google.rpc.ErrorInfo',‘原因’:‘费率_限制_已超出‘,’域‘:'googleapis.com',’元数据‘:{’配额_指标‘:'sheets.googleapis.com/read_请求‘,’配额_limit':'ReadRequestsPerMinutePerUser','service':'sheets.googleapis.com','consumer':'projects/583704109550'}}}

我试图研究为什么它会抛出它,但由于我在该领域的经验不足,我感到困惑。这是任何人都想知道的脚本,

代码语言:javascript
运行
AI代码解释
复制
from woocommerce import API
from df2gspread import df2gspread as d2g
from df2gspread import gspread2df as g2d
from collections import defaultdict
import pandas as pd
import gspread
from oauth2client.service_account import ServiceAccountCredentials
def parseData(entry):
        #Extract relectant information (all key value pairs that are listed under meta_data)
        d = {pair["key"]:pair["value"] for pair in entry["line_items"][0]["meta_data"]}
        d["Event"] = entry["line_items"][0]["name"]
        return d
wcapi = API(
    url="REDACTED",
    consumer_key="REDACTED",
    consumer_secret="REDACTED",
    version="wc/v3",
    query_string_auth="true"
)
entries = []
pageNum = 1
while True:
        #API is paginated with products per page limit of 100
        rawEntries = wcapi.get("orders", params = {"per_page": 100, "page": pageNum}).json()
        #Page until there are no entries on a page
        if len(rawEntries) == 0:
                break
        entries.extend([parseData(e) for e in rawEntries])
        pageNum += 1
rawEvents = defaultdict(list)
for entry in entries:
        #Organize entries by their event
        rawEvents[entry["Event"]].append(entry)
events = {k: pd.DataFrame(v).fillna('') for (k,v) in rawEvents.items()} #Built a dataframe for each event
#Upload to Google Sheets using gspread and df2gspread
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('/home/shahav2016/GoogleKeyJSON.json', scope)
gc = gspread.authorize(credentials)
spreadsheet_key = 'REDACTED FOR PRIVACY REASONS' #The name of the spreadsheet - look at the URL
for event, df in events.items():
        #Filter out test events
        if event not in ['REDACTED FOR PRIVACY']:
                #Upload the data to the correct sheet
                d2g.upload(df, spreadsheet_key, event, row_names = False, credentials = credentials)
EN

回答 1

Stack Overflow用户

发布于 2020-12-05 10:53:41

Google Sheets API对每100秒可以处理的请求数有限制。这是来自文档表接口v4的页面。

此版本的Google Sheets API的限制为每个项目每100秒500个请求,每个用户每100秒100个请求。对读取和写入的限制是单独跟踪的。没有每日使用限制。

要查看或更改项目的使用限制,或请求增加配额,请执行以下操作:

如果你的项目还没有帐单账户,那就创建一个。在API控制台访问API库的已开通API页面,从列表中选择API。要查看和更改与配额相关的设置,请选择配额。要查看使用率统计信息,请选择使用率。

此外,有三个选项可以绕过此限制:

  1. 增加quota limit您在开发人员控制台中调用的Sheets API的。
  2. 由于您使用的是for循环,因此发送请求的速度非常快。我认为明智的做法是将一个sleep在该循环中的某个位置,这样您就不会每100秒处理100个请求。
  3. 如果进展太慢,尝试一次将多个更改上传到电子表格,这种机制称为batching。这也将减少API请求的数量。
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65153922

复制
相关文章
【GPU陷入价格战】谷歌云可抢占GPU降价40%,P100每小时不到3块钱
来源:Google 作者:文强 【新智元导读】还愁用不起GPU?今天谷歌宣布云端可抢占GPU大幅降价,P100的价格每小时0.43美元,换算成人民币只需2.77元。 不是每个人工作的时候都需要GPU
新智元
2018/06/25
2.2K0
Cloud Compute
       最近,Cloud Compute,也就是“云计算”备受关注,或者说是因为一些大厂商铺天盖地的宣传才导致自web2.0以来又一个互联网应用的new wave。。。
bisal
2019/01/29
6520
使用Google Cloud Platform进行资产跟踪
高价值资产往往会被放错地方或被盗。我们回顾了Leverege如何使用GCP创建一个使用物联网设备的资产跟踪解决方案。
用户4122690
2020/06/18
2.6K0
使用Google Cloud Platform进行资产跟踪
Google 的 Serverless 产品对比:Cloud Run、Cloud Functions、App Engine
Serverless 平台的主要优点是,它们使您可以专注于编写代码,而不必关心管理基础结构,自动扩容或为所用资源支付更多费用。
donghui
2021/02/08
3.5K0
Google 的 Serverless 产品对比:Cloud Run、Cloud Functions、App Engine
Cloud Pilot 2.5 Google Cloud Platform 虚拟机迁移(下)
本周赶上独立日休假,本来没打算写。后来看了看上周的素材还多了点边角料,就顺手凑了一篇。实属为了这点醋,包了顿饺子。
s09g
2022/12/18
7600
Cloud Pilot 2.5 Google Cloud Platform 虚拟机迁移(下)
TPU使用说明
为了连接到 TPU,我们必须配置一台虚拟机(单独结算)。要注意的是虚拟机和TPU是分别计费的。
marsggbo
2018/10/22
2K0
TPU使用说明
谷歌对决亚马逊 在云中运行Hadoop
Google Compute Engine 的虚拟机提供了一种快速、可靠的方式来运行 Apache Hadoop。如今,Google 正在努力通过Google Cloud Storage Hadoop
静一
2018/03/15
1.3K0
谷歌对决亚马逊 在云中运行Hadoop
TPU使用说明
为了连接到 TPU,我们必须配置一台虚拟机(单独结算)。要注意的是虚拟机和TPU是分别计费的。
marsggbo
2019/05/26
3.4K0
TPU使用说明
TPU使用说明
为了连接到 TPU,我们必须配置一台虚拟机(单独结算)。要注意的是虚拟机和TPU是分别计费的。
marsggbo
2018/10/16
1.5K0
如何在 Google Cloud 上部署 EMQX 企业版
Google Cloud 的 IoT Core 产品将于 2023 年 8 月 16 日停止服务,随着这一日期的临近,许多用户正在为他们现有的物联网业务寻找新的解决方案,而 EMQX 企业版是实现这一目标的理想选择。
EMQ映云科技
2023/04/19
2.8K0
Compute Engine Static Ip Charge 谷歌云被扣费
信用卡收到 2 次被谷歌云扣费的短信,每月 7 美刀左右,是因为之前开了 vm 实例(送的 300 美刀到期后,把几个实例删除了,可能是操作的时候默认保留一个静态 IP 导致一直在扣费,刚开始还以为是送的美刀的过了有效期,扣费了就没去仔细看),没有把 静态 IP 释放掉。
卓越笔记
2023/02/18
5040
Compute Engine Static Ip Charge 谷歌云被扣费
Cloud Pilot 2. Google Cloud Platform 服务器虚拟化架构(上)
首先还是拿个友商出来做对照。当初是在大四毕业的暑假到研究生的第一年期间考的VCP和VCAP,vSphere的版本还在6.5/6.7,放在今天多少有点过气。但我还是打算把VMware拎出来,看看VMware vSphere虚拟化架构。
s09g
2022/07/06
1.9K1
Cloud Pilot 2. Google Cloud Platform 服务器虚拟化架构(上)
python google app engine
云计算的三个层次:issa:paas:saas 云计算有三个层次。图12-1 显示了每个层次,以及对应层次的代表产品。最低层的是IaaS(Infrastructure-as-a-Service),即提供计算机本身基本的计算能力(物理形式或虚拟形式)、存储(通常是磁盘)、计算。亚马逊Web 服务(Amazon Web Services,AWS)提供了弹性计算云(Elastic Compute Cloud,EC2),以及简单存储系统(Simple Storage System,S3)服务,这两者就在IaaS 层面。Google 也提供了IaaS 存储服务,称为Google Cloud Storage。Google App Engine 作为云计算的中间一层,称为Paas(Platform-as-a-Service)。这一层为用户的应用提供执行平台。最高一层是Software-as-a-Service(SaaS)。在这一层,用户只须简单地访问应用,这些应用位于本地,但只能通过因特网访问。SaaS 的例子包括基于Web的电子邮件服务,如Gmail、Yahoo! Mail 和Hotmail。
用户5760343
2022/05/14
5460
python google app engine
[译] Traffic Director如何为开放服务网格提供全局负载均衡
在上周的Next ‘19,我们宣布了用于服务网格的Traffic Director,为您的VM和容器服务带来全局流量管理。我们还在博客中向您展示了Traffic Director的功能。今天,我们将深入探讨其特性和优势。
PHP开发工程师
2022/06/16
1K0
[译] Traffic Director如何为开放服务网格提供全局负载均衡
点击加载更多

相似问题

无法连接Linux VM (Google Cloud Platform Compute Engine)

21

Google Cloud Platform Debugger for Compute Engine with Payara/Glassfish Application Server

18

How to Read Photos for Deep Learning on Google Cloud Platform Compute Engine VM Instance,通过Jupyter Lab

11

Google Cloud Platform - Compute Engine Bitnami表示堆栈启动脚本

11

如何在Google Cloud Platform的Compute Engine上安装Jenkins?

111
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档