In short
What if you didn't run a server at all? With Lambda you upload a function, AWS runs it only when something happens, and you pay per request instead of per hour.
Running backend code as individual functions that execute on-demand and scale automatically, without managing any servers — you pay only for actual execution time.

Think of it like this
Hailing an auto vs owning a car
Owning a car means paying EMI and parking even on days you stay home. An auto-rickshaw shows up when you wave, takes you there, and you pay only for that ride. Lambda is the auto: no idle cost, but after a quiet spell the first one takes a moment to arrive.
Watch it happen
A cold start, then a warm one
POST /orders
1/5A request arrives at API Gateway, the front door that turns HTTP into a Lambda event.
The big ideas
What you need to know
Event-driven
Functions run on events: an HTTP call, a new S3 file, a queue message or a cron schedule.
Scales down to zero
No traffic, no compute cost. A spike? AWS runs many copies in parallel, up to your account's concurrency limit.
Cold starts
A new instance must load your code first. Keep bundles small and do setup outside the handler so it's reused.
Limits apply
One invocation can run for at most 15 minutes. Long jobs belong on a queue worker or a container.
See it in code
Walk through the code
1// handler.ts, on the Node.js 22 runtime2import { DynamoDBClient } from "@aws-sdk/client-dynamodb";3import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb";4import type { APIGatewayProxyHandlerV2 } from "aws-lambda";5 6// Outside the handler: created once per instance, reused while warm7const db = DynamoDBDocumentClient.from(new DynamoDBClient({}));8 9export const handler: APIGatewayProxyHandlerV2 = async (event) => {10 const order = JSON.parse(event.body ?? "{}");11 await db.send(new PutCommand({ TableName: "orders", Item: order }));12 return { statusCode: 201, body: JSON.stringify({ ok: true }) };13};1/4Clients made outside the handler survive between warm invocations.
Real code would validate the body first. The AWS SDK v3 ships with the Node.js runtime, but bundling your own copy pins its version.
Save yourself the pain
Common mistakes
Oops
Opening a new database connection inside the handler on every call.
Do this instead
Create clients outside the handler so warm invocations reuse them. Otherwise you flood the database with connections.
Oops
Moving a long video-encoding job to Lambda.
Do this instead
Invocations stop at 15 minutes. Use a queue plus a container or EC2 worker for long tasks.
Your mission
Your first function
Quick check
Your Lambda's first request after a quiet hour is slow, and later ones are fast. What's happening?
Go deeper
- 1Deploy a simple function to AWS Lambda and trigger it via API Gateway.
- 2Learn the trade-offs: no idle cost and automatic scaling, but cold starts and execution time limits.
- 3Compare when serverless fits (spiky, event-driven workloads) vs when a traditional server fits better.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.