diff --git a/deployment/terraform/lambda/modelling_e2e/main.tf b/deployment/terraform/lambda/modelling_e2e/main.tf index 826e83aa..4be3bd2a 100644 --- a/deployment/terraform/lambda/modelling_e2e/main.tf +++ b/deployment/terraform/lambda/modelling_e2e/main.tf @@ -13,6 +13,17 @@ data "aws_secretsmanager_secret_version" "db_credentials" { locals { db_credentials = jsondecode(data.aws_secretsmanager_secret_version.db_credentials.secret_string) + + # Per-container minimum gap (seconds) between Google Solar API calls. The Solar + # API caps the whole GCP project at a hard 600 QPM shared across Building + # Insights + Data Layers. Each of the up-to-`maximum_concurrency` containers + # loops its ~50-property batch sequentially, so pacing each one to + # 0.8 (safety headroom) × 600 QPM ÷ 60 ÷ N keeps the fleet sum under the + # ceiling — eliminating the sustained 429 storm that per-process backoff alone + # can't ride out. Derived from `maximum_concurrency` so N has one source of + # truth. At N=32 → 4.0s. Consumed by the handler's throttle (see + # infrastructure/solar/google_solar_api_client.py). + solar_min_request_interval_seconds = var.maximum_concurrency / (0.8 * 600 / 60) } module "lambda" { @@ -42,6 +53,8 @@ module "lambda" { OPEN_EPC_API_TOKEN = var.open_epc_api_token GOOGLE_SOLAR_API_KEY = var.google_solar_api_key DATA_BUCKET = "retrofit-data-${var.stage}" + + SOLAR_MIN_REQUEST_INTERVAL_SECONDS = tostring(local.solar_min_request_interval_seconds) } }