AWS Lambda and Serverless Interview Questions and Answers (50 Questions on Lambda, API Gateway, SQS, SNS, EventBridge, Step Functions)
This page has 50 new serverless interview questions with full answers. Serverless questions are very common for developer, cloud and DevOps roles, because many new systems are built with Lambda, API Gateway, queues and events.
1. An everyday example: a restaurant kitchen
Serverless looks simple, but real problems come from retries, duplicates, limits and timeouts. Interviewers check if you understand these hidden parts, not only "Lambda runs code without servers".
Think of a busy restaurant. API Gateway is the waiter who takes orders at the door. Lambda functions are cooks who appear only when an order comes. SQS is the order spike where tickets wait in line so cooks are not overloaded. SNS is the loudspeaker that tells every counter at once. EventBridge is the manager who reads every event and sends it to the right team. Step Functions is the recipe card that says which step comes next and what to do if a step fails.
How to use this page
- For every answer, think about what happens when the call fails and is retried.
- Remember the key Lambda limits: up to 30 minutes for on-demand Event Functions, up to 10,240 MB memory, and 6 MB each for a synchronous request and buffered response. Streaming responses have a separate limit.
- Practise with the AWS Free Tier and delete test resources after labs.
2. Fresher level questions
Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.
Q1. What does "serverless" really mean? Fresher
Serverless does not mean there are no servers. It means you do not manage them.
AWS handles provisioning, patching, scaling and availability. You write code or configuration and pay mainly for what you use.
Everyday example: taking a taxi instead of owning a car. You still use a car, but you do not service it or pay for parking.
Examples of serverless services: Lambda, API Gateway, DynamoDB, S3, SQS, SNS, EventBridge, Step Functions and Fargate.
Q2. What are the main limits of a Lambda function that every developer should know? Fresher
Key limits from current AWS documentation:
- Timeout: up to 1,800 seconds (30 minutes) for on-demand Lambda Event Functions. Eligible async and event source mapping invocations on Lambda Managed Instances support up to 90 minutes.
- Memory: 128 MB to 10,240 MB. CPU grows with memory.
- Invocation payload: 6 MB each for a synchronous request and buffered response, up to 200 MB for a synchronous streamed response, and 1 MB for asynchronous invocations. An integration can set lower limits.
- Deployment package: 50 MB zipped upload, 250 MB unzipped including layers. Container images up to 10 GB.
- /tmp storage: 512 MB to 10,240 MB.
- Environment variables: 4 KB in total.
If a job needs more, use Step Functions, ECS, Fargate or batch services.
Q3. How is Lambda priced? Fresher
You pay for two things:
- Requests: the number of invocations.
- Duration: the time your code runs, measured in milliseconds, multiplied by the memory you configured (GB-seconds).
There are extra charges for options such as provisioned concurrency, larger ephemeral storage, and data transfer.
Lambda has a free tier for requests and compute each month. Remember that more memory also gives more CPU, so a function can finish faster and sometimes costs less.
Q4. What is the difference between synchronous and asynchronous Lambda invocation? Fresher
Synchronous: the caller waits for the result. Examples: API Gateway, ALB, or aws lambda invoke with the default type. If the function fails, the caller gets the error and decides whether to retry.
Asynchronous: the caller hands the event to Lambda and moves on. Examples: S3 notifications, SNS, EventBridge. Lambda puts the event in an internal queue and retries on errors.
Polling (event source mapping): Lambda reads from SQS, Kinesis or DynamoDB Streams and invokes the function with batches.
Q5. Which permissions does a Lambda execution role need at minimum, and how is it different from the function's resource policy? Fresher
It is the IAM role that the function assumes when it runs. Its permissions decide what the code can do in AWS.
Every function needs at least permission to write logs to CloudWatch Logs, for example through the AWSLambdaBasicExecutionRole managed policy.
Add only what the code needs, such as dynamodb:PutItem on one table. Do not confuse it with the resource-based policy, which decides who may invoke the function.
Q6. What is a Lambda layer? Fresher
A layer is a .zip archive with shared code or libraries, such as a common logging library or a Python package.
Many functions can use the same layer, so you do not copy the same files into every deployment package.
A function can use up to 5 layers. The total unzipped size of the function and all layers must stay within 250 MB.
For container image functions, you add dependencies into the image instead of using layers.
Q7. Which jobs does Amazon API Gateway take off your backend code? Fresher
API Gateway is a managed service to create, publish and secure APIs at any scale.
It receives HTTP or WebSocket requests and forwards them to backends such as Lambda, HTTP endpoints or AWS services.
It handles authentication, throttling, request validation, CORS, custom domains, stages and monitoring.
There are three types: REST APIs (feature-rich), HTTP APIs (simpler, lower cost, lower latency) and WebSocket APIs (two-way real-time communication).
Q8. What is Amazon SQS? Fresher
SQS (Simple Queue Service) is a managed message queue.
A producer sends messages to the queue. A consumer polls the queue, processes messages and deletes them.
Why it helps: if the consumer is slow or down, messages wait safely in the queue instead of getting lost. This is called decoupling.
Two types: Standard queues (nearly unlimited throughput, at-least-once delivery, best-effort ordering) and FIFO queues (ordered within a message group, with deduplication).
Q9. What is Amazon SNS? Fresher
SNS (Simple Notification Service) is a publish/subscribe service.
A publisher sends one message to a topic, and SNS pushes a copy to every subscriber. Subscribers can be SQS queues, Lambda functions, HTTP endpoints, email, SMS or mobile push.
Everyday example: a WhatsApp group announcement. One message, many receivers.
SNS does not store messages for later reading like SQS does. If a subscriber must not miss messages, subscribe an SQS queue to the topic.
Q10. What is Amazon EventBridge? Fresher
EventBridge is a serverless event bus.
AWS services, your apps and SaaS partners send events to a bus. Rules match events by their content and send them to targets such as Lambda, SQS, Step Functions or another bus.
Example: when an EC2 instance changes to the stopped state, a rule sends the event to a Lambda function that posts a message to the team.
EventBridge Scheduler can also run tasks on a schedule or at a one-time date and time.
Q11. What is AWS Step Functions? Fresher
Step Functions is a workflow service. You describe steps in a state machine using JSON (Amazon States Language) or the visual designer.
It calls services such as Lambda, DynamoDB, SQS and ECS in order, in parallel or in loops. It handles waits, retries, error catching and branching.
Everyday example: a loan application checklist. Verify documents, check credit, then approve or reject, and notify the customer.
It keeps the state of each run, so you can see exactly which step failed.
Q12. When exactly does a Lambda cold start happen, and which requests feel it? Fresher
A cold start happens when Lambda must create a new execution environment before running your code.
It downloads the code, starts the runtime, and runs your initialisation code outside the handler. This adds extra time to that request.
Later requests that reuse the warm environment skip this step.
Cold starts happen on the first request, after scaling up, and after an environment has been idle for a while. They matter most for latency-sensitive APIs.
Q13. What is a dead-letter queue? Fresher
A dead-letter queue (DLQ) is a separate SQS queue (or SNS topic for some sources) where failed messages go after too many failed attempts.
For an SQS source queue, you set a redrive policy with maxReceiveCount, for example 5. After 5 failed receives, SQS moves the message to the DLQ.
Why: one bad message should not block or keep retrying forever. Engineers can inspect the DLQ, fix the bug, and redrive the messages back to the source queue.
Q14. How do you invoke a Lambda function from the CLI and read the result? Fresher
Use aws lambda invoke. The response body is saved to a file.
aws lambda invoke --function-name order-validator --cli-binary-format raw-in-base64-out --payload '{"orderId":"o-5001","amount":499}' out.json && cat out.jsonOutput:
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
{"valid":true,"orderId":"o-5001"}StatusCode 200 means Lambda ran the function. The second line is what the function returned. If the code failed, you would also see a "FunctionError" field, so always check it.
Q15. When is an SQS FIFO queue worth its lower throughput compared with a standard queue? Fresher
Standard queues:
- Nearly unlimited throughput.
- At-least-once delivery: a message can arrive more than once.
- Best-effort ordering: order is not guaranteed.
FIFO queues:
- Strict order within each message group ID.
- Deduplication within a 5-minute window, using a deduplication ID or content-based deduplication.
- Lower throughput limits, which you can raise with batching and high throughput mode.
Use FIFO only when order or no-duplicates is truly needed, such as bank transactions for one account.
Q16. What are Amazon Cognito user pools and identity pools? Fresher
A user pool is a user directory. It handles sign-up, sign-in, MFA and password reset, and gives your app JWT tokens. API Gateway can check these tokens.
An identity pool gives users temporary AWS credentials, so a mobile or web app can call AWS services such as S3 directly with limited permissions.
Often both are used together: sign in with the user pool, then exchange the token for AWS credentials in the identity pool.
Q17. How should you size the SQS visibility timeout, and what goes wrong if it is too short? Fresher
When a consumer receives a message, SQS hides it from other consumers for the visibility timeout. The default is 30 seconds, and the maximum is 12 hours.
If the consumer deletes the message in time, it is gone. If not, the message becomes visible again and another consumer can process it.
Set the timeout longer than the processing time. For Lambda with SQS, AWS recommends at least six times the function timeout.
3. Mid level questions
These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.
Q18. How does Lambda handle errors for asynchronous invocations? Mid level
Lambda puts async events in an internal queue. If the function returns an error, Lambda retries it two more times by default, with waits between attempts.
You can set the retry attempts from 0 to 2 and the maximum event age up to 6 hours.
After the final failure, Lambda can send the event to an on-failure destination (SQS, SNS, Lambda, EventBridge or S3) or to a dead-letter queue.
Destinations are preferred because they include details of the error and the request.
Q19. How do reserved concurrency and provisioned concurrency solve different Lambda problems? Mid level
Reserved concurrency sets aside a part of the account's concurrency for one function and also caps it at that number. It has no extra charge. Use it to protect critical functions or to protect a database from too many connections.
Provisioned concurrency keeps a number of execution environments initialised and ready, so requests avoid cold starts. It has an extra charge.
You can use both together, and you can schedule provisioned concurrency with Application Auto Scaling for busy hours.
Q20. How does Lambda scale, and what limits it? Mid level
Each concurrent request needs its own execution environment. Concurrency = requests per second × average duration in seconds. Example: 200 requests per second × 0.5 seconds = 100 concurrent executions.
Limits:
- The account's Regional concurrency quota, 1,000 by default for most accounts, which you can raise.
- The scaling rate: each function can add up to 1,000 execution environments every 10 seconds.
- Reserved concurrency set on a function.
When limits are hit, synchronous calls get throttled with 429 errors, and async events are retried.
Q21. How do you reduce Lambda cold start time? Mid level
Options:
- Keep the package small and load only the libraries you need.
- Initialise SDK clients and database connections outside the handler, so warm calls reuse them.
- Choose a runtime with fast start, or optimise heavy frameworks.
- Use Lambda SnapStart for supported runtimes such as Java, Python and .NET. It restores from a snapshot of an initialised environment.
- Use provisioned concurrency for strict latency needs.
- Increase memory, which also gives more CPU for initialisation.
Measure with the Init Duration value in the REPORT log line.
Q22. How does Lambda process messages from SQS, and what is a partial batch response? Mid level
Lambda polls the queue and invokes the function with a batch of messages. If the function succeeds, Lambda deletes the whole batch.
If the function throws an error, the whole batch becomes visible again and every message is retried, even those that succeeded.
With ReportBatchItemFailures turned on, the function returns the IDs of only the failed messages:
{"batchItemFailures":[{"itemIdentifier":"3f1c2a9e-1111-4c3b-9b1d-2a3b4c5d6e7f"}]}Lambda deletes all other messages and retries only that one. This avoids reprocessing good messages.
Q23. Why must serverless consumers be idempotent, and how do you build that? Mid level
An operation is idempotent if running it many times gives the same result as running it once.
In serverless, events can be delivered more than once: SQS standard is at-least-once, async Lambda retries, and clients retry on timeouts.
Example: a payment function receives the same event twice. Without idempotency, the customer is charged twice.
How: use a unique ID from the event (such as orderId), store it in DynamoDB with a conditional write, and skip work if it already exists. Powertools for AWS Lambda has an idempotency utility.
Q24. Which features would make you pick an API Gateway REST API over a cheaper HTTP API? Mid level
HTTP APIs are simpler, faster and cheaper. They support Lambda and HTTP integrations, JWT authorizers, Lambda authorizers, IAM auth and CORS.
REST APIs have more features: API keys and usage plans, request validation, request and response transformations, caching, AWS WAF integration, private APIs and more integration options.
Choose HTTP APIs for most simple Lambda backends, and REST APIs when you need those extra features.
Q25. What types of authorizers can API Gateway use? Mid level
Options:
- IAM authorization: callers sign requests with AWS credentials (SigV4). Good for service-to-service calls.
- Amazon Cognito user pool authorizer (REST APIs) or JWT authorizer (HTTP APIs): checks tokens from Cognito or another OIDC provider.
- Lambda authorizer: your own function checks a token or headers and returns an allow or deny policy. Results can be cached.
API keys are not a security mechanism. They are for identifying clients in usage plans and throttling.
Q26. What are API Gateway throttling limits? Mid level
API Gateway has an account-level default throttle per Region, which is 10,000 requests per second with a burst of 5,000 by default, and you can request more.
You can also set limits per stage, per method, and per client through usage plans.
When limits are exceeded, clients get 429 Too Many Requests. Clients should retry with exponential backoff.
Remember to compare this with Lambda concurrency. API Gateway may accept more requests than your functions can run at the same time.
Q27. How do you implement fan-out with SNS and SQS? Mid level
Publish one message to an SNS topic, and subscribe several SQS queues to it. Each queue gets its own copy, and each consumer works at its own speed.
Example: an "order placed" event goes to the payment queue, the email queue and the analytics queue.
Use SNS subscription filter policies so each queue receives only relevant messages, for example only orders with country = IN.
Give the SNS topic permission to send to each queue in the queue policy, and add a DLQ for each queue.
Q28. How do you decide between SNS and EventBridge for publishing events? Mid level
SNS is best for high-throughput pub/sub fan-out to many subscribers, including SMS, email and mobile push. Filtering is by message attributes or message body.
EventBridge is best for event routing across services and accounts. It has rich content-based matching, many AWS service events built in, SaaS integrations, schema registry, and archive and replay.
Simple rule: many subscribers for the same message → SNS. Route different events to different targets based on content → EventBridge.
Q29. What is the difference between Step Functions Standard and Express workflows? Mid level
Standard workflows:
- Can run up to one year.
- Exactly-once workflow execution.
- Full execution history in the console.
- Priced per state transition.
Express workflows:
- Run up to five minutes.
- Very high event rates.
- Priced by number of executions, duration and memory.
- At-least-once (asynchronous) or at-most-once (synchronous) execution.
Use Standard for long business processes and Express for high-volume, short event processing.
Q30. How do Retry and Catch work in Step Functions? Mid level
Retry tells a state to try again on certain errors. You set ErrorEquals, IntervalSeconds, MaxAttempts and BackoffRate.
Example: retry Lambda.TooManyRequestsException up to 3 times, starting with 2 seconds and doubling each time.
Catch sends the workflow to a fallback state when retries are used up, for example a "NotifyFailure" state that sends an SNS message and marks the order as failed.
This removes most error-handling code from your functions.
Q31. What is the "wait for task token" pattern in Step Functions? Mid level
It lets a workflow pause until an outside system or a person replies.
Step Functions passes a unique task token to a task, such as a message in SQS or an email for manager approval. The workflow waits.
When the work is done, the system calls SendTaskSuccess or SendTaskFailure with that token, and the workflow continues.
Use a heartbeat or timeout so the workflow does not wait forever.
Q32. How do you pass secrets to a Lambda function safely? Mid level
Do not hard-code secrets or keep them in plain environment variables in code repos.
- Store them in Secrets Manager or Parameter Store SecureString.
- Give the execution role permission to read only that secret.
- Read the secret at start, cache it in memory, and refresh it from time to time. The AWS Parameters and Secrets Lambda Extension can cache it for you.
- If you use environment variables, they are encrypted at rest with KMS, but anyone with permission to view the function config may see them.
Q33. How do you connect Lambda to resources in a private VPC? Mid level
Configure the function with VPC subnets and a security group. Lambda creates Hyperplane elastic network interfaces in those subnets.
Then the function can reach RDS, ElastiCache or internal services by private IP.
Important: a function in a VPC does not get internet access by default. To call the internet, route the private subnets through a NAT gateway. To call AWS services, use VPC endpoints instead.
Use private subnets in at least two AZs.
Q34. What are EventBridge archive and replay used for? Mid level
An archive stores events sent to an event bus, either all events or those matching a pattern, for a retention period you choose.
Replay sends archived events from a time window back to the bus, so rules process them again.
Uses: recover after a bug in a consumer, test a new consumer with real past events, or rebuild data.
Make consumers idempotent, because replayed events are processed again.
Q49. What is EventBridge Pipes and when do you use it? Mid level
EventBridge Pipes connects one source to one target, with optional filtering, enrichment and transformation in between.
Sources include SQS, Kinesis, DynamoDB Streams, Amazon MQ and Amazon MSK. Targets include Step Functions, Lambda, API destinations, EventBridge buses and more.
Example: read new items from a DynamoDB stream, filter only status = PAID, enrich with customer details from a Lambda function, and start a Step Functions workflow.
It removes "glue" Lambda functions that only move data from one service to another.
4. Senior level and scenario questions
These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.
Q35. An SQS queue's backlog keeps growing even though Lambda is processing messages. How do you troubleshoot? Senior
Check the metrics first: ApproximateNumberOfMessagesVisible, ApproximateAgeOfOldestMessage, Lambda Errors, Throttles, Duration and ConcurrentExecutions.
Common causes:
- The function fails and messages return to the queue. Check logs and the DLQ.
- Concurrency is capped by reserved concurrency or the account limit, or by maximum concurrency on the event source mapping.
- Processing is slow because of a slow database or API.
- The visibility timeout is too short, so messages are processed twice.
Fixes: fix errors, raise concurrency carefully, tune batch size and batching window, and protect downstream systems.
Q36. Users report duplicate orders from your serverless checkout. How do you find and fix the cause? Senior
Find where the duplicate comes from:
- Client retries after a timeout: the first request succeeded but the response was lost.
- API Gateway or Lambda timeouts that are shorter than the real work.
- SQS standard at-least-once delivery, or a visibility timeout shorter than processing time.
- Async Lambda retries after an error that happened after the order was saved.
Fix it with idempotency: the client sends an idempotency key, and the order function does a conditional write in DynamoDB so the same key cannot create two orders. Return the original result on repeats.
Q37. Your API Gateway with Lambda returns 504 errors under load. What do you check? Senior
504 from API Gateway usually means the integration timed out.
- REST APIs have a default integration timeout of 29 seconds, and HTTP APIs allow up to 30 seconds.
- Check Lambda Duration. Is the function close to the limit because a database or third-party API is slow?
- Check Lambda throttles and concurrency.
- Check cold starts if the function is in a VPC or uses heavy frameworks.
Fixes: optimise the slow call, add caching, return quickly and process the rest asynchronously with SQS or Step Functions, and give clients a status endpoint to poll.
Q38. How would you design a serverless image-processing pipeline that handles 1 million uploads a day? Senior
A simple, scalable design:
- Clients get a presigned URL from API Gateway and Lambda, then upload directly to an S3 uploads bucket.
- S3 sends an event to an SQS queue, not straight to Lambda, so bursts are buffered.
- A Lambda function reads batches from the queue, creates thumbnails, and saves them to an output bucket.
- Metadata is written to DynamoDB with the object key as an idempotency key.
- Failed messages go to a DLQ with an alarm.
- CloudFront serves the images.
Explain how you would cap concurrency and estimate cost per million images.
Q39. When would you choose orchestration with Step Functions over choreography with events? Senior
Orchestration: one central workflow tells each service what to do and in which order. It gives clear visibility, easy retries, timeouts and compensation steps. It is good for business processes like order checkout or loan approval.
Choreography: services react to events independently through EventBridge or SNS. It gives loose coupling and easy addition of new consumers, but it is harder to see the end-to-end flow.
Many systems mix both: Step Functions inside one domain, and events between domains.
Q40. How do you implement the saga pattern in a serverless system? Senior
A saga breaks a business transaction across services into steps, each with a compensating action.
Example: book a trip. Reserve the flight, reserve the hotel, charge the card. If the card charge fails, cancel the hotel and then cancel the flight.
With Step Functions: each step is a task, each has a Catch that moves to compensation states in reverse order, and each action is idempotent.
This gives eventual consistency without a distributed database transaction.
Q41. A Lambda function that calls a third-party API is overwhelming that API. How do you control the rate? Senior
Put a buffer and a limit in between.
- Send work to an SQS queue instead of calling the API directly.
- Set maximum concurrency on the SQS event source mapping, or reserved concurrency on the function, to cap parallel calls.
- Use retries with exponential backoff and jitter when the API returns 429.
- Use a circuit breaker to stop calling when the API is down.
- For strict rates, use EventBridge Scheduler or a token-bucket stored in DynamoDB or ElastiCache.
Monitor queue age to make sure the backlog clears in time.
Q42. How do you deploy Lambda changes safely to production? Senior
Use versions, aliases and gradual traffic shifting.
- Publish a new version of the function.
- The alias "live" points to the old version.
- Use CodeDeploy (for example through AWS SAM) to shift traffic, such as 10 percent for 5 minutes, then 100 percent.
- Add CloudWatch alarms on errors and latency. If an alarm fires, CodeDeploy rolls back automatically.
- Use pre-traffic and post-traffic hook functions for smoke tests.
API Gateway and event sources should call the alias, not $LATEST.
Q43. How do you monitor and trace a serverless application end to end? Senior
Use the three pillars:
- Logs: structured JSON logs with a correlation ID, in CloudWatch Logs. Use Logs Insights to query.
- Metrics: Lambda Errors, Throttles, Duration, ConcurrentExecutions, IteratorAge for streams; SQS queue age; API Gateway 4XX, 5XX and latency. Use embedded metric format for business metrics.
- Traces: AWS X-Ray or OpenTelemetry to see each request across API Gateway, Lambda, DynamoDB and SQS.
Add alarms on symptoms users feel, such as error rate and p99 latency, and build a dashboard per service.
Q44. Your Lambda function processing a Kinesis or DynamoDB stream is stuck on one bad record. What do you do? Senior
For stream sources, a failing batch blocks that shard, because records must be processed in order. IteratorAge keeps rising.
Fix:
- Turn on BisectBatchOnFunctionError to split the batch and isolate the bad record.
- Set MaximumRetryAttempts and MaximumRecordAgeInSeconds so the bad record is eventually skipped.
- Configure an on-failure destination to save details of skipped records.
- Use ReportBatchItemFailures to checkpoint up to the failed record.
Then fix the bug and reprocess the saved records.
Q45. How would you control costs of a high-traffic serverless API? Senior
Look at each layer.
- API Gateway: HTTP APIs cost less than REST APIs. Use caching or CloudFront for repeated GETs.
- Lambda: right-size memory with a power-tuning test, use Graviton (arm64), cut duration by reusing connections, and avoid waiting on slow calls inside Lambda.
- Logs: set retention periods and avoid very verbose logs in production.
- DynamoDB: right capacity mode and efficient keys.
- At very high steady load, compare with containers on Fargate or EC2.
Track cost per request with tags and Cost Explorer.
Q46. How do you handle a sudden spike of 50,000 requests per second on a serverless API? Senior
Prepare before the spike.
- Check quotas: Lambda concurrency, API Gateway throttles, DynamoDB capacity. Raise them early.
- Use provisioned concurrency for predictable spikes.
- Cache responses at CloudFront or API Gateway.
- Move non-urgent work to SQS so the API responds fast.
- Use DynamoDB on-demand or pre-warm capacity, and check for hot keys.
- Load test with realistic traffic.
During the spike, watch throttles and errors, and have a plan to shed load gracefully, for example a friendly "try again" response.
Q47. What are the risks of putting a large monolith into one big Lambda function? Senior
This "Lambda monolith" works for small apps, but it has risks:
- Large packages and slow cold starts.
- One execution role with permissions for everything, which breaks least privilege.
- One memory and timeout setting for all routes.
- Hard to see which feature causes errors or cost.
- Every change redeploys everything.
A balanced approach is to split by domain or by route group, with shared code in layers or libraries. Use the strangler fig pattern to move features out gradually.
Q48. How do you secure a public serverless API? Senior
Use defence in depth.
- Authentication with Cognito or another OIDC provider, and authorization checks inside the function for each resource.
- AWS WAF on API Gateway or CloudFront, with managed rules and rate-based rules.
- Throttling and usage plans per client.
- Request validation for body and parameters.
- Least-privilege execution roles, one per function.
- Secrets in Secrets Manager.
- Logging with CloudTrail and access logs, and alerts on unusual 4XX or 5XX spikes.
Also validate input carefully to avoid injection attacks in downstream calls.
Q50. How would you move a nightly cron job from an EC2 server to serverless? Senior
Step by step:
- Understand the job: how long it runs, what it touches, and what happens if it runs twice.
- Consider an on-demand Lambda Event Function if the measured job fits comfortably inside its 30-minute timeout and the rest of its resource requirements. If the work is too long or needs different resources, evaluate a Step Functions Map to split it or a container task on Fargate.
- Schedule it with EventBridge Scheduler, with the right time zone, such as Asia/Kolkata.
- Make it idempotent and add a lock record in DynamoDB if two runs must not overlap.
- Add alarms on failures and on "job did not run".
- Run old and new in parallel for a few days, compare results, then switch off the EC2 cron.
5. Frequently asked questions
Is serverless always cheaper?
No. It is usually cheaper for spiky or low traffic. For steady very high traffic, containers or EC2 can cost less. Always estimate with the AWS Pricing Calculator.
Which serverless topic is asked most to experienced candidates?
Retries and idempotency, concurrency limits, SQS with Lambda, and how to debug a failed event flow.
Do I need to know Step Functions for a fresher interview?
Know what it is and when to use it. Detailed questions on states and error handling are usually for mid and senior roles.
6. Quick revision
- Lambda Event Functions on demand: up to 30 minutes, 128 to 10,240 MB memory, 6 MB each for synchronous request and buffered response, up to 200 MB for a synchronous streamed response, and 1 MB for asynchronous requests.
- Asynchronous invocations are retried by Lambda. Use destinations or a DLQ to catch failures.
- SQS standard is at-least-once. Make consumers idempotent.
- Set the SQS visibility timeout longer than the function timeout.
- Step Functions Standard runs up to one year. Express runs up to five minutes.
7. Related chapters
- What Is AWS Lambda? Serverless Explained with Examples
- Lambda Cold Starts, Concurrency, Provisioned Concurrency and SnapStart
- AWS Lambda Triggers: S3, EventBridge, SQS and SNS Explained
- What Is Amazon API Gateway? REST vs HTTP vs WebSocket
- Amazon SQS and SNS: Messaging Queues and Pub/Sub Explained
- What Is Amazon EventBridge? Event Bus, Rules and Schedules Explained
- What Is AWS Step Functions? Orchestrate Lambda Workflows Explained
- Queue-Based Load Leveling, DLQ, Retries and Idempotency on Serverless
This page is one part of a 500-question AWS interview set. Open the full list here: All 500 AWS interview questions.