0% found this document useful (0 votes)
39 views12 pages

AWS Lambda

AWS Lambda is a serverless computing service that allows developers to run code in response to events without managing infrastructure, automatically handling scaling and maintenance. It supports various programming languages and integrates with other AWS services, making it ideal for event-driven applications. While it offers advantages like cost efficiency and automatic scaling, it also has limitations such as execution time limits and potential latency issues.

Uploaded by

rincejohn80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views12 pages

AWS Lambda

AWS Lambda is a serverless computing service that allows developers to run code in response to events without managing infrastructure, automatically handling scaling and maintenance. It supports various programming languages and integrates with other AWS services, making it ideal for event-driven applications. While it offers advantages like cost efficiency and automatic scaling, it also has limitations such as execution time limits and potential latency issues.

Uploaded by

rincejohn80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

AWS Lambda

AWS Lambda is a serverless computing service that automatically runs code in


response to events, without requiring you to manage the underlying
infrastructure. It supports event-driven applications triggered by events such as
HTTP requests, DynamoDB table updates, or state transitions. You simply upload
your code (as a .zip file or container image), and Lambda handles everything from
provisioning to scaling and maintenance. It automatically scales applications based
on traffic, handling server management, auto-scaling, security patching, and
monitoring. AWS Lambda is ideal for developers who want to focus on writing code
without worrying about infrastructure management.

AWS Lambda is a cloud computing service that lets developers run code without
managing compute resources. It's a popular example of serverless architecture
and function as a service (FaaS).
What are Lambdas Functions?
AWS lambda are server-less compute functions are fully managed by the AWS
where developers can run there code without worrying about servers. AWS lambda
functions will allow you to run the code without provisioning or managing servers.

Once you upload the source code file into AWS lambda in the form of ZIP file then
AWS lambda will automatically run the code without you provision the servers and
also it will automatically scaling your functions up or down based on demand.

AWS lambda are mostly used for the event-driven application for the data
processing Amazon S3 buckets, or responding to HTTP requests.

Example:
 Process data from Amazon S3 buckets.
 Respond to HTTP requests.
 Build serverless applications.

Use Cases of AWS Lambda Functions


You can trigger the lambda in so many ways some of which are mentioned below.

File Processing: AWS lambda can be triggered by using simple storage services (S3).
Whenever files are added to the S3 service Lambda data processing will be
triggered.

Web Applications: You can combine both web applications and AWS lambda which
will scale up and down automatically based on the incoming traffic.
IoT (Internet of Things) applications: You can trigger the AWS lambda based on
certain conditions while processing the data from the device which are connected
to the IOT applications. It will analyze the data which are received from the IOT
application.

Stream Processing: Lambda functions can be integrated with the Amazonn kinesis
to process real-time streaming data for application tracking, log filtering, and so
on.

AWS lambda will help you to focus more on your code than the underlying
infrastructure. The infrastructure maintenance in AWS was taken care of by AWS
lambda.

Features of AWS Lambda Functions


The following are the some features which are provided by the AWS (Amazon Web
Services):

AutoScaling and High Availability: AWS lambda will make sure that your application
was highly available to the end users when there is sudden incoming traffic. High
availability can be achieved by scaling the application.

Serverless Execution: There is no need for provisioning the servers manually in


AWS. AWS lambda will provision the underlying infrastructure based on the
triggers you are mentioned whenever a new file uploaded to a particular then AWS
lambda will automatically trigger and takes care of the infrastructure.

Pay-per-use-pricing: AWS will charge you only for the time that time compute
engine was active. AWS bills you based on the time taken to execute the code.
Supports different programming languages: AWS lambda function will support
different programming languages. You can build the function with the language at
your convenience. Following are some languages supported by AWS lambda:

 Python
 Node.js
 Java
 C#
 PowerShell
 Go

Integrates with other AWS Services: AWS lambda can be integrated with different

AWS services like the following :

 API Gateway
 DynamoDB
 S3
 Step Functions
 SNS
 SQS

Versioning and Deployment: AWS lambda function will maintain the different
kinds of versions of the code by which you can change between the versions
without any disruptions y based on the application performances.

Security and Identity Management: AWS lambda will leverage AWS Identity and
Access Management (IAM) to control the access to the functions which are built
by using lambda You can define fine-grained permissions and policies to secure
your functions and ensure that only authorized entities can invoke them.
Working of AWS Lambda Functions
Start off by uploading the code to AWS Lambda. From there, set up the code to
trigger from other AWS services, HTTP endpoints, or mobile apps. AWS Lambda
will only run the code when it’s triggered and will also only use the computing
resources needed to run it. The user has to pay only for the compute time used.

Getting Started With AWS Lambda Function

The following are the steps mentioned below to create your own customized
AWS lambda functions by using the AWS console. Create an AWS account.

