Inject Solar throttle gap derived from queue maximum_concurrency

Terraform computes SOLAR_MIN_REQUEST_INTERVAL_SECONDS = N / (0.8 * 600 / 60)
from var.maximum_concurrency (=4.0s at N=32) so the fleet width has one source
of truth and the per-container Solar pacing tracks it automatically.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-06-25 16:05:57 +00:00
parent 1e3c401b38
commit ecb31bf114

View file

@ -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)
}
}