0% found this document useful (0 votes)
9 views

AWS Lambda

The document provides a comprehensive overview of AWS Lambda, including its definition, functionality, use cases, and pricing factors. It also discusses key concepts such as invocation types, Lambda Layers, execution environments, and performance optimization strategies. Additionally, it contrasts AWS Lambda with AWS EC2 and highlights important aspects for interview preparation related to AWS Lambda.

Uploaded by

sriiraman1985
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

AWS Lambda

The document provides a comprehensive overview of AWS Lambda, including its definition, functionality, use cases, and pricing factors. It also discusses key concepts such as invocation types, Lambda Layers, execution environments, and performance optimization strategies. Additionally, it contrasts AWS Lambda with AWS EC2 and highlights important aspects for interview preparation related to AWS Lambda.

Uploaded by

sriiraman1985
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Here are some common AWS Lambda interview questions and answers:

1. What is AWS Lambda?

Answer: AWS Lambda is a serverless computing service that allows you to run code in response
to events without provisioning or managing servers. Lambda automatically handles the compute
fleet, scaling your application up or down as needed. It supports multiple programming
languages like Node.js, Python, Java, C#, Go, Ruby, and custom runtimes.

2. How does AWS Lambda work?

Answer: AWS Lambda works by allowing you to upload your code (functions) to AWS. You
then define a trigger (event source) that will invoke your Lambda function. Lambda
automatically scales and executes your function based on the events it receives. When the
function is triggered, AWS Lambda allocates the necessary compute resources, runs your code,
and returns the results.

3. What are some use cases of AWS Lambda?

Answer: AWS Lambda is typically used in scenarios such as:

 Real-time file processing: Process files as soon as they are uploaded to Amazon S3.
 Data transformation: Transform or enrich data from sources like Amazon DynamoDB
or Kinesis streams.
 API backend: Create serverless APIs by integrating Lambda with Amazon API
Gateway.
 Automation: Trigger Lambda functions in response to events like changes in resources
or logs in CloudWatch.
 Microservices architecture: Build small, decoupled services that scale independently.

4. What is the maximum execution timeout for an AWS Lambda function?

Answer: The maximum execution timeout for an AWS Lambda function is 15 minutes (900
seconds). This means that a Lambda function can run for up to 15 minutes before it is
automatically terminated. You can set a shorter timeout for your function based on your use case.

5. What are the pricing factors for AWS Lambda?


Answer: AWS Lambda pricing is based on:

 Requests: The number of requests for your functions. AWS charges $0.20 per 1 million
requests.
 Duration: The time your code runs, measured from the time your code begins executing
until it returns or otherwise terminates. Pricing is based on the amount of memory
allocated to the function and the execution time in 100ms increments.
 Provisioned Concurrency (optional): If you enable provisioned concurrency (which
pre-warms instances of your function), you’ll pay for the number of concurrent
executions you reserve.

6. What is the difference between synchronous and asynchronous invocation in


AWS Lambda?

Answer:

 Synchronous Invocation: When a function is invoked synchronously, the caller waits for
the function to finish execution and return a result. Examples include Lambda functions
triggered by API Gateway or direct invocations via SDKs.
 Asynchronous Invocation: When a function is invoked asynchronously, the caller does
not wait for a result. The function execution is queued, and the caller receives an
immediate acknowledgment. Examples include Lambda functions triggered by events
from S3 or CloudWatch Events.

7. What are Lambda Layers?

Answer: Lambda Layers are a distribution mechanism for libraries, custom runtimes, and other
function dependencies that can be shared across multiple Lambda functions. Layers allow you to
keep your Lambda functions smaller by separating the dependencies and code into a layer, which
can be attached to multiple functions.

8. What is the maximum size of a Lambda deployment package?

Answer: The maximum size of a Lambda deployment package is:

 10 MB for direct uploads via the AWS Management Console.


 50 MB for packages uploaded via AWS CLI or SDKs.
 250 MB for packages stored in Amazon S3 and referenced during the Lambda
deployment.
9. What is the purpose of an IAM role in AWS Lambda?

