AWS in 1 Min · Episode 74

AWS Lambda explained: serverless functions (Part 1)

Serverless functions. Watch the one-minute video, then read the details.

David Gomez1:13 video · 3 min read

"Serverless means there are no servers." There are plenty. The difference is that they aren't yours to look after. With AWS Lambda, AWS provisions the machines, patches them, scales them and replaces them when they fail. You bring code. This is part one of three on Lambda: what a function is and when it fits. Part two covers triggers, part three cold starts and limits.

What a Lambda function is

A function is a small piece of code with one entry point, called the handler. Lambda runs the handler whenever an event arrives: an HTTP request, a new file, a message, a timer. The event is passed in as data, your code does its work, and it returns.

To create one you:

  1. Write the code and choose a runtime, such as Python, Node.js, Java or .NET. You can also package the function as a container image.
  2. Give it an execution role, the IAM role that says which AWS services the code may call.
  3. Set its memory and timeout.

A naming note: AWS documentation now calls this original function type Lambda Event Functions, to tell it apart from newer Lambda options for web servers and isolated environments. The API, the CLI and your templates still just say "function".

Scaling and paying

Lambda scales by running more copies of your function at the same time. Ten events at once means up to ten environments running in parallel, with no scaling rules to write. When the events stop, nothing runs.

Billing follows the same shape. For standard functions you pay:

  • a small charge per request
  • for duration: the time your code runs, metered in milliseconds, at a rate that depends on the memory you configured

There is no charge for idle time, and AWS publishes a monthly free tier for requests and compute. That makes Lambda very cheap for spiky or low-volume work, and not automatically cheap for code that runs flat out all day: at steady high load, a server or container can cost less. Do the arithmetic for your own traffic.

What it fits, and what it doesn't

Lambda is built for short, event-driven jobs: resizing an image, validating an upload, handling an API call, reacting to a database change, running a nightly cleanup.

The design rule to remember is that a function keeps no state between runs. Lambda may reuse an environment or start a new one, so anything you need later has to live outside the function: in Amazon S3, in a database, or in a queue. A common mistake is keeping important data in a local variable or a temp file and finding it gone on the next request.

Long-running processes, or apps that need a permanent connection or a GPU, usually belong on EC2 or containers instead.

Where AI fits

In AI systems Lambda is rarely the brain. It is the glue. An event arrives, the function gathers some context, calls a model on Amazon Bedrock, and stores or forwards the answer. For example: classify each support email as it comes in, tag every uploaded image, or act as the "tool" an AI agent calls to look up an order.

It suits that job because model calls are occasional and bursty, and you don't want a server sitting idle between them. Two things to check: the function's role needs permission to invoke the model, and the timeout must be long enough for the model to answer.

Quick recap

  • Serverless means no servers for you to manage. AWS runs them.
  • A function is code plus a handler; it scales by itself and keeps no state.
  • You pay per request and per millisecond, and nothing while idle.
AWS in 1 Min #74 · 1:13

Need an AWS expert on your team?

I'm David, an AWS expert and fractional cloud consultant. I work alongside your team to run your cloud and infrastructure: architecture, security, cost and day-to-day operations. You get senior AWS experience when you need it, without the cost of a full-time hire.

  • Architecture reviews and a clear plan for what to fix first
  • Security hardening: IAM, networking, audits
  • Lower AWS bills without slowing your team down
  • Hands-on help with AI workloads on AWS