Stop 04 · Compute ServicesTopics · 7/10

Serverless Computing (Lambda / Functions)

Part of the Cloud Computing Roadmap

In short

What if you never patched a server, never picked an instance size, and paid nothing when nobody used your app? That's the promise of serverless, with a few catches worth knowing.

Running code in response to events without managing any servers directly — you pay only for actual execution time, and the platform handles all scaling automatically, covered in depth in Phase 8.

The blob character waves to hail an auto-rickshaw on a sunny street.

Think of it like this

Hailing an auto

Owning a car means EMI, insurance, servicing and parking even when it sits idle. Hailing an auto, you pay only for the ride and someone else maintains the vehicle. Serverless functions are autos for your code.

Watch it happen

One photo upload, one function run

App
S3 bucket
Lambda
DynamoDB

PUT photo.jpg

1/5A user uploads a photo straight to a storage bucket.

The big ideas

What you need to know

Event in, code runs

Functions run in response to events: an HTTP request, a file upload, a queue message or a timer.

Scales by itself

Ten requests or ten thousand, the platform runs as many copies as needed, up to your account's limits.

Pay per run

You're billed for number of requests and run time. Idle costs nothing, which is perfect for spiky work.

Know the limits

Lambda runs max 15 minutes, has cold starts and keeps no local state between runs. Plan around these.

See it in code

Walk through the code

python
1import json2 3def handler(event, context):4    # event holds the trigger's details, e.g. an HTTP request5    name = (event.get("queryStringParameters") or {}).get("name", "friend")6 7    return {8        "statusCode": 200,9        "headers": {"Content-Type": "application/json"},10        "body": json.dumps({"message": f"Namaste, {name}!"}),11    }

1/3Lambda calls handler with the event and some runtime info.

A Lambda function behind an HTTP endpoint. No server code, no port, no framework: just a function that gets an event.

Save yourself the pain

Common mistakes

Oops

Saving files to the function's disk and expecting them next time.

Do this instead

Each run may be a fresh environment. Store anything you need in S3, a database or a cache.

Oops

Using functions for a constant, heavy, 24/7 workload by default.

Do this instead

At steady high load, containers or VMs can be cheaper and avoid cold starts. Do the maths.

Your mission

Your first function URL

~25 min

Quick check

Which job suits a serverless function best?

Go deeper

  1. 1Deploy a simple function triggered by an HTTP request.
  2. 2Learn the trade-offs: no server management, but cold starts and execution time limits.
  3. 3Preview Phase 8 for a deeper dive into event-driven serverless architecture.

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.

Download
InsideEdge