Skip to content

Conversation

@sebsto
Copy link
Collaborator

@sebsto sebsto commented Jan 13, 2026

AWS launched Lambda Managed Instances, i.e Lambda functions running on EC2 instances.

This comes with a major change in the programming model as function handlers are now allowed to run concurrently on the same machine (multiple in flight events being processed in parallel in the same execution environment). The maximum concurrency per runtime environment is controlled by the user.

This PR adds support for running multiple Runtime Interface Clients (RICs) concurrently when deployed on Lambda Managed Instances, enabling the runtime to handle multiple invocations simultaneously within a single execution environment.

This PR is a followup to #617 which used another approach to support Lambda Managed Instances by changing the public API and requiring that all handlers must conform to Sendable. The original PR was closed as we agreed that only a fraction of the Lambda functions will be deployed on EC2 and it was not worth adding a Sendable requirement for all.

Changes

  • Introduced thread-safe LambdaManagedRuntime: Created new Sendable-conforming runtime class that supports concurrent handler execution with atomic guards to prevent multiple runtime instances and thread-safe handler requirements (Handler: StreamingLambdaHandler & Sendable)

  • Implemented ServiceLifecycle integration: Added managed runtime support for structured concurrency lifecycle management, allowing proper startup/shutdown coordination in multi-concurrent environments

This PR contains only changes to the core runtime, convenience functions, handlers, adapters, and a comprehensive example will be added in a follow up PR.

Context
Lambda Managed Instances support multi-concurrent invocations where multiple invocations execute simultaneously within the same execution environment. The runtime now detects the configured concurrency level and launches the appropriate number of RICs to handle concurrent requests efficiently.

When AWS_LAMBDA_MAX_CONCURRENCY is 1 or unset, the runtime maintains the existing single-threaded behaviour for optimal performance on traditional Lambda deployments.

@sebsto sebsto added the 🆕 semver/minor Adds new public API. label Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant