AWS Lambda interview questions and answers for serverless engineers
AWS Lambda interview questions test how well you understand what happens around your handler: the execution environment and cold starts, synchronous, asynchronous and poll-based invocation, concurrency limits, the execution role, and how retries interact with SQS and streams. Senior rounds ask you to design an event-driven flow that survives duplicates, poison messages and throttling. Good answers mention idempotency early and treat Lambda as one part of a system, not a place to put everything.
By Evin JohnPublished 5 min read
How Lambda is tested in interviews
Lambda questions turn up in backend, cloud engineer, serverless developer and solutions architect interviews, either as part of a wider AWS round or as a design exercise built around events. Account structure, networking basics and other services are covered on AWS interview questions. Here the subject is the function itself and the systems around it.
- Runtime questionsWhat happens on a cold start, what survives between invocations, what the handler receives.
- Integration questionsHow a function is triggered by an API, a queue, a stream or a schedule, and what happens on failure in each case.
- Code reviewA handler on screen with a database connection opened inside it, or an SQS batch that fails as a whole.
- DesignAn order pipeline, an image thumbnailer or a webhook receiver, with retries, duplicates and limits in mind.
Lambda fundamentals questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is AWS Lambda and when is it a good fit? | Use cases | Run code in response to events without managing servers, billed by invocations and duration. A good fit for spiky or event-driven work; a poor fit for long-running jobs, steady high load or workloads that need a persistent connection. |
| What does a handler receive? | Handler | An event, whose shape depends on the source (an API request, an SQS batch, an S3 notification), and a context object with the request ID, remaining time and function details. |
| What happens during a cold start? | Init phase | Lambda creates an execution environment, downloads the code, starts the runtime and runs the init code outside the handler. Later invocations on that environment skip all of that. |
| What survives between invocations? | Warm reuse | Anything created outside the handler: SDK clients, configuration, a connection pool and files in the temporary directory. Nothing is guaranteed, because environments are recycled at any time. |
| What is the maximum run time of a function? | Limits | Fifteen minutes. Work that may take longer belongs in Step Functions, a container service or a batch job. Other quotas, such as memory and payload size, are worth checking on the current quotas page. |
| How do memory and CPU relate? | Sizing | You choose memory, and CPU and network share scale with it. A CPU-bound function can get faster and sometimes cheaper per request with more memory. |
| Execution role versus resource-based policy? | IAM | The execution role says what the function may call, such as reading a table. The resource-based policy says who may invoke the function, such as API Gateway or another account. |
| How do you configure a function per environment? | Configuration | Environment variables for non-secret settings, and Secrets Manager or Parameter Store for secrets, read at init and cached, rather than pasted into variables in plain text. |
| What are layers? | Packaging | Archives of shared libraries or runtimes attached to functions. Useful for common dependencies, but they hide versions from the function's own package, so many teams prefer bundling. |
| What are versions and aliases? | Releases | A published version is an immutable snapshot of code and settings. An alias such as live points to a version and can split traffic between two versions for a gradual rollout. |
Invocation and event source questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| Synchronous versus asynchronous invocation? | Invocation types | Synchronous callers wait for the result and handle errors themselves, as API Gateway does. Asynchronous events are queued by Lambda, retried on error and then sent to an on-failure destination or dead-letter queue if configured. |
| What is an event source mapping? | Polling | For SQS, Kinesis, DynamoDB Streams and Kafka, Lambda polls the source and invokes the function with batches. Batch size, batching window and error handling live on the mapping. |
| An SQS batch has one bad message. What happens by default? | Batch failures | The whole batch returns to the queue and is retried, including the messages that succeeded. Enable partial batch responses and return only the failed message IDs. |
| How should the queue's visibility timeout relate to the function timeout? | SQS tuning | It must be comfortably longer than the function timeout, or messages reappear while still being processed. AWS guidance suggests a generous multiple; check the current recommendation. |
| How do you stop a poison message looping forever? | Dead letters | A redrive policy on the source queue with a maximum receive count, sending repeat failures to a dead-letter queue that someone monitors. |
| Why can one bad record stall a Kinesis or DynamoDB stream? | Ordered streams | Records are processed in order per shard, so a failing batch is retried until it succeeds or expires. Bisecting batches on error, a maximum retry count and an on-failure destination keep the shard moving. |
| Why must handlers be idempotent? | Delivery semantics | Most sources deliver at least once and retries are normal, so the same event can arrive twice. Use a natural key or an idempotency record, for example a conditional write keyed on the order ID. |
| A function triggered by S3 uploads writes its output to the same bucket. What goes wrong? | Recursion | Each output triggers the function again, a loop that can run up a large bill. Write to another bucket or prefix and filter the trigger on the input prefix. |
| How do you run a function on a schedule? | Scheduling | An EventBridge schedule or rule with a cron or rate expression. Keep the job idempotent in case it runs twice or late. |
| When would you use Step Functions instead of chaining functions? | Orchestration | When a flow has several steps, waits, branches or retries. Functions calling functions directly pay for idle waiting and hide the flow; a state machine makes it visible and retries each step on its own terms. |
// index.mjs
export const handler = async (event) => {
const batchItemFailures = [];
for (const record of event.Records) {
try {
const order = JSON.parse(record.body);
await saveOrder(order);
} catch (err) {
console.error(JSON.stringify({ messageId: record.messageId, error: err.message }));
batchItemFailures.push({ itemIdentifier: record.messageId });
}
}
return { batchItemFailures };
};
async function saveOrder(order) {
if (!order.id) throw new Error("order has no id");
// In real code: a conditional write keyed on order.id, so a retried
// message cannot create a second order.
}import json
import os
# Init phase: runs on a cold start only. SDK clients created here are
# reused by warm invocations of the same environment.
TABLE_NAME = os.environ.get("TABLE_NAME", "orders")
def handler(event, context):
order_id = (event.get("pathParameters") or {}).get("id")
if not order_id:
return {"statusCode": 400, "body": json.dumps({"error": "missing id"})}
return {
"statusCode": 200,
"headers": {"content-type": "application/json"},
"body": json.dumps({"id": order_id, "table": TABLE_NAME}),
}Concurrency, performance and senior questions
| Question or scenario | What it tests | What a strong answer shows |
|---|---|---|
| Reserved versus provisioned concurrency? | Concurrency | Reserved concurrency caps a function and sets aside that capacity from the account's regional pool. Provisioned concurrency keeps a number of environments initialized ahead of time to remove cold starts, at extra cost. |
| A function overwhelms the database during a traffic spike. | Back pressure | Cap the function with reserved concurrency, put a queue in front so work waits instead of failing, and use a connection proxy or a pooled data API so each environment does not open its own connections. |
| Cold starts hurt p99 latency on a Java API. | Cold start tuning | Measure init duration first. Then trim dependencies, initialize lazily, consider snapshot-based start features where the runtime supports them, or provisioned concurrency for the hot path. |
| Another team's function is throttling yours. | Shared limits | Concurrency is shared per account and region. Reserve capacity for critical functions, ask for a quota increase if justified, and separate noisy workloads into their own accounts. |
| Does putting a function in a VPC slow it down or cut it off? | Networking | Modern VPC networking removed most of the old cold start penalty, but a function in private subnets has no internet route. It needs a NAT gateway or VPC endpoints to reach AWS services. |
| How do you deploy a new version safely? | Releases | Publish a version and shift a small share of the alias's traffic to it, watch errors and latency, then move the rest or roll back. Deployment tools can automate this with alarms. |
| How do you debug a function that fails only in production? | Observability | Structured logs with the request ID, metrics for errors, throttles, duration and iterator age, tracing across services, and a reproducible event saved from the failure for a local run. |
| A webhook provider expects a reply within seconds, but processing takes minutes. | Async design | Accept the webhook in a thin function that validates the signature, stores or queues the payload and returns quickly. A second function processes the queue with retries and a dead-letter queue. |
| How would you secure a public function URL or API? | Security | Authentication at the edge (IAM, a JWT authorizer or a custom authorizer), input validation, least-privilege execution role, throttling at the API layer and no secrets in environment variables in plain text. |
| When would you not choose Lambda? | Judgment | Long-running or steady high-throughput workloads, tight latency budgets that cold starts break, heavy local state, or software that expects a long-lived server. Containers on a managed service may suit those better. |
Fictional example
- Interviewer
- Users upload photos to S3. We want three thumbnail sizes, and we have had problems with duplicate work and runaway costs before. Walk me through it.
- Candidate
- Uploads land under an
uploads/prefix, and the bucket notification only fires for that prefix, so thumbnails written to a separate output bucket can never trigger the function again. I would send the S3 event to an SQS queue rather than straight to the function. That gives me a buffer, batch control and a dead-letter queue for images that fail repeatedly, such as corrupt files. The function uses partial batch responses, so one bad image does not retry the others. Each thumbnail's key is derived from the source object's key and version, so processing the same event twice just overwrites identical files. I would cap concurrency so a bulk import cannot starve other functions, size memory by testing a few real images, and alarm on dead-letter queue depth and errors. If processing ever outgrew the time limit, I would move that step to a container task and keep the queue design.
A one-week AWS Lambda practice plan
- Day 1: write a handler in your language, run it locally with a saved test event, then deploy it and read the init duration in the logs.
- Day 2: move client creation outside the handler and compare cold and warm durations. Write down what you think survives between calls.
- Day 3: connect an SQS queue, break one message on purpose and watch the whole batch retry. Then enable partial batch responses and repeat.
- Day 4: add a dead-letter queue, a version and an alias, and shift a small share of traffic to a new version.
- Day 5: sketch two designs out loud: a webhook receiver and a stream consumer that must keep order.
- Days 6 and 7: answer the senior table in two minutes each, starting every answer with the failure mode you are protecting against.
Serverless roles still deploy infrastructure. CloudFormation interview questions covers templates that define functions and their permissions, Terraform interview questions covers the common alternative, and backend developer interview questions covers the rest of a typical loop.
Design answers about Lambda are judged on the failure cases you raise without being asked. Natively, an AI interview assistant for Mac and Windows, transcribes your mock design rounds on your computer, so you can count how often you mentioned retries, duplicates and limits. In practice sessions it can read a handler or an error trace from a screenshot and explain what might be wrong, and with Pro or the free trial it can use the résumé and job description you supply. Each session's transcript and notes stay for later review.
Questions people ask
What AWS Lambda questions are asked in interviews?
Cold starts and the execution environment, synchronous versus asynchronous invocation, event source mappings for SQS and streams, retries and dead-letter queues, reserved and provisioned concurrency, IAM roles, VPC access, versions and aliases, and idempotent design.
What is a cold start in AWS Lambda?
The delay when Lambda creates a new execution environment: downloading code, starting the runtime and running init code outside the handler. Warm invocations reuse an existing environment and skip that work.
What is the difference between reserved and provisioned concurrency?
Reserved concurrency caps a function and guarantees it that share of the account's capacity. Provisioned concurrency keeps environments initialized in advance so requests avoid cold starts, at extra cost.
How do I prepare for an AWS Lambda interview?
Deploy a small function, connect it to an SQS queue, break a message on purpose and fix the retry behavior with partial batch responses, then practice designing an event-driven flow that handles duplicates and throttling.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
