You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -22,11 +23,11 @@ For standard Lambda development, see [aws-lambda skill](../aws-lambda/). For SAM
22
23
## When to Load Reference Files
23
24
24
25
-**Cost comparison**, **pricing analysis**, **Lambda vs LMI cost**, **Savings Plans**, or **Reserved Instances** -> see [references/cost-comparison.md](references/cost-comparison.md)
25
-
-**Instance types**, **memory sizing**, **vCPU ratios**, **scaling tuning**, or **capacity provider config** -> see [references/configuration-guide.md](references/configuration-guide.md)
26
+
-**Instance types**, **memory sizing**, **vCPU ratios**, **scaling tuning**, **scheduled scaling**, or **capacity provider config** -> see [references/configuration-guide.md](references/configuration-guide.md)
26
27
-**Thread safety**, **concurrency model**, **code review checklist**, **Powertools compatibility**, or **multi-concurrency readiness** -> see [references/thread-safety.md](references/thread-safety.md)
27
28
-**Before/after code examples**, **runtime-specific migration** (Node.js, Python, Java, .NET), or **connection pooling** -> see [references/migration-patterns.md](references/migration-patterns.md)
28
-
-**IAM roles**, **VPC setup**, **CLI commands**, **SAM template**, or **CDK example** -> see [references/infrastructure-setup.md](references/infrastructure-setup.md) and [scripts/setup-lmi.sh](scripts/setup-lmi.sh)
29
-
-**Errors**, **throttling**, **debugging**, or **stuck deployments** -> see [references/troubleshooting.md](references/troubleshooting.md)
29
+
-**IAM roles**, **VPC setup**, **CLI commands**, **SAM template**, **CDK example**, or **scheduled scaling setup (EventBridge Scheduler)** -> see [references/infrastructure-setup.md](references/infrastructure-setup.md) and [scripts/setup-lmi.sh](scripts/setup-lmi.sh)
30
+
-**Errors**, **throttling**, **debugging**, **stuck deployments**, **tuning configuration**, or **adjusting after deployment** -> see [references/troubleshooting.md](references/troubleshooting.md)
30
31
31
32
## Quick Decision: Is LMI Right for This Workload?
32
33
@@ -54,6 +55,38 @@ Gather these signals before recommending:
7.**VPC**: Already in a VPC? Private resource access needed?
56
57
58
+
#### Deriving LMI Configuration from Metrics
59
+
60
+
If Lambda Insights is enabled on the function, use these metrics to calculate your starting configuration. If Lambda Insights is not enabled, suggest adding it to gather accurate workload data — but only proceed with the user's explicit confirmation, as adding the Insights layer may affect function performance or cold start times.
61
+
62
+
To check if Lambda Insights is enabled, look for a LambdaInsightsExtension layer on the function. To add it, find the latest layer ARN for your region from the [Lambda Insights documentation](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-extension-versions.html) and attach the `CloudWatchLambdaInsightsExecutionRolePolicy` managed policy to the function's execution role.
63
+
64
+
**Target max concurrency** (from `cpu_total_time` and `Duration`):
This overestimates (assumes no shared base memory) but provides a safe starting point. The outer `min` caps the result at the 32 GB (32768 MB) LMI maximum.
**Scheduled scaling**: For predictable traffic (business hours, marketing events), use EventBridge Scheduler to adjust Min/Max execution environments on a one-time or recurring schedule — scale up before peak, scale down or to zero when idle.
114
+
80
115
See [references/configuration-guide.md](references/configuration-guide.md) for decision trees and detailed tuning.
81
116
82
117
### Step 4: Migrate the Code
@@ -105,16 +140,16 @@ See [references/infrastructure-setup.md](references/infrastructure-setup.md) for
105
140
### Step 6: Validate and Cut Over
106
141
107
142
1. Deploy to a non-production environment first
108
-
2. Monitor CloudWatch: CPU utilization, memory, concurrency, throttle rate
2. Monitor CloudWatch: CPU utilization, memory, concurrency, throttle rate. If you observe low CPU utilization or ongoing throttles, see [references/troubleshooting.md](references/troubleshooting.md) for metric-specific adjustment guidance.
144
+
3.Shift traffic to the LMI function (note: weighted alias shifting between LMI and non-LMI functions is not currently supported)
110
145
4. Compare costs after 1-2 weeks of production data
111
146
5. Decommission standard Lambda once stable
112
147
113
148
## Best Practices
114
149
115
150
### Configuration
116
151
117
-
- Do: Start with 4:1 ratio and runtime default concurrency
152
+
- Do: Start with 2:1 ratio and runtime default concurrency
118
153
- Do: Use ARM (Graviton) unless x86 dependencies exist
119
154
- Do: Let Lambda choose instance types unless specific hardware needed
120
155
- Do: Set MaxVCpuCount to control cost ceiling
@@ -125,7 +160,7 @@ See [references/infrastructure-setup.md](references/infrastructure-setup.md) for
125
160
126
161
- Do: Start with I/O-heavy functions (benefit most from multi-concurrency; CPU-bound functions compete for same CPU)
127
162
- Do: Review code for concurrency safety before attaching to capacity provider (thread safety for Node.js/Java/.NET; `/tmp` and memory for Python)
128
-
- Do: Use weighted aliases for gradual traffic shift
163
+
- Do: Plan traffic shifting strategy based on your invocation source (weighted alias shifting between LMI and non-LMI functions is not currently supported)
129
164
- Do: Include request IDs in all log statements
130
165
- Do: Initialize DB pools and SDK clients outside the handler
131
166
- Do: Estimate total `/tmp` usage under max concurrency
@@ -135,8 +170,10 @@ See [references/infrastructure-setup.md](references/infrastructure-setup.md) for
135
170
### Operations
136
171
137
172
- Do: Set CloudWatch alarms on throttle rate > 1% and CPU > 80%
173
+
- Do: Use scheduled scaling (EventBridge Scheduler) for predictable traffic — raise Min/Max before peak periods and lower them (or scale to zero) when idle
- Don't: Forget to publish a version — unpublished functions cannot run on LMI
176
+
- Don't: Rely on a deactivated (Min=Max=0) function to self-recover — schedule an explicit scale-up to reactivate it
140
177
141
178
## Limits Quick Reference
142
179
@@ -172,7 +209,7 @@ REQUIRED: AWS credentials configured on the host machine.
172
209
173
210
### Regional Availability
174
211
175
-
Currently available: us-east-1, us-east-2, us-west-2, ap-northeast-1, eu-west-1. Expanding to all commercial regions soon.
212
+
Available in all commercial AWS Regions except Israel (Tel Aviv), Middle East (Bahrain), Middle East (UAE), and Asia Pacific (Auckland).
176
213
177
214
Check the [Lambda Managed Instances documentation](https://docs.aws.amazon.com/lambda/latest/dg/lambda-managed-instances.html) for the latest regional availability.
For workloads with known traffic patterns (business hours, marketing events, batch windows), use [Amazon EventBridge Scheduler](https://docs.aws.amazon.com/scheduler/latest/UserGuide/managing-targets-universal.html) to adjust a function's `MinExecutionEnvironments` and `MaxExecutionEnvironments` on a one-time or recurring schedule. A schedule (cron or rate expression) targets the Lambda `PutFunctionScalingConfig` API as an EventBridge Scheduler universal target, passing new Min/Max values in the input payload.
57
+
58
+
**Behavior:**
59
+
60
+
- Scheduled scaling sets the provisioned floor and ceiling. Actual scaling between Min and Max still responds to CPU utilization and concurrency saturation.
61
+
- If traffic more than doubles within 5 minutes of a scheduled scale-up, you may still see throttles while capacity provisions.
62
+
- Setting both `MinExecutionEnvironments` and `MaxExecutionEnvironments` to 0 deactivates the function version (instances terminate). A deactivated function does NOT auto-recover — schedule a separate action with non-zero values to reactivate it.
Copy file name to clipboardExpand all lines: plugins/aws-serverless/skills/aws-lambda-managed-instances/references/infrastructure-setup.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -224,6 +224,83 @@ Resources:
224
224
CapacityProviderArn: !GetAtt MyCP.Arn
225
225
```
226
226
227
+
## Scheduled Scaling (EventBridge Scheduler)
228
+
229
+
For predictable traffic, adjust `MinExecutionEnvironments`/`MaxExecutionEnvironments` on a schedule using [Amazon EventBridge Scheduler](https://docs.aws.amazon.com/scheduler/latest/UserGuide/managing-targets-universal.html). The schedule calls the Lambda `PutFunctionScalingConfig` API directly as a universal target — no Lambda code or extra glue required.
230
+
231
+
### 1. Scheduler execution role
232
+
233
+
Trust policy (allow EventBridge Scheduler to assume the role):
Set both values to `0` to deactivate during idle periods; schedule a separate non-zero action to reactivate (a deactivated function does not auto-recover).
`MinExecutionEnvironments`and `MaxExecutionEnvironments` accept values from 0 to 15000 and must be set together. Setting them on `$LATEST.PUBLISHED` propagates to future published versions.
0 commit comments