Cloud Cost Sense

Google Cloud API Gateway の費用:Call・転送・Backend

月間 API call、data transfer、backend compute、logging、monitoring、retry から Google Cloud API Gateway の費用を見積もります。

Billing account の call tier ごとに計算する

API Gateway は Service Control に報告する call 数で課金されます。Billing account ごとに月間 200 万 call までは無料、200 万超から 10 億 call までは 100 万件あたり 3 ドル、10 億超の部分は 100 万件あたり 1.50 ドルです。すべての call に一つの単価を掛けず、各 tier を段階的に適用し、USD 以外で支払う場合は現在の通貨別価格を確認します。

成功した backend response だけでなく gateway に到達する request を数えます。Client retry、polling、health traffic、authentication rejection、error response も call 数を増やします。通常時と retry が多い障害時を分けて見積もり、小さな failure rate に隠れた request cost を把握します。

Data transfer と backend の料金を加える

Google Cloud への data transfer は無料ですが、API Gateway から Google の外へ出る data には Premium Tier の転送料金が適用されます。Response size と成功 call 数から response GiB を見積もり、internet、cross-region、その他の課金経路を分けます。大きな JSON response や file delivery では転送費が gateway call 料金を上回ることがあります。

Gateway 料金には背後の service は含まれません。Cloud Run、Cloud Functions、App Engine などの compute に database read、storage operation、external API、secrets access を加えます。API の正確性と freshness を保てる範囲で caching、pagination、compression、response field の削減を使います。

Log・metric と不要な retry を管理する

API Gateway は request metric を自動生成しますが、Cloud Logging と Cloud Monitoring の使用には別料金が発生する場合があります。特に大量の成功 request では log sampling、exclusion、retention を意図的に設定します。価値の低い payload をすべて保持せず、error、latency、authentication、request correlation の診断データは残します。

Gateway request 数、response code、latency、backend error、response byte、retry rate を一緒に追跡します。費用増加は正当な成長の場合もありますが、過剰な polling、client backoff の欠如、duplicate submission、bot を示す場合もあります。生の request 単価ではなく、成功した business action あたりの費用を比較します。

API Gateway の背後で動く Cloud Run backend の費用を加える。