Skip to content

feat(infra): scheduled warmer per Lambda — fixes the idle-reactivation 502s - #181

Open
bjagg wants to merge 1 commit into
demo/e2e-alignedfrom
feat/infra-scheduled-warmer
Open

bjagg wants to merge 1 commit into
demo/e2e-alignedfrom
feat/infra-scheduled-warmer

Conversation

@bjagg

@bjagg bjagg commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

What

Every service stack gains two condition-gated resources: an EventBridge rule (rate(5 minutes)) that invokes the function with a synthetic Function-URL-shaped (HTTP API v2) GET /healthz event, plus the resource-based permission. Both Mangum (Python) and serverless-http (Node) treat it as a normal health check. WarmingScheduleEnabled (default "true") opts a stack out.

Why this and not provisioned concurrency

The idle failure mode (2026-08-27 AACRAO demo): container-image Lambdas unused for weeks get deactivated; the first invocation fails at the platform level (502 from the Function URL, zero runtime logs) while the function reactivates, then everything works. Any periodic invocation prevents deactivation.

Provisioned concurrency also fixes it but can't target $LATEST — it needs version/alias publishing that this raw-CFN, two-pass, per-tag deploy flow would drift against (a PC'd alias silently serving a stale image after a code deploy), and costs ~$75+/month for the fleet. SnapStart doesn't support container images. The warmer is ~121k invocations/month across 14 functions — effectively free.

Verification

  • aws cloudformation validate-template passes; deployed to all 14 service stacks (template-only update, per-stack ImageUri preserved) and verified live: rules firing, healthz invocations in the logs, functions staying active.
  • Edge-auth (Lambda@Edge) is excluded — CloudFront invokes it on every console request, so it never idles unnoticed.

Companion: #180 adds the presenter-facing warm-up reminder to the Admin UI (belt for this suspender).

Container-image Lambdas idle for weeks are deactivated by the platform and
fail their first invocation while reactivating (2026-08-27 AACRAO demo:
one lost event, one all-fallback run, one failed issuance; failing calls
left no runtime logs). Add a per-service EventBridge rule that invokes the
function every 5 minutes with a synthetic Function-URL-shaped GET /healthz
event — keeps every function active for ~zero cost, no roles, no HTTP hop.
Param-gated (WarmingScheduleEnabled, default true).

Provisioned concurrency was considered and rejected: it cannot target
$LATEST, and the version/alias publishing it requires would drift against
this raw-CFN two-pass deploy (a PC'd alias silently serving stale images),
at ~$75+/month. SnapStart is zip-only.
@bjagg bjagg self-assigned this Sep 1, 2026
@bjagg
bjagg requested a review from mgwozdz-unicon September 1, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant