What is serverless, and when would you use it?
In one line: Serverless means running code without managing servers — the cloud provider runs your code when an event happens, scales it automatically (even to zero) and charges only for actual use.
Common serverless services:
- Functions (FaaS): AWS Lambda, Azure Functions, Google Cloud Functions / Cloud Run functions.
- Serverless containers: AWS Fargate, Google Cloud Run, Azure Container Apps.
- Serverless data and integration: DynamoDB, S3, SQS, EventBridge, API Gateway, Step Functions.
How a function works:
- An event occurs — an HTTP request through API Gateway, a file uploaded to S3, a message in a queue, a schedule.
- The platform starts your function (if not already warm) and runs it.
- You pay per request and for execution time × memory.
Good use cases:
- APIs with uneven or unpredictable traffic.
- Event processing: resize images when uploaded, process queue messages.
- Scheduled jobs: nightly reports, cleanup tasks.
- Glue and automation: react to cloud events (for example tag new resources, send alerts).
- Prototypes and small services where you don't want to run servers.
Limitations:
- Cold starts — the first request after idle can be slower.
- Time limits (Lambda: max 15 minutes per run) — not for long-running jobs.
- Vendor lock-in — code and design are tied to one provider's services.
- Debugging and testing locally can be harder.
- Cost at constant high load can exceed containers or VMs.
DevOps angle: you still need CI/CD (SAM, Serverless Framework, Terraform, CDK), monitoring (CloudWatch, X-Ray), IAM least privilege for each function, and versioning with aliases for safe rollouts (Lambda supports weighted aliases for canary releases).
Example: when a user uploads a profile picture to S3, a Lambda function creates a thumbnail and saves it — with no servers running when nobody is uploading.
Tip for interviews: give a balanced answer: great for event-driven and spiky workloads, not ideal for long-running or constantly busy services.