Skip to content

Conversation

@hablutzel1
Copy link
Contributor

A cold start currently takes approximately 8 seconds, whereas subsequent invocations complete in around 1 second.

Cold starts primarily impact CAs with low API invocation frequency, as their associated Lambda execution environments are eventually terminated. High-traffic CAs are unlikely to be affected due to the constant reuse of warm environments.

To mitigate the impact of cold starts, several approaches are available:

  • Provisioned Concurrency: Maintains a specified number of pre-initialized execution environments.
  • SnapStart: Restores a snapshot of a pre-initialized execution state, significantly reducing cold start latency.
  • EventBridge Scheduler: Periodically invokes functions (e.g., every 5 minutes) to keep the execution environments active.

This PR implements the EventBridge Scheduler approach, as it is the simplest to deploy. From https://aws.amazon.com/pt/blogs/compute/operating-lambda-performance-optimization-part-1/ :

Understanding how functions warmers work
...

> This approach uses EventBridge rules to schedule invocations of the function every minute to help keep the execution environment active. As a result, this can increase the likelihood of using a warm environment when you invoke the function.

For clients that invoke the API infrequently, this solution should help ensure that a complete set of Lambda execution environments remains warm.

@birgelee
Copy link
Member

birgelee commented May 7, 2025

I like this. I think its good as an option with it disabled by default. It worked for me in testing. I did have some questions about the cost of this approach vs Provisioned Concurrency. I had looked into the Provisioned Concurrency docs and it didn't seem to be too complex. Maybe before generating documentation around this it would be good to lock in the cost and better understand the cost/performance benefits of this vs other approaches. Since it is default disabled and functional, I am fine merging it in at this stage.

@hablutzel1
Copy link
Contributor Author

My guess is this will be cheaper than Provisioned Concurrency as it will be executed just every 5 minutes and takes around 1 second to complete, but I'm not sure.

@birgelee birgelee merged commit 5dae7b0 into open-mpic:main May 8, 2025
1 check passed
@hablutzel1 hablutzel1 deleted the eventbridge-warmer branch May 19, 2025 10:57
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.

2 participants