Serverless

AWS Lambda

An AWS service that runs functions in response to events and bills only for execution time.

What it is

AWS Lambda launched in 2014 and started the mass trend of serverless. You upload a function (Node.js, Python, Java, Go, .NET, Ruby or your own container) and AWS runs it on an event and scales it automatically.

Triggers include HTTP requests (via API Gateway or a Function URL), messages in SQS, changes in S3 and DynamoDB, schedules (EventBridge) and other AWS events.

Billing is by number of invocations and gigabyte-seconds of execution. There are limits: at most 15 minutes per invocation, and the first start after idle has a cold start.

Use it when

  • Event processing: files in S3, queue messages, webhooks.
  • Uneven or rare load where a permanent server would sit idle.
  • Small APIs and scheduled backend jobs.
  • You need to glue AWS services together without managing servers.

Avoid it when

  • Long computations over 15 minutes or persistent connections (a WebSocket server).
  • Steady high load: an always-on container can be cheaper.
  • Latency-critical logic where a cold start is unacceptable.

Key concepts

Handler
The function that Lambda calls with an event and a context. This is what you write.
Cold start
Extra time for the first run when the environment is not ready. Smaller packages, lighter runtimes and provisioned concurrency reduce it.
Trigger
The event source: API Gateway, SQS, S3, EventBridge, DynamoDB Streams.
Concurrency
The number of simultaneous executions. There is an account limit and you can reserve capacity for a function.
Layer
A shared archive of dependencies attached to several functions.

Example

A Lambda handler behind a Function URL or API Gateway.

Interview questions

  1. 1. What is a cold start and how do you reduce it?

    It is the delay when Lambda creates a new execution environment before the first call. You reduce it with light dependencies, faster runtimes, initialization outside the handler and provisioned concurrency.

  2. 2. What are the main limits of Lambda?

    At most 15 minutes per invocation, limits on memory and package size, and no persistent state between calls. For state you use external stores: DynamoDB, S3, Redis.

  3. 3. How does Lambda scale?

    For each parallel request AWS creates a separate environment instance until the concurrency limit is hit. When traffic drops the instances disappear and you do not pay for idle time.

  4. 4. When is a container better than Lambda?

    When load is steady, runs are long or you need persistent in-memory state. Then ECS or Kubernetes give more control and are cheaper at high utilization.

Comparisons with this technology

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).