Lambda functions on arm64 (AWS Graviton) are billed at a lower per-GB-second rate than x86_64, and many workloads also run faster. AWS documents roughly 20% lower duration cost, and often better price-performance. The change is a single line of configuration, but the risks are in native dependencies and build pipelines. This tutorial covers a safe migration with Serverless Framework V4.
Step 1: Check whether your workload is a good candidate
Pure Node.js, Python, Java and .NET code with no compiled dependencies usually moves without code changes. Watch for:
- Native npm modules such as
sharp,bcryptor database drivers with binaries. - Python wheels with C extensions (
numpy,pandas,cryptography,psycopg2). Most popular packages publishaarch64wheels, but verify. - Lambda layers built for x86_64. Layers must match the function architecture.
- Container images based on an x86 image, or binaries downloaded in the Dockerfile.
- Third-party extensions (APM agents) that need an arm64 build.
Step 2: Set the architecture per function
Start with one low-risk function, not the whole service:
service: orders-api
frameworkVersion: '4'
provider:
name: aws
runtime: nodejs22.x
architecture: x86_64 # service default stays for now
functions:
thumbnailer:
handler: src/thumbnail.handler
architecture: arm64
createOrder:
handler: src/orders.create
Once everything is verified, move the default by setting provider.architecture: arm64 and delete the per-function overrides.
Step 3: Build dependencies for the right target
If you package on an x86 CI runner or a laptop, native modules will be installed for the wrong platform. Options:
- Build on an arm64 runner. GitHub-hosted arm64 runners and other CI providers offer them, which keeps the build identical to production.
- Install for the target platform. For npm, for example:
npm install --os=linux --cpu=arm64 sharp. For Python,pip install --platform manylinux2014_aarch64 --only-binary=:all: --target ./package -r requirements.txt. - Container images. Use an arm64 base image and build with
docker buildx build --platform linux/arm64. Setprovider.ecr.imagesaccordingly, and make sure the image manifest is arm64 only.
Rebuild any Lambda layers for arm64 and publish them as separate versions that declare the arm64 compatible architecture.
Step 4: Benchmark before and after
Do not assume the speedup. Deploy the arm64 variant to a non-production stage and compare with realistic payloads:
- Run AWS Lambda Power Tuning against both architectures at several memory sizes.
- Compare p50, p95 and p99 duration, and
Init Durationfor cold starts. - Calculate cost per 1,000 invocations, since a faster function at a lower rate compounds, while a slower one may erase the saving.
CPU-bound code like compression, image processing and JSON-heavy transformations tends to benefit most. I/O-bound functions mostly gain the lower rate.
Step 5: Roll out gradually
Use the same canary approach you would for any risky deploy: alias traffic shifting with CodeDeploy, alarms on error rate and duration, and automatic rollback. Because architecture is a function-level setting, you can migrate in waves: stateless read endpoints first, then queue consumers, then latency-critical paths.
Remember that architecture changes need a new deploy; you cannot mix architectures within a single function version. Rolling back is a redeploy with architecture: x86_64.
Step 6: Update CI and local testing
- Run unit tests on arm64 in CI at least once, since subtle behavior differences in native libraries show up here.
- If you use
serverless-offlineor Docker locally on Apple Silicon, you already run arm64, which is a useful early check. On x86 machines, use QEMU emulation for container tests. - Add a lint or policy check that prevents x86-only layers from being attached to arm64 functions.
Common failure modes
Runtime.ExitErrororexec format errorat startup: a binary built for the wrong architecture.Cannot find modulefor a native package: it was installed on the wrong platform.- Layer attach errors: the layer version does not list arm64 as compatible.
Summary
Migrating to arm64 is typically a low-effort cost reduction when your dependencies cooperate. Inventory native code, build for the target, benchmark, and roll out in waves. If you want help auditing a large estate of functions for arm64 readiness, our performance tuning and migration teams do this regularly. Get in touch through the contact page.