Serverless compute · Chapter 1 of 2
How Lambda executes your code
Serverless compute removes the operating system layer, but forces you to work within memory and execution time ceilings.
FoundationsBuilds the idea from nothing. No prior AWS assumed.
The serverless execution model
What does it mean to run code without managing a server?
First request invokes an idle Lambda function. Firecracker MicroVM environment must be provisioned.
- 01
Renting execution instead of hardware
Instead of paying for a virtual machine that sits idle waiting for requests, AWS Lambda runs your code only when triggered. AWS manages the underlying operating system, scaling, and patching.
- 02
The ephemeral execution environment
When a request arrives, Lambda creates a microVM container to run your code. Once execution finishes, the container is kept alive for a short time to process future requests, before being destroyed.
- 03
The per millisecond billing model
You are billed based on the number of requests and the duration it takes for your code to execute, measured in milliseconds. If your function runs for 15 milliseconds, you pay for 15 milliseconds.
Check yourself
How is the execution cost of a Lambda function calculated?
Under the hoodThe same thing from underneath: limits, failure modes, numbers.
Cold starts and execution limits
What happens during a cold start when a function is triggered after being idle?
First request invokes an idle Lambda function. Firecracker MicroVM environment must be provisioned.
- 01
The anatomy of a cold start
If a function is idle or needs to scale, Lambda must download your deployment package, initialize the runtime, and run your global initialization code. This boot sequence is a cold start and adds latency to the request.
- 02
The fifteen minute ceiling
AWS Lambda is designed for short-lived tasks. The maximum execution duration for a single invocation is 15 minutes, after which AWS terminates the container, returning an execution timeout error.
- 03
Memory dictates CPU allocation
You cannot configure CPU cores in Lambda. Instead, you select a memory size, and AWS allocates a proportional amount of CPU power and network bandwidth to your function.
The numbers
- Maximum timeout
- 900 secondsThe absolute ceiling for execution duration. Code that runs longer will be terminated.
- Memory range
- 128 MB to 10,240 MBConfiguring memory also allocates CPU. At 1,769 MB, you receive the equivalent of 1 full vCPU.
- Ephemeral storage limit
- 512 MB to 10,240 MBThe size of the /tmp directory available to your code for temporary file writes.
- Zip deployment limit
- 50 MB compressedThe maximum size of a zip package uploaded directly, or 250 MB uncompressed.
- Cold start runtime duration
- 100ms to 5,000msLight runtimes like Node.js start faster than heavy frameworks like Java.
Check yourself
You need to increase the CPU allocation for a Lambda function. How do you perform this configuration in the AWS console?
Official references & further reading
These lessons simplify selected behaviors for learning. Verify current service limits, Region support and production requirements with the official references. Experiments describe their own assumptions.
Report an error or suggest a clearer explanation →