# Serverless

> Code that runs only when called; you never see or manage the server.

- Level: Intermediate
- Topics: Cloud
- URL: https://tidbit.legios.com.ar/serverless/
- In Spanish: [Serverless](https://tidbit.legios.com.ar/es/serverless/)

**Serverless** is a way of running code in the cloud where you upload a function and the provider runs it only when something triggers it: an HTTP request, a new file landing in Amazon S3, a timer. There are still servers, of course, but you never see them, size them or patch them. AWS Lambda is the best-known example, and the word also describes services like Amazon DynamoDB that scale by themselves with no machines to manage.

Billing is per execution. If your function runs 10 times a day for 200 milliseconds each, you pay for 2 seconds of computing. If a viral post sends a million requests, the provider starts thousands of copies in parallel and bills for those. Zero traffic costs zero, or close to it.

It suits spiky or small workloads: generating thumbnails, receiving webhooks, nightly reports, glue between services. It fits worse for long jobs, since a function usually has a time limit (15 minutes on Lambda), and the first call after a quiet period can be slow while the provider spins it up (a "cold start").

## An analogy

A taxi instead of owning a car. With a server you pay for the car even while it sits parked; with serverless you pay per trip, and someone else worries about the maintenance.

## Keep in mind

- You pay per invocation and per millisecond, not per hour of a running machine.
- It scales from zero to thousands of copies with no configuration.
- Functions are short-lived and stateless: save anything that matters in a database or in storage.
- Cold starts and vendor lock-in are the usual complaints.

## Go deeper

- [Serverless on AWS](https://aws.amazon.com/serverless/)
- [What is AWS Lambda? (official docs)](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)
- [Serverless computing (Wikipedia)](https://en.wikipedia.org/wiki/Serverless_computing)

## Related terms

- [Cloud computing](https://tidbit.legios.com.ar/cloud-computing/): Renting computers over the internet instead of buying your own.
- [HTTP](https://tidbit.legios.com.ar/http/): The request-and-response language browsers and websites speak.
- [Amazon S3](https://tidbit.legios.com.ar/amazon-s3/): A giant online drawer for files, rented by the gigabyte.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [AWS Lambda](https://tidbit.legios.com.ar/aws-lambda/): Run a piece of code only when something happens, with no server to manage.
- [Amazon DynamoDB](https://tidbit.legios.com.ar/amazon-dynamodb/): A key-value database that answers in milliseconds no matter how big the table gets.
- [Webhook](https://tidbit.legios.com.ar/webhook/): A way for one service to call your app the moment something happens.
- [Database](https://tidbit.legios.com.ar/database/): An organized store of data that programs can search and update safely.
