Section 1: Serverless foundations
What serverless really means
Serverless does not mean there are no servers. It means you do not manage them. You give AWS your code and configuration, and AWS runs it on demand, scales it and patches the underlying machines.
How a Lambda function runs
A Lambda function is a handler, a function AWS calls with an event and a context:
def handler(event, context):
name = event.get("queryStringParameters", {}).get("name", "there")
return {"statusCode": 200, "body": f"Hello, {name}"}
When a request arrives and no execution environment is ready, Lambda creates one: it downloads your code, starts the runtime and runs any initialisation code outside the handler. This is a cold start. Later requests reuse the warm environment, so code outside the handler, such as creating an SDK client, runs once per environment rather than once per request.
Each environment handles one request at a time. If 50 requests arrive at once, Lambda runs up to 50 environments in parallel, subject to your account's concurrency limits.
Limits worth knowing
- Maximum timeout per invocation: 15 minutes.
- Memory from 128 MB up to 10,240 MB, and CPU scales with memory.
- Payload size limits apply to synchronous requests, so large files go through S3, not through the event.
Pricing in one paragraph
You pay per request and per unit of compute time, measured in gigabyte seconds. Idle functions cost nothing. This is excellent for spiky or low traffic workloads. For a service under constant heavy load, an always on container can be cheaper, which we calculate in the final section.
The serverless toolbox
Lambda is rarely alone. Serverless applications combine managed services: API Gateway for HTTP, DynamoDB for data, SQS for queues, EventBridge for events, S3 for files, Step Functions for workflows. Each one scales on its own and bills per use. Your job shifts from running servers to connecting services correctly: permissions, error handling and data design. That is what this course focuses on.
When not to use it
Long running jobs over 15 minutes, workloads needing GPUs, very latency sensitive paths where cold starts matter, or steady high throughput services may be better on containers. We revisit this decision with numbers at the end of the course.