Answer: An IAM (Identity and Access Management) role is used to define permissions for
AWS Lambda functions to interact with other AWS services. When you create a Lambda
function, you can assign it an IAM role that specifies the resources it can access and the actions
it can perform (e.g., accessing an S3 bucket, reading from DynamoDB, or writing logs to
CloudWatch).

10. What is the Lambda execution environment?

Answer: The Lambda execution environment is a secure, isolated environment where your
Lambda function code runs. It contains:

 The runtime: The environment that supports the programming language (e.g., Node.js,
Python, Java).
 Temporary storage: A small amount of temporary disk space (/tmp) where your
function can store data during execution (up to 512 MB).
 IAM permissions: The IAM role with the necessary permissions to interact with AWS
services.
 System libraries: The system environment needed for function execution, including the
libraries for the selected runtime.

11. What is AWS Lambda’s cold start?

Answer: A cold start occurs when AWS Lambda needs to initialize a new instance of a
function, usually because it has not been invoked in a while or if the function is being invoked
for the first time. During a cold start, Lambda must load the runtime, initialize the function code,
and prepare the execution environment, which can introduce latency. This latency is usually
higher than for a warm start, where the environment is already initialized.

12. How can you improve the performance of Lambda cold starts?

Answer: You can improve Lambda cold start performance by:

 Reducing package size: Minimize the size of your deployment package to reduce
initialization time.
 Using provisioned concurrency: This allows Lambda to keep a specified number of
function instances pre-warmed, reducing cold start latency.
 Optimizing dependencies: Avoid unnecessary dependencies in the deployment package
to speed up the initialization process.
 Choosing appropriate memory allocation: Allocate enough memory for your function
to run efficiently but avoid excessive allocations that may lead to longer start-up times.

13. Can AWS Lambda be used for scheduled tasks?

Answer: Yes, AWS Lambda can be used for scheduled tasks. You can create an Amazon
CloudWatch Events rule to trigger Lambda functions at specified intervals, like running a
Lambda function every hour, every day, or on a custom schedule (using cron expressions). This
is ideal for periodic jobs like backups, data processing, or regular monitoring tasks.

14. How does AWS Lambda integrate with other AWS services?

Answer: AWS Lambda can be integrated with various AWS services to trigger functions based
on events, such as:

 Amazon S3: Trigger Lambda functions when files are uploaded to an S3 bucket.
 Amazon DynamoDB: Trigger Lambda functions when there are changes to a
DynamoDB table (e.g., inserts, updates).
 Amazon SNS/SQS: Trigger Lambda functions when messages are published to an SNS
topic or added to an SQS queue.
 Amazon API Gateway: Expose Lambda functions as RESTful APIs using API Gateway.
 CloudWatch Logs/Events: Invoke Lambda functions based on log entries or event
patterns.

15. What is the maximum memory allocated for a Lambda function?

Answer: AWS Lambda allows you to allocate from 128 MB to 10 GB of memory for a
function. The amount of memory allocated determines the CPU power allocated to the function
as well. More memory can result in faster execution, but it also increases the cost.

16. What is the AWS Lambda execution timeout, and how can it be configured?

Answer: AWS Lambda’s maximum execution timeout is 15 minutes (900 seconds). You can
configure the timeout when you create or update a Lambda function. The timeout setting
determines how long Lambda will wait before terminating the function if it hasn’t completed
execution.
17. What are Lambda Destinations?

Answer: Lambda Destinations allow you to capture the result of asynchronous invocations
(success or failure) of Lambda functions. When a function is invoked asynchronously, you can
define a destination (e.g., an SQS queue, SNS topic, or Lambda function) to send the result of the
invocation. This is useful for tracking and processing the outcome of Lambda executions.

18. What is the difference between AWS Lambda and AWS EC2?

Answer:

 AWS Lambda is a serverless compute service where you don’t manage servers. You
only pay for the compute time that your code runs, and Lambda automatically scales
based on demand.
 AWS EC2 is a virtual machine-based compute service where you need to provision,
manage, and scale servers. EC2 requires more management, but it gives you more control
over the underlying infrastructure.

These AWS Lambda questions and answers cover the key aspects of Lambda functions,
including use cases, performance considerations, integration, and management. Being familiar
with these will help you in an interview involving AWS Lambda.

You might also like