Modern QA2026Cold Start Deep Dive — tiles
Log inJoin
84 / 95 · 05 Performance & Chaos Engineering · Serverless Performance Testing← prev⊞ allnext →☰ Read as one page

13.3Cold Start Deep Dive

Cold starts are the most impactful serverless performance concern. A cold start occurs when the cloud provider needs to:

  1. Provision a new execution environment
  2. Download your deployment package
  3. Initialize the runtime (Node.js, Python, Java, etc.)
  4. Execute your initialization code (imports, connections, model loading)

Cold Start Benchmarks by Runtime

Runtime Typical Cold Start With VPC With Large Bundle
Node.js 100-300ms +300-500ms +50-200ms
Python 200-500ms +300-500ms +100-300ms
Go 50-100ms +300-500ms +20-50ms
Java 1-5s +300-500ms +500ms-2s
.NET 500ms-2s +300-500ms +200-500ms

Measuring Cold Starts with k6

// k6-serverless-cold-start.js
import http from 'k6/http';
import { Trend, Counter } from 'k6/metrics';
import { sleep } from 'k6';

const coldStartLatency = new Trend('cold_start_ms', true);
const warmLatency = new Trend('warm_latency_ms', true);
const coldStartCount = new Counter('cold_start_detected');

export const options = {
  scenarios: {
    cold_start_measurement: {
      executor: 'per-vu-iterations',
      vus: 1,
      iterations: 8,
      maxDuration: '60m',
    },
  },
  thresholds: {
    cold_start_ms: ['p(95)<5000'],     // cold starts under 5s
    warm_latency_ms: ['p(95)<500'],     // warm requests under 500ms
  },
};

export default function () {
  // Wait for scale-to-zero (adjust based on provider settings)
  const idleMinutes = [0, 1, 3, 5, 10, 15, 20, 30];
  const iteration = __ITER;
  const idleTime = idleMinutes[iteration] || 30;

  console.log(`Waiting ${idleTime} minutes for idle...`);
  sleep(idleTime * 60);

  // First request after idle = likely cold start
  const coldRes = http.get('https://api-gw.example.com/function', {
    timeout: '60s',
  });
  const firstLatency = coldRes.timings.duration;

  // If first request is >3x the expected warm latency, it is a cold start
  const isColdStart = firstLatency > 1000; // threshold: 1s
  if (isColdStart) {
    coldStartLatency.add(firstLatency);
    coldStartCount.add(1);
    console.log(`Cold start after ${idleTime}min idle: ${firstLatency}ms`);
  }

  // Warm requests for comparison
  for (let i = 0; i < 5; i++) {
    const warmRes = http.get('https://api-gw.example.com/function');
    warmLatency.add(warmRes.timings.duration);
    sleep(0.5);
  }
}