Home › AWS Resources › Lambda Web Functions

Lambda Web Functions

Run a standard HTTP server (Express, Hono, Fastify) on Lambda with no handler rewrite: multi-concurrency, active-CPU billing, multi-Region endpoints, and how the cost compares to Event Functions.

What Are Lambda Web Functions?

Lambda Web Functions run a standard port-listening HTTP server on Lambda. You deploy the Express, Hono, Fastify, or Next.js app you already have. You don't write an event handler or use an adapter library, and you don't need API Gateway. Lambda gives you an HTTPS endpoint, scales environments up and down, and bills on the CPU your code uses.

They are one of three Lambda form factors, all on Firecracker:

Form factor Programming model Concurrency Billing
Event Functions (what used to be just "Lambda") Handler receives an event 1 request per environment (more on Managed Instances) Requests + wall-clock duration
Web Functions Your server listens on a port Many requests per environment Requests + active CPU + memory
MicroVMs Isolated stateful sandbox Per-session Per instance-second

When to Use Web Functions

Good fit:

  • An existing Node.js HTTP app or API you want on Lambda without rewriting it into handlers
  • I/O-heavy backends that spend most of each request waiting on a database or downstream API
  • Streaming responses (SSE, chunked transfer) such as LLM gateways
  • Server-side rendering behind CloudFront
  • Global audiences where multi-Region endpoints with latency-based routing are worth having

Stay with Event Functions when:

  • You already have tuned Event Functions. For short requests they are usually cheaper (see below)
  • The trigger isn't HTTP: SQS, S3, EventBridge, Kinesis, DynamoDB Streams
  • Your runtime isn't Node.js 24 yet
  • You need more than 2 vCPUs or 2 GB per environment

Use ECS/Fargate when:

  • You need WebSockets or other non-HTTP protocols (AWS documents SSE, chunked transfer, and request/response streaming, not WebSockets)
  • You need sidecars, large images, or more than 2 GB per task

How It Works

Your server reads the host and port Lambda assigns from AWS_LAMBDA_HTTP_ENDPOINT and listens there. Everything else is a normal HTTP server:

import express from 'express';
const app = express();
const [host, port] = process.env.AWS_LAMBDA_HTTP_ENDPOINT.split(':');
app.get('/', (req, res) => {
  res.json({ message: 'Hello from Lambda Web Functions!' });
});
app.listen(port, host);

To run locally, set the variable yourself: AWS_LAMBDA_HTTP_ENDPOINT=127.0.0.1:3000 node index.js.

Deploy with one command:

aws lambda-web deploy --name my-web-app --code ./my-app
# multi-Region, with one global latency-routed URL
aws lambda-web deploy --name my-web-app --code ./my-app \
  --regions us-east-1,eu-west-1,ap-northeast-1

Key concepts

  • Revision: an immutable snapshot of your deployed code.
  • Endpoint: the HTTPS URL that routes to a revision. An endpoint can split traffic between two revisions, which gives you canary releases without extra tooling.
  • Multi-concurrency: one environment serves many requests at once (default 64, up to 128). Background work continues after the response is sent.
  • CloudFront origin: use an endpoint as a distribution origin, and attach origin access control so only your distribution can call it.
# 90/10 canary between two revisions
aws lambda-web update-web-function-endpoint \
  --function-name my-web-app --endpoint-name dev \
  --auto-deployment-mode Disabled \
  --revision-weights '[{"revisionId": "<current>", "weight": 90}, {"revisionId": "<new>", "weight": 10}]'

Pricing

Three components, US East (N. Virginia), Arm:

Component Price
Requests $0.30 per million (Event Functions: $0.20)
Active vCPU $0.0000276944 per vCPU-second, metered on CPU your code uses
Memory $0.0000036667 per GB-second, for as long as the environment exists, including idle time between requests

Time spent waiting on a database or API call uses little CPU, so it costs little. Memory is shared by all concurrent requests in an environment.

Event Functions vs Web Functions

These figures use AWS's Web Functions pricing examples (one always-on environment, even traffic). The Event Function numbers are my calculation at Arm pricing ($0.0000133334 per GB-second, $0.20 per million requests) and assume the memory size gives the same duration.

Workload (per month) Web Function Event Function
Authorizer: 100M req, 50 ms, 12 ms CPU $64.56 $28.33 (128 MB)
SSR app: 15M req, 150 ms, 40 ms CPU $25.78 $18.00 (512 MB)
I/O-heavy API: 10M req, 200 ms, 50 ms CPU $19.61 $15.33 (512 MB)
LLM streaming: 5M req, 3 s, 200 ms CPU $33.94 $101.00 (512 MB)

Short requests favor Event Functions. Requests that wait a long time relative to their CPU time, and streaming responses, favor Web Functions. With about 50 ms of CPU per request, the break-even against a 512 MB Event Function is a little over 250 ms of total request time. Moving optimized Event Functions to Web Functions rarely saves money. The reason to move is to avoid rewriting an existing HTTP app.

What Changes in Your Code

  • Per-request state can't live in module globals. Concurrent requests share one process. Use AsyncLocalStorage or pass state explicitly. This is the same discipline Managed Instances requires.
  • Startup must finish quickly. Your server has 10 seconds to start listening.
  • Request timeout defaults to 30 seconds (range 3 to 900). Set it per revision.
  • Outbound traffic from the environment is IPv4 only for direct public egress. VPC access goes through an egress network connector, which is limited to single-Region (home Region) endpoints.

Limits at Launch

Limit Value
Runtime Node.js 24 (nodejs24.x), Arm64 only
Regions us-east-1, us-east-2, us-west-2, ap-northeast-1, eu-west-1
vCPUs / memory per environment 2 / 2 GB
Concurrent requests per environment 64 default (1-128)
Request timeout 30 s default (3-900 s)
Deployment package 512 MB unzipped
/tmp 512 MB
Endpoints per Web Function 10
Revisions an endpoint can route 2
Requests per second per account 100,000 (adjustable)
Arm64 vCPUs per account per Region 2,000 (adjustable)

New accounts start with reduced vCPU and request-rate quotas that AWS raises with usage. Private endpoint access through AWS PrivateLink is not available.

Further Reading

Looking for hands-on help? View my AWS architecture services →

Moving a web app or API to Lambda?

Drop me a message — I typically respond within one business day.