# Firecracker snapshot restore & wake-ahead

> Every workload runs in its own Firecracker microVM that snapshots to disk at zero RAM cost (SSD platform-only snapshot-restore p95 target: below 350 ms) and pre-wakes internal service dependencies automatically.

Category: Runtime · Maturity: GA & Beta · Plans: Free, Hobby, Pro, Scale · Updated 2026-11-26

Most scale-to-zero platforms force either shared container kernels, multi-second cold starts, or cascading delays when an edge API calls internal microservices. Gregale pairs hardware-virtualized Firecracker snapshots with Service Wake-Ahead, after-restore lifecycle hooks, and zero-rewrite OCI compatibility.

## Configure after_restore hooks and multi-service wake-ahead in YAML

```yaml
# gregale.yaml — refresh in-memory connections right after snapshot restore
lifecycle:
  after_restore:
    path: /internal/after-restore
    timeout_ms: 500

# compose.yaml — toggle automatic wake-ahead per dependent service
services:
  billing:
    build: ./billing
    x-gregale-wake-ahead: true
```

## Key capabilities

- **MicroVM snapshot restore:** Idle instances park to snapshot on disk at zero resident RAM. SSD platform-only snapshot-restore p95 target: below 350 ms. Public request latency also includes network transit and can be higher. A fresh cold boot is a separate path.
- **Service wake-ahead:** When an app wakes, Gregale automatically starts waking its parked internal dependencies right away so multi-service chains avoid serialized cold-start stacks.
- **After-restore hooks & automatic fallback:** Run an idempotent loopback hook (X-Faas-After-Restore: 1) after guest clock and entropy repair; if it fails or times out, Gregale falls back cleanly to a fresh cold boot.
- **Warm pools, wake pages & timelines:** Inspect exact phase timings per wake in the Wake Timeline, show branded waiting pages to browser visitors if needed, or keep warm paused capacity on paid plans.

## Typical PaaS vs. Gregale

| Capability | Typical PaaS | Gregale |
|---|---|---|
| Workload isolation boundary | Shared Linux kernel / cgroup containers | Dedicated Firecracker KVM microVM per instance |
| Cascading microservice wakes | Downstream services stay cold until caller reaches them | Service wake-ahead wakes declared dependencies immediately |
| Post-restore connection refresh | Stale sockets discovered on live user request | lifecycle.after_restore hook with cold-boot fallback |

## Documentation

- [Scale to zero](https://gregale.dev/docs/scale-to-zero.md)
- [Internal services](https://gregale.dev/docs/internal-services.md)
- [Multi-service Compose](https://gregale.dev/docs/multi-service.md)
- [Container compatibility](https://gregale.dev/docs/container-compatibility.md)
- [Scaling policies](https://gregale.dev/docs/scaling-policy.md)

## Related guides

- [scale-to-zero-without-cold-starts](https://gregale.dev/articles/scale-to-zero-without-cold-starts.md)
- [microvm-isolation](https://gregale.dev/articles/microvm-isolation.md)
- [private-microservice-networking-no-vpc](https://gregale.dev/articles/private-microservice-networking-no-vpc.md)
- [deploy-docker-container-scale-to-zero-no-rewrite](https://gregale.dev/articles/deploy-docker-container-scale-to-zero-no-rewrite.md)

## Research

- [firecracker-snapshot-restore-ssd-2026-09-09](https://gregale.dev/research/firecracker-snapshot-restore-ssd-2026-09-09.md)
- [intermittent-fastapi-cost-2026-11-24](https://gregale.dev/research/intermittent-fastapi-cost-2026-11-24.md)
- [paas-intermittent-api-cost-model-2026-11-25](https://gregale.dev/research/paas-intermittent-api-cost-model-2026-11-25.md)

## Runnable starters on GitHub

- [Postgres Migration & Rollback Demo](https://github.com/gregale-dev/postgres-migration-rollback-demo) (Python 3.13 · FastAPI · Postgres 17): FastAPI + managed PostgreSQL 17 starter demonstrating release.command migrations (MIGRATION_DATABASE_URL) and coordinated code + database rollback via gregale rollback --restore-databases.
- [Next.js 16 + Postgres Starter](https://github.com/gregale-dev/nextjs-postgres-starter) (Node 24 · Next.js 16 · Postgres 17): Next.js App Router with output: "standalone", pre-traffic SQL migrations, separate /healthz readiness check, and scale-to-zero MicroVMs.
- [Bun + Hono + Postgres Starter](https://github.com/gregale-dev/bun-hono-postgres-starter) (Bun 1 · Hono · TypeScript · Postgres 17): TypeScript REST API using Bun, Hono, and postgres.js with release-command SQL migrations and managed PostgreSQL 17 suspension when idle.
- [Scale-to-Zero WebSockets & SSE](https://github.com/gregale-dev/scale-to-zero-websockets) (Node 22 · Managed Realtime): Hold thousands of idle WebSocket or SSE connections on Gregale Managed Realtime with heartbeat offload and HTTP callbacks so your app parks at $0 compute.
- [Node.js API + Private Worker Queue](https://github.com/gregale-dev/node-api-worker) (Node 22 · Docker Compose · Postgres 17): Multi-service Compose starter pairing a public Express API with a private worker and Postgres FOR UPDATE SKIP LOCKED job queue without Redis.
- [FastAPI + Postgres Background Jobs](https://github.com/gregale-dev/fastapi-postgres-jobs) (Python 3.13 · FastAPI · Postgres 17): FastAPI HTTP API with a durable PostgreSQL job queue, leases, and exponential retries that scales both compute and database to zero when idle.

Browse all starters: https://gregale.dev/templates.md

## Frequently asked questions

### What does the snapshot restore target measure?

SSD platform-only snapshot-restore p95 target: below 350 ms. Public request latency also includes network transit and can be higher. A fresh cold boot is a separate path. The platform interval covers capacity admission or boot start through the first upstream byte (scheduler, snapshot restore, and internal proxy).

### Do I have to configure Service Wake-Ahead manually for Compose apps?

Wake-ahead is enabled automatically for declared project dependencies and can also be toggled per app with gregale app wake-ahead <app> on|off or x-gregale-wake-ahead in Compose.

### How do existing Docker images run with scale to zero?

Any stateless Linux/amd64 Docker or OCI container listening on HTTP works without function SDK rewrites. Stateless contract checks also warn before deploy if code relies on local ephemeral disk surviving a park.

Canonical URL: https://gregale.dev/features/firecracker-scale-to-zero
