Skip to content

Add Lambda warmer function to reduce cold starts #9

@aynaash

Description

@aynaash

Summary

Add an optional warmer Lambda that periodically invokes the server Lambda to keep it warm, reducing cold start frequency.

Design

  • Warmer Lambda — Scheduled via EventBridge (every 5 minutes)
  • Sends a special "ping" event to the server Lambda
  • Server Lambda detects ping and returns immediately without processing
  • Configurable concurrency (warm N instances)

Configuration

serverless:
  warmer:
    enabled: true
    interval: 5        # minutes
    concurrency: 3     # keep 3 instances warm

Infrastructure to Auto-Provision

  • Warmer Lambda function
  • EventBridge scheduled rule
  • IAM permissions for warmer to invoke server Lambda

Server Lambda Changes

Add ping detection at the top of the handler:

if (event.__NEXTDEPLOY_WARMER) {
  return { statusCode: 200, body: "warm" };
}

Difficulty: Medium · Language: Go + JavaScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions