Architecture of AWS Lambda

Architecture of AWS Lambda

Note: If you’re not a medium member, CLICK HERE

AWS Lambda = Serverless Functions-as-a-Service (FaaS)

You write the code → Lambda runs it when an event happens → You don’t touch a single server.

It’s called FaaS because you’re essentially running just your function as a service. No need to spin up EC2s or build any Infrastructure( like setting up networking and a new EC2 instance to deploy and run your application). Its like running a simple Python script that just works — zero setup.

You write code → Lambda executes it in response to an event → No need to provision or manage servers.

FaaS because this helps you to run your function as a service. You dont need to setup the infra to run you application( lets take simple python application as example for now).

Feature of Lambda

  • Trigger-based execution: Events (like S3 upload, API Gateway HTTP call etc.) trigger the function.

  • Stateless: No persistent local state — use services like S3, DynamoDB, RDS externally.

  • Auto-scaling: AWS handles concurrency and scaling behind the scenes ( comment for seperate medium article for in-depth analysis of concurrency)

  • Short-lived tasks: Max 15 mins per invocation.

  • Cost-efficient: Pay only for execution time and resources used.

Where Does Lambda Actually Run?

Internally, Lambda uses:

  • Firecracker MicroVMs (AWS-built VMM tech for secure, lightweight VMs) [ please drop in comment if you want a separate article about Firecracker MicroVM’s ]

  • Think of it as “a mini VM spun up in milliseconds” and isolated securely

  • It runs in the region where your Lambda is deployed

  • Backed by physical AWS EC2 infrastructure, but you don’t manage any of that

From Hardware to Lambda

Step 1: Physical Hardware

  • It all starts with physcial hardware Machine which are present at any data centre. So, AWS has racks of physical servers — metal beasts.

Step 2: Firecracker

  • Firecracker is AWS’s lightweight hypervisor (open-source, super fast).

  • It takes that big piece of metal and breaks it into microVMs (micro Virtual Machines), each isolated, secure, and fast-booting.

  • It’s not a full VM like EC2; it’s tiny, boots in ~125ms or less.

Step 3: Lambda Containers inside MicroVMs

  • Inside each microVM, your Lambda code runs in a container.

  • Container doestn’t mean a docker container. Its more like a container runtime environment with minimal OS.

Does Lambda Reuse Containers?

Yes! This might be possible.

AWS uses a concept called “container reuse” or warm containers:

  • If you invoke a Lambda function and then another invocation comes shortly after…then, AWS may route it to the same container (inside the same microVM)

  • But remember — it’s possible, not guaranteed. It depends on factors like traffic pattern, memory size, and whether AWS decides to keep that container warm.

0
Subscribe to my newsletter

Read articles from Aakash Choudhary directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aakash Choudhary
Aakash Choudhary