# AWS Lambda

> Run a piece of code only when something happens, with no server to manage.

- Level: Basic
- Topics: AWS
- URL: https://tidbit.legios.com.ar/aws-lambda/
- In Spanish: [AWS Lambda](https://tidbit.legios.com.ar/es/aws-lambda/)

**Lambda** lets you upload a function (a chunk of code in Python, JavaScript, Java and other languages) and tell AWS when to run it: when a file lands in Amazon S3, when an HTTP request arrives through Amazon API Gateway, when a message shows up in an Amazon SQS queue, or every day at 3 a.m. AWS finds a machine, runs your code, and throws the machine away. You never see a server.

You pay per request and per millisecond of execution. If nobody calls the function, the bill is zero. If a million people call it at once, AWS runs thousands of copies in parallel without you changing anything. The limits: one run lasts at most 15 minutes, and the first call after a quiet period is a bit slower (a **cold start**) while AWS prepares a fresh copy.

This is what people mean by serverless: there are still servers, but someone else owns them. A typical example: a photo app uploads an image to S3, which triggers a Lambda function that makes a thumbnail and stores it back. No machine sits idle waiting for the next photo.

## An analogy

A plumber on call instead of one on your payroll. You pay only for the visits, you do not care where they park the van, and if ten pipes burst at once the company sends ten plumbers.

## Keep in mind

- A function runs in response to an event: an upload, a request, a schedule.
- Billing is per request and per millisecond; idle time costs nothing.
- One execution lasts up to 15 minutes; longer jobs belong somewhere else.
- Scales on its own, from zero to thousands of parallel copies.

## Go deeper

- [What is AWS Lambda? (official docs)](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)
- [AWS Lambda](https://aws.amazon.com/lambda/)

## Related terms

- [Python](https://tidbit.legios.com.ar/python/): A popular programming language known for being easy to read and quick to write.
- [JavaScript](https://tidbit.legios.com.ar/javascript/): The programming language that runs inside web pages and makes them interactive.
- [Amazon S3](https://tidbit.legios.com.ar/amazon-s3/): A giant online drawer for files, rented by the gigabyte.
- [HTTP](https://tidbit.legios.com.ar/http/): The request-and-response language browsers and websites speak.
- [Amazon API Gateway](https://tidbit.legios.com.ar/amazon-api-gateway/): The front door of your API: it receives requests and passes them to your code.
- [Amazon SQS](https://tidbit.legios.com.ar/amazon-sqs/): A waiting line for messages between programs, so none of them gets lost.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [Serverless](https://tidbit.legios.com.ar/serverless/): Code that runs only when called; you never see or manage the server.
