MeWrite Docs

GCP: RESOURCE_EXHAUSTED: Quota exceeded

GCPクォータ超過エラーの解決方法

概要

GCPのリソースクォータを超えた場合に発生するエラーです。

エラーメッセージ

RESOURCE_EXHAUSTED: Quota exceeded for quota metric 'Requests' and limit 'Requests per minute'

原因

  1. APIリクエスト制限: 分あたりのリクエスト数超過
  2. リソース制限: VM数やIPアドレス数
  3. プロジェクト制限: 同時実行数
  4. リージョン制限: 特定リージョンのクォータ

解決策

1. クォータ確認

1
2
3
4
gcloud compute project-info describe --project PROJECT_ID

# 特定のクォータ
gcloud compute regions describe REGION

2. クォータ増加リクエスト

1
2
# コンソールから
# IAM & Admin -> Quotas -> Edit Quotas

3. エクスポネンシャルバックオフ

1
2
3
4
5
6
7
8
9
from google.api_core import retry
from google.cloud import storage

@retry.Retry(predicate=retry.if_exception_type(Exception))
def upload_file(bucket_name, source_file, dest_name):
    client = storage.Client()
    bucket = client.bucket(bucket_name)
    blob = bucket.blob(dest_name)
    blob.upload_from_filename(source_file)

4. バッチ処理

1
2
3
4
5
6
7
8
from google.cloud import bigquery

client = bigquery.Client()

# 複数クエリをバッチで
job_config = bigquery.QueryJobConfig(
    priority=bigquery.QueryPriority.BATCH
)

よくある間違い

  • 無限ループでAPI呼び出し
  • 並列処理でリクエスト集中

GCP の他のエラー

最終更新: 2025-12-09