3 回答

TA貢獻1821條經驗 獲得超6個贊
Cloud Endpoints with App Engine 是一種解決方案。
您可以設置 ESP 以對客戶端進行身份驗證選擇身份驗證方法。
然后,您可以通過在 OpenAPI 文檔配置配額中添加配額來限制 api 請求。
這是官方文檔中的示例:
以下示例顯示如何在路徑部分中配置 x-google-quota 擴展:
x-google-management:??
?metrics:
# Define a metric for read requests.
?- name: "read-requests"
? ?displayName: "Read requests"
? ?valueType: INT64
? ?metricKind: DELTA? ?quota:
?limits:
? ?# Define the limit or the read-requests metric.
? ?- name: "read-limit"
? ? ?metric: "read-requests"
? ? ?unit: "1/min/{project}"
? ? ?values:
? ? ? ?STANDARD: 1000 paths:? ?"/echo":
?post:
? ?description: "Echo back a given message."
? ?operationId: "echo"
? ?produces:
? ?- "application/json"
? ?responses:
? ? ?200:
? ? ? ?description: "Echo"
? ? ? ?schema:
? ? ? ? ?$ref: "#/definitions/echoMessage"
? ?parameters:
? ?- description: "Message to echo"
? ? ?in: body
? ? ?name: message
? ? ?required: true
? ? ?schema:
? ? ? ?$ref: "#/definitions/echoMessage"
? ?x-google-quota:
? ? ?metricCosts:
? ? ? ?"read-requests": 1
? ?security:
? ?- api_key: []

TA貢獻1847條經驗 獲得超7個贊
您可以將Cloud Endpoints 與 App Engine 結合使用。您可以借助 Cloud Endpoints 在任何 Google Cloud 后端上開發、部署和管理 API。
Cloud Endpoints 提供配額,讓您可以控制應用程序調用 API 的速率。設置配額允許您指定使用限制,以保護您的 API 免受調用應用程序發出的過多請求的影響。過多的請求可能是由簡單的拼寫錯誤或設計效率低下的系統導致的,該系統對 API 進行了不必要的調用。無論原因如何,一旦特定來源的流量達到一定水平,就對其進行阻止,這對于 API 的整體健康而言是必要的。通過設置配額,您可以確保一個應用程序不會對使用您的 API 的其他應用程序產生負面影響。
您還可以檢查Apigee Edge 上的速率限制

TA貢獻1829條經驗 獲得超6個贊
我自己沒有嘗試過,但看起來有一個 API 可以做到這一點。
要以編程方式為 App Engine 應用程序創建防火墻規則,您可以使用 Admin API 中的 apps.firewall.ingressRules 方法。
- 3 回答
- 0 關注
- 178 瀏覽
添加回答
舉報