Command Palette

Search for a command to run...

Назад к скиллам
скилл № 51346

cloud-native-serverless-cold-starts

Use when the user asks to reduce Lambda cold start latency, Init Duration, provisioned concurrency, SnapStart, GraalVM native Lambdas, Azure Functions or…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить cloud-native-serverless-cold-starts в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Serverless Cold Starts

Purpose

A cold start happens when a request needs a new execution environment. Its cost is environment creation + runtime start + your init code. Measure which part dominates, then apply the cheapest fix: smaller init, faster runtime packaging, snapshotting, or paying for pre-warmed capacity.

Agent Protocol

Trigger

"cold start", "init duration", "provisioned concurrency", "SnapStart", "optimize serverless startup", "GraalVM native", "min instances", "Azure Functions cold start", "Cloud Run cold start".

Input Context

  • Platform/runtime, package size, memory setting, VPC attachment.
  • Latency SLO (p99) and traffic pattern (steady vs spiky vs idle for long periods).
  • Current Init Duration distribution and cold-start rate.

Output Artifact

Diagnosis + prioritized changes (code/IaC). No file unless requested.

Response Format

Cold-start rate: {%} | p99 Init Duration: {ms}
Dominant cost: {runtime boot|dependency loading|network setup|package size}
Fixes (ordered by cost/impact): 1) ... 2) ...
Pre-warmed capacity: {none|SnapStart|provisioned N|min instances N} (cost note)

Completion Criteria

  • Measured before and after (Init Duration from REPORT logs / X-Ray / OTel).
  • Code-level fixes attempted before paying for provisioned capacity.

Anatomy (AWS Lambda)

  1. Environment creation — Firecracker microVM, code download (ZIP from S3 or container image chunks lazily loaded and cached).
  2. Runtime init — start Node.js/Python/JVM/.NET; extensions start.
  3. Function init — module-level code: imports, SDK clients, config fetch, DB connections.
  4. Invoke — handler. CloudWatch REPORT lines show Init Duration only on cold starts. Since 1 August 2025, INIT is billed for all on-demand configurations (previously free for ZIP managed runtimes), so slow init now costs money too.

Find cold starts with Logs Insights:

filter @type = "REPORT"
| stats count(*) as invocations, count(@initDuration) as coldStarts,
        pct(@initDuration, 99) as p99Init, avg(@initDuration) as avgInit by bin(1h)

Fixes in Order of Cost

1. Shrink init work (free)

  • Import only what you use (AWS SDK v3 per-client packages in Node.js: @aws-sdk/client-dynamodb, not the whole SDK).
  • Bundle and tree-shake (esbuild) for Node.js; exclude dev dependencies.
  • Lazy-load rarely used heavy modules inside the code path that needs them.
  • Create SDK clients/connection pools at module scope so warm invocations reuse them; don't open DB connections you might not need.
  • Fetch config/secrets once and cache with TTL (Parameters and Secrets Lambda Extension or Powertools parameters).
// Node.js 22, ESM
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb";

const ddb = DynamoDBDocumentClient.from(new DynamoDBClient({})); // init once

export const handler = async (event) => {
  if (event.rawPath === "/report") {
    const { renderPdf } = await import("./pdf.js");   // heavy, rarely used: lazy
    return renderPdf(event);
  }
  const { Item } = await ddb.send(new GetCommand({ TableName: process.env.TABLE, Key: { pk: event.pathParameters.id } }));
  return { statusCode: Item ? 200 : 404, body: JSON.stringify(Item ?? {}) };
};

2. Right-size memory and architecture

CPU scales with memory; init-heavy functions often get faster and cheaper at higher memory. Test with AWS Lambda Power Tuning. arm64 (Graviton) is usually cheaper per GB-second.

3. Runtime and packaging

Runtime Typical cold start profile Lever
Go/Rust (provided.al2023) Lowest Already compiled
Node.js / Python Low–medium, grows with dependencies Bundle, trim imports
Java Highest without help (class loading, JIT) SnapStart, tiered compilation (-XX:TieredStopAtLevel=1), or GraalVM native image
.NET Medium–high Native AOT, SnapStart (supported for .NET 8+)

4. Snapshotting — Lambda SnapStart

Lambda initializes once when you publish a version, snapshots the microVM memory/disk (Firecracker snapshot), and restores from the cache on cold start. Supported for Java 11+, Python 3.12+, and .NET 8+ managed runtimes.

  • Works on published versions/aliases only; not with provisioned concurrency, EFS, or ephemeral storage > 512 MB.
  • Uniqueness: anything generated during init (random seeds, UUIDs, unique IDs, credentials with expiry) is shared across restored environments — regenerate in a runtime hook (afterRestore via CRaC Resource in Java, @register_after_restore in Python).
  • Re-establish network connections after restore.

5. Pay for warm capacity

Platform Feature Note
AWS Lambda Provisioned concurrency (per alias/version), scheduled or target-tracking via Application Auto Scaling Billed hourly while configured; spillover beyond it cold-starts
Azure Functions Flex Consumption always-ready in
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/firecracker-microvm.md
  • references/provisioned-concurrency.md
  • references/runtime-optimizations.md

FAQ

Что делает скилл cloud-native-serverless-cold-starts?

Use when the user asks to reduce Lambda cold start latency, Init Duration, provisioned concurrency, SnapStart, GraalVM native Lambdas, Azure Functions or Cloud Run cold starts, or min instances. Produces a measured cold-start diagnosis and fixes for init code, packaging and runtime. Not for Lambda concurrency and event sources (use cloud-native-aws-serverless).

Как установить скилл cloud-native-serverless-cold-starts?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл cloud-native-serverless-cold-starts запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить cloud-native-serverless-cold-starts с