← Back to the blog

AWS & n8n • 2026-08-13 • 3 min read

Rust on AWS Lambda and Graviton: Cold Starts Worth Measuring

A Rust Lambda on Graviton starts in single-digit milliseconds, which changes which workloads are worth putting behind a function at all. What to build, and what still belongs on ECS.

Rust on AWS Lambda and Graviton: Cold Starts Worth Measuring — AWS & n8n

Cold starts are the reason teams avoid serverless for latency-sensitive paths. With a compiled runtime and no JIT, the number stops being the reason.

Building for arm64

cargo-lambda handles the cross-compilation and packaging. The target is aarch64-unknown-linux-gnu, and the artefact is a single bootstrap binary in a zip.

// bash
cargo lambda build --release --arm64
cargo lambda deploy \
    --iam-role arn:aws:iam::123456789012:role/wident-verify \
    --env-var RUST_LOG=info \
    wident-verify

Graviton is cheaper per millisecond than x86 and, on this workload, faster. There is no reason to deploy a new Rust function to x86.

What actually drives the cold start

In our measurements the binary itself is barely the cost. The things that matter:

  • Binary size. Strip symbols, lto = "fat", codegen-units = 1, panic = "abort". A 3 MB binary loads faster than a 30 MB one, and the difference is measurable
  • What runs in `main` before the handler. Building a TLS client, reading a parameter from SSM, loading configuration — all of it is on the cold path. Initialise lazily, or accept the cost knowingly
  • VPC attachment. Hyperplane ENIs made this far better than it used to be, but it is not free. If the function does not need to reach a private resource, do not attach it
  • Provisioned concurrency, if you genuinely need a floor rather than a good average

A function that parses a request, verifies a signature and writes to DynamoDB comfortably starts in single-digit milliseconds. The p99 that users see is then dominated by whatever it calls, which is the right place for it to be.

Reusing work between invocations

Everything above the handler survives a warm invocation. Build the SDK client once, outside the handler, and keep it in a OnceLock. The same goes for a connection pool and anything parsed from configuration.

What must *not* be reused is anything request-scoped. A static mutable buffer is a data race waiting for the first concurrent invocation, and it will leak one request's data into another's response.

Where Lambda is the wrong tool

Honest limits:

  • Sustained, predictable traffic is cheaper on ECS; functions are priced for burst
  • Long-lived connections — WebSockets, streaming — fit badly
  • Anything that wants a warm local cache loses it constantly
  • Workloads needing more than the memory ceiling, or longer than the timeout

Our rule: event-driven and spiky goes to Lambda, steady request/response goes to ECS. The deciding question is the shape of the traffic, not the language.

Observability

Structured JSON to stdout, one line per invocation, with the request id. CloudWatch parses it, and the cost of logging the whole request body at scale is a line item you will notice — log the shape, not the content.

Read next

COOKIES // MEASUREMENT

We count page views through Google Tag Manager. Say yes and it may store a cookie in your browser; say no and it still counts the visit, without storing anything and without an identifier. Nothing here is used for advertising.

Cookie Policy — you can change this at any time from the footer of any page.