Steps for Creating AWS Lambda Functions Using AWS Console

Step 1: Log in to your AWS console and search for Lambda. As shown in the
following image.
Step 2: Click on Create function.

Step 3: Here we are going to use a sample hello world program by using Author
from scratch and configure the details according to your requirement.
Step 4: Successfully our function is created.

Advantages of AWS Lambda Function


The following are the advantages of AWS Lambda function

Zero Server Management: Since AWS Lambda automatically runs the user’s code,
there’s no need for the user to manage the server. Simply write the code and
upload it to Lambda.

Scalability: AWS Lambda runs code in response to each trigger, so the user’s
application is automatically scaled. The code also runs in parallel processes, each
triggered individually, so scaling is done precisely with the size of the workload.

Event-Driven Architecture: AWS Lambda function can be triggered based on the


events happing in the aws other service like when the file or video is added to the
S3 bucket you can trigger the AWS Lambda function.

Automatic High Availability: When there is high demand or high incoming traffic
aws lambda function will automatically scale the servers.
Affordable: With AWS Lambda, one doesn’t pay anything when the code isn’t
running. The user has to only be charged for every 100ms of code execution and
the number of times his code is actually triggered.

Disadvantages of AWS Lambda Function


The following are the disadvantages of AWS Lambda function:

Latency while starting: While aws lambda is going to be activated after a long gap
it will take some time to initialize the service which is required to deploy the
application at that time end users will face latency issues.

Limited control of infrastructure: Behalf of your lambda function is going to take


of underlying infrastructure so you will have very limited control over undelaying
infrastructure.

Time Limit: AWS Lambda enforces a maximum execution time limit for functions,
which is currently set to 900 seconds (15 minutes). If your function exceeds this
time limit, it will be forcibly terminated.

Vendor Lock-In: If you want to execute the lambda function then you need the
support of any cloud provider as here we are using AWS because it is widely used
in the market.

Limited Computing and Memory Options: Limited configuration is there on the


memory and CPU configuration. The predefined memory configuration was 120 MB
to 120 GB and memory configuration determines the corresponding CPU power.
Benefits of AWS Lambda Functions
Cost Efficiency: It only charges for the compute that is only for running known as
pay-as-you-go model.

Automatic Scaling: AWS Lambda automatically helps in scaling your applications


by running code in response to each trigger.

Reduced Operational Compliance: It allows the developers to focus on building


your logic, the aws itself while take care of the infrastructure.

Integration with AWS Services: It provides a seamlessly integration with other AWS
services, enabling strong and scalable applications.

Best Practices of using AWS Lambda Functions


Optimzing function performance: By minimizing the cold starts by keeping the
functions warm and reduce the execution time by optimizing your code and
dependencies.

Efficient Resource Management: Through allocating the appropriate amount of


memory to your function based on performance needs and cost considerations.

Implement Error Handling and Retries: By using try-catch blocks, AWS SDK retries
and dead letter queues (DLQs), we handle the errors gracefully.

Secure Your Functions: By applying the principles of least privilege for IAM roles,
using environment variables securely enhance the security.

How to build AWS functions in Python


To build your first Python based AWS Lambda function, follow these steps:

 Log into the AWS console and navigate to the Lambda dashboard.
 Click the orange Create Function button.
 Specify the function’s name and the Python version (Python 3.10 is
recommended).
 Edit the Python code in Amazon’s embedded code editor.
 Click Deploy and then Test to see your Python Lambda function in action!

AWS Lambda function creation


From the Lambda dashboard in the AWS management console, an orange Create
Function button entices you to create your function. When you click it, the system
only requires two pieces of information:

 The name of the Lambda function (I suggest myPythonFunction).


 The runtime language and version (I suggest Python 3.10).

With the basic AWS Lambda function created, you can move to the Python code
editor embedded within the AWS Management Console.
Simply provide a name and select the Python runtime to create an AWS Lambda
function.

AWS’ embedded Python code editor


Amazon provides a source code editor on the Code tab of the new function’s
configuration page.

The provided code is fully functional, but you should make the Python Lambda
function your own. Here’s how:

 Add a print statement to the function. Print statements turn into CloudWatch
logs.
 Customize the JSON in the return clause. This is the data that gets returned
to the calling program.

The embedded editor allows you to code complex Python function inside the AWS
Lambda configuration page. I suggest starting with a simple ‘Hello World’ though.
Test and deploy the serverless AWS Python function
Click the Deploy and then Test buttons, and your updated Lambda function and the
Python code is run. The output handsomely displays back to you in the Execution
Results tab.

Python print statement show up as log entries, and the return block is the Lambda’s
response.

And that’s how simple it is to create, code, test and deploy Python based AWS
Lambda functions. It really couldn’t be any easier!

You might also like