AWS Lambda マネージドインスタンス(LMI:AWS が管理するサーバー)へのワークロード(処理の仕事)の評価、設定、移行に対応します。 **対応するトリガー(起動条件):** - Lambda マネージドインスタンス、LMI、キャパシティプロバイダー(処理能力の割り当て管理機能) - マルチ同時実行 Lambda、専用インスタンス Lambda、EC2 バックアップ Lambda - コールドスタート(起動初期の遅延)の排除 - Graviton Lambda(特定のプロセッサを使う Lambda) - Lambda のインスタンスタイプ選択 - LMI のスケジュール自動スケーリング - Reserved Instances(予約購入)または Savings Plans(割引購入プラン)による Lambda のコスト最適化 **以下のような場合にも対応:** - 大量の予測可能なワークロードでコスト削減を求める場合 - LMI のキャパシティをスケジュールに基づいて拡張したい場合 - 安定したトラフィックに対して Lambda と EC2 を比較検討する場合 **注記:** LMI 機能を使わない標準的な Lambda の場合は、代わりに aws-lambda スキルをお使いください。
Evaluate, configure, and migrate workloads to AWS Lambda Managed Instances (LMI). Triggers on: Lambda Managed Instances, LMI, capacity provider, multi-concurrency Lambda, dedicated instance Lambda, EC2-backed Lambda, cold start elimination, Graviton Lambda, instance type for Lambda, scheduled scaling for LMI, Lambda cost optimization with Reserved Instances or Savings Plans. Also trigger when users describe high-volume predictable workloads seeking cost savings, want to scale LMI capacity on a schedule, or compare Lambda vs EC2 for steady-state traffic. For standard Lambda without LMI, use the aws-lambda skill instead.
AWSがプロビジョニング、パッチ適用、スケーリング、ルーティング、ロードバランシングを管理しながら、お使いのアカウント内の現行世代EC2インスタンス上でLambda関数を実行します。Lambdaの開発者エクスペリエンスと、EC2の料金体系およびハードウェアオプションを組み合わせたサービスです。
標準的なLambda開発については aws-lambda skill を、SAM/CDKによるデプロイについては aws-serverless-deployment skill を参照してください。
| 判断基準 | LMIが有力な選択肢 | 標準Lambdaが適切 |
|---|---|---|
| トラフィック | 安定・予測可能・月間5,000万リクエスト以上 | バースト的・予測不能・長時間アイドル |
| コスト | スケール時に実行時間のコストが大きい | 呼び出しが少ない・散発的 |
| コールドスタート | 許容不可(プロビジョニング済みキャパシティではLMIが排除;スケールアウト時に短い遅延が発生する場合あり) | 許容可能、またはSnapStartで緩和済み |
| コンピュート | 最新CPU・特定ファミリー・高ネットワーク帯域幅 | 標準LambdaのメモリおよびCPUで十分 |
| 分離性 | アカウント内の専有EC2インスタンス・完全なVPC制御 | 共有Firecracker マイクロVMで問題なし |
| ゼロスケール | 不要(実行環境は常時起動) | 必須(アイドル時は無課金にしたい) |
| コードの対応状況 | スレッドセーフ(Node.js / Java / .NET)またはPythonの任意のコード | スレッドアンセーフなNode.js / Java / .NETで変更コストが高い |
推奨を行う前に以下の情報を収集してください。
/tmpパスの共有は?呼び出しごとのDBコネクションは?必須: LMIを推奨する前にコスト比較を提示してください。最低限、以下のシナリオを比較します。
| シナリオ | 有利な条件 |
|---|---|
| Lambda オンデマンド | 低ボリューム・バースト的トラフィック |
| LMI オンデマンド | 高ボリューム・安定したトラフィック |
目安: Lambdaの月間費用が安定したトラフィックで約1,000ドルを超えると、LMIのコスト競争力が生まれます。
割引分析(Savings Plans、Reserved Instances)については、AWSの料金計算ツールおよび計算式と具体的な例が掲載されている references/cost-comparison.md をユーザーに案内してください。 割引の推奨はワークロード固有の予測が必要なため、このskillの対応範囲外となります。
インスタンスファミリー(約450種類): Cシリーズ(コンピュート・.xlarge以上)、Mシリーズ(汎用・.large以上)、Rシリーズ(メモリ・.large以上)。 価格性能比の観点からARM(Graviton)を推奨します。
メモリ対vCPU比率: 2:1(コンピュート)、4:1(汎用・デフォルト)、8:1(メモリ)。 最小2GB・最大32GB。
マルチ同時実行のデフォルト値(vCPUあたり): Node.js 64、Java 32、.NET 32、Python 16。
スケーリング: MinExecutionEnvironments(デフォルト3)、MaxVCpuCount(デフォルト400)、TargetResourceUtilization。
デシジョンツリーと詳細なチューニングについては references/configuration-guide.md を参照してください。
同時実行の安全性についてコードをレビューしてください。 LMIは1つの実行環境内で複数の呼び出しを並行して実行しますが、その動作モデルはランタイムによって異なります。
/tmpの競合とメモリサイジング(プロセスあたりのメモリ × 同時実行数)に注意してください。全ランタイム共通の注意点: /tmpパスの共有、呼び出しごとのDBコネクション。
スレッドセーフティの注意点(Node.js / Java / .NETのみ): ミュータブルなグローバル変数、スレッドセーフでないライブラリ。
レビューチェックリストは references/thread-safety.md、ランタイム別の移行前後のコード例は references/migration-patterns.md を参照してください。
CLIコマンドとSAMテンプレートについては references/infrastructure-setup.md を参照してください。
/tmpとメモリを確認)/tmp使用量の合計を見積もる/tmpパスへの書き込み| リソース | 制限 |
|---|---|
| メモリ | 最小2GB・最大32GB |
| 同時実行数/vCPU | 64(Node.js)、32(Java / .NET)、16(Python) |
| インスタンスの寿命 | 約12時間(Lambdaが自動的に置き換えます) |
| 実行環境(EE)の寿命 | 約4時間(Lambdaが自動的に置き換えます) |
| ランタイム | Node.js、Java、.NET、Python |
| インスタンスファミリー | C(.xlarge以上)、M(.large以上)、R(.large以上) |
| スケーリング | スロットリングなしで5分以内に2倍に拡張 |
| 問題 | 原因 | 対処方法 |
|---|---|---|
| 429スロットリング | トラフィックがスケーリング速度を超過 | MinExecutionEnvironmentsを増やすか、TargetResourceUtilizationを下げる |
| 関数がPENDING状態のまま | インスタンスのプロビジョニング中 | しばらく待つ;VPC / IAMの設定を確認する |
| アーキテクチャの不一致 | 関数とキャパシティプロバイダーのアーキテクチャが異なる | 両者を同じアーキテクチャに揃える |
| インスタンスを終了できない | キャパシティプロバイ |
Run Lambda functions on current-generation EC2 instances in your account while AWS manages provisioning, patching, scaling, routing, and load balancing. Combines Lambda's developer experience with EC2's pricing and hardware options.
For standard Lambda development, see aws-lambda skill. For SAM/CDK deployment, see aws-serverless-deployment skill.
| Signal | LMI is a strong fit | Standard Lambda is better |
|---|---|---|
| Traffic | Steady, predictable, 50M+ req/mo | Bursty, unpredictable, long idle |
| Cost | Duration-heavy spend at scale | Low or sporadic invocations |
| Cold starts | Unacceptable (LMI eliminates for provisioned capacity; scale-out may have brief delays) | Tolerable or mitigated by SnapStart |
| Compute | Latest CPUs, specific families, high network bandwidth | Standard Lambda memory/CPU sufficient |
| Isolation | Dedicated EC2 instances in your account, full VPC control | Shared Firecracker micro-VMs acceptable |
| Scale-to-zero | Not needed (execution environments always running) | Required (pay nothing when idle) |
| Code readiness | Thread-safe (Node.js/Java/.NET) or any Python code | Non-thread-safe Node.js/Java/.NET, expensive to change |
Gather these signals before recommending:
/tmp paths? Per-invocation DB connections?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.
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 and attach the CloudWatchLambdaInsightsExecutionRolePolicy managed policy to the function's execution role.
Target max concurrency (from cpu_total_time and Duration):
PerExecutionEnvironmentMaxConcurrency = floor((0.5 × Duration) / cpu_total_time)
This targets 50% CPU utilization at full concurrency, leaving headroom for scaling.
Memory allocation (from memory_utilization and current memory):
MemorySize = min(32768, max(2048, MaxConcurrency × (memory_utilization / 100) × current_allocated_memory))
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.
Minimum execution environments (from baseline ConcurrentExecutions):
MinExecutionEnvironments = max(3, ceil(baseline_concurrent_executions × 2 / MaxConcurrency))
Targets 50% concurrency utilization to leave headroom for traffic bursts.
Without Lambda Insights: Start with the runtime's default max concurrency, 2 GB memory, and MinExecutionEnvironments = 3. Adjust during testing.
REQUIRED: Present a cost comparison before recommending LMI. Compare at minimum:
| Scenario | When it wins |
|---|---|
| Lambda on-demand | Low volume, bursty traffic |
| LMI on-demand | High volume, steady traffic |
Rule of thumb: LMI becomes cost-competitive when your Lambda spend exceeds ~$1,000/month with steady traffic.
For discount analysis (Savings Plans, Reserved Instances), refer users to the AWS Pricing Calculator and references/cost-comparison.md for formulas and worked examples. Discount recommendations require workload-specific forecasting beyond this skill's scope.
Instance families (~450 types): C-series (compute, .xlarge+), M-series (general, .large+), R-series (memory, .large+). ARM (Graviton) for best price-performance.
Memory-to-vCPU ratios: 2:1 (default, CPU-bound work), 4:1 (general/mixed workloads), 8:1 (memory-heavy or Python apps). Min 2 GB, max 32 GB.
Multi-concurrency defaults/vCPU: Node.js 64, Java 32, .NET 32, Python 16.
Scaling: MinExecutionEnvironments (default 3), MaxVCpuCount (default 400), TargetResourceUtilization.
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.
See references/configuration-guide.md for decision trees and detailed tuning.
Review code for concurrency safety. LMI runs multiple invocations concurrently per execution environment, but the model differs by runtime:
/tmp conflicts and memory sizing (per-process × concurrency).Common issues (all runtimes): shared /tmp paths, per-invocation DB connections.
Thread-safety issues (Node.js/Java/.NET only): mutable globals, non-thread-safe libs.
See references/thread-safety.md for the review checklist and references/migration-patterns.md for runtime-specific before/after code.
See references/infrastructure-setup.md for CLI commands and SAM templates.
/tmp and memory for Python)/tmp usage under max concurrency/tmp paths without request-unique naming| Resource | Limit |
|---|---|
| Memory | 2 GB min, 32 GB max |
| Concurrency/vCPU | 64 (Node.js), 32 (Java/.NET), 16 (Python) |
| Instance lifespan | ~12 hours (auto-replaced by Lambda) |
| EE lifespan | ~4 hours (auto-replaced by Lambda) |
| Runtimes | Node.js, Java, .NET, Python |
| Instance families | C (.xlarge+), M (.large+), R (.large+) |
| Scaling | Doubles within 5 min without throttles |
| Issue | Cause | Fix |
|---|---|---|
| 429 throttles | Traffic exceeds scaling speed | Increase MinExecutionEnvironments or lower TargetResourceUtilization |
| Function stuck PENDING | Provisioning instances | Wait; check VPC/IAM config |
| Architecture mismatch | Function ≠ capacity provider arch | Align both to same architecture |
| Cannot terminate instances | Managed by capacity provider | Delete capacity provider instead |
| Race conditions | Code not thread-safe | See references/thread-safety.md |
See references/troubleshooting.md for detailed resolution steps.
REQUIRED: AWS credentials configured on the host machine.
Verify access: Run aws sts get-caller-identity
Available in all commercial AWS Regions except Israel (Tel Aviv), Middle East (Bahrain), Middle East (UAE), and Asia Pacific (Auckland).
Check the Lambda Managed Instances documentation for the latest regional availability.
Default: TypeScript
Override: "use Python" → Python, "use JavaScript" → JavaScript. When not specified, ALWAYS use TypeScript.
Default: CDK
Override: "use SAM" → SAM YAML, "use CloudFormation" → CloudFormation YAML. When not specified, ALWAYS use CDK.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。