SlideShare a Scribd company logo
Introduce AWS Lambda
By Chitpong Wuttanan (iFew)
Updated as of 6 Feb 2019
Evolving to Serverless
Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
Evolving to Serverless
Reference: https://medium.com/@sdorzak/why-serverless-is-the-new-black-e4ff9e9947e0
What’s Serverless
● Is Cloud-computing execution model
● Dynamically manages the allocation of machine resources.
● Pricing is based on the actual amount of resources consumed by an
application
● Execute application logic only, but do not store data
● Client side control flow and dynamic content generation replaces the server
side controllers (Event-driven)
● In serverless applications, custom code components have a lifecycle that is
much shorter
● Serverless Providers such as AWS Lambda, Google Cloud Functions,
Microsoft Azure Functions, IBM/Apache's OpenWhisk (open source), Oracle
Cloud Fn (open source) Reference: https://en.wikipedia.org/wiki/Serverless_computing, https://martinfowler.com/bliki/Serverless.html
What’s Serverless
Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
Common use cases
Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
What’s Lambda
● Serverless Computing platform for stateless as a part of the AWS (Amazon
Web Services)
● Release on November 2014 (4 years agos)
● FaaS (Function-as-a-Service)
● Designed for EDA (Event-driven architecture)
● Support Node.js, Python, Java, Go, Ruby and C# through .NET Core
● Official Website https://aws.amazon.com/lambda
● Logo
Reference: https://en.wikipedia.org/wiki/AWS_Lambda
Lambda Lambda Function
Lambda Function Page
Events Trigger
Resources to access
Function
AWS Lambda models
Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
Working with AWS Lambda
Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
Example: Request to API endpoint
Reference: https://medium.com/@chrishantha/ballerina-services-in-serverless-world-b54c5e7382a0
Function
Understand the Function Lifecycle
Reference: https://www.slideshare.net/AmazonWebServices/srv310designing-microservices-with-serverless
Reference: https://www.slideshare.net/AmazonWebServices/become-a-serverless-black-belt-optimizing-your-serverless-applications-srv401-reinvent-2017,
https://www.slideshare.net/AmazonWebServices/srv310designing-microservices-with-serverless
AWS Optimization Your Optimization
Explain Initialization
Beware the Cold Start
AWS Lambda Function anatomy
Handler() Function
Function to start
execution of your Lambda
function.
Event object
Data sent during Lambda
function
Context object
Context object your code
can interact with AWS
Lambda
Continuous Scaling
Reference: https://docs.aws.amazon.com/lambda/latest/dg/scaling.html
Initial concurrency brust
Concurrency Limit per Account Concurrency Limit Account
1,000
Start Concurrency
(Asia Pacific - Singapore)
500
NumberofUserExecution
500
Add More (Automatic)
per minute
500
0
1,000Increasingmoretraffic
1,000
* Can request an increase
number of concurrent,
Contact AWS
1,001+
Queue
Setup Rate Limiting with Reserve Concurrency
Reserve concurrency
for this function
Concurrency limit per
account
Speed button, if execution
count is exceeding
Dynamic concurrency for
this function (Default)
Function is Throttled
Reserve concurrency
to zero
Can't call this
function anyway
Error/Debugging Display
Access monitoring via AWS CloudWatch
Tracing via AWS X-Ray
Duration time from Gateway
Duration time from LambdaCold Start
Should doing for develop Lambda Function
● Separate the Lambda handler from your core logic. This allows you to
make a more unit-testable function.
● Take advantage of Execution Context reuse to improve the performance of
your function
● Use AWS Lambda Environment Variables to pass operational parameters
to your function.
● Control the dependencies in your function's deployment package.
● Minimize your deployment package size to its runtime necessities.
● Reduce the time it takes Lambda to unpack deployment packages
● Minimize the complexity of your dependencies.
● Avoid using recursive code
Reference: https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html#function-code
Should doing for develop Lambda Function
● Avoid fat/monolithic functions
● Performance Testing for your lambda, to allocate memory and control cost
● Load Test your Lambda function to determine an optimum timeout value
and concurrency.
● Use most-restrictive permissions when setting IAM policies
● Delete Lambda functions that you are no longer using
Reference: https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html#function-code
AWS Lambda Pricing
Reference: https://aws.amazon.com/lambda/pricing/
Charged based on the number of requests for your functions and the duration time to execution code.
* 1 Gigabyte second is 1 Gigabyte of memory used for one second.
AWS Lambda Pricing - What’s Request?
Lambda counts a request each time it starts executing in response to an event notification or invoke call,
including test invokes from the console. You are charged for the total number of requests across all your
functions.
Function1 Request to
Reference: https://aws.amazon.com/lambda/pricing/
AWS Lambda Pricing - What’s Duration?
Duration is calculated from the time your code begins executing until it returns or otherwise terminates,
rounded up to the nearest 100ms. The price depends on the amount of memory you allocate to your
function.
Reference: https://aws.amazon.com/lambda/pricing/
Billed 15.2sec
Actual 0.00208sec
15.1sec * 0.256 GB-Second
= 3.8656 GB-Second
0.1sec * 0.128 GB-Second
= 0.0128 GB-Second
Billed 0.1sec
Actual 15.18536sec
* 1 Gigabyte second is 1 Gigabyte of memory used for one second.
Pricing related with Lambda Memory size
Reference: https://aws.amazon.com/lambda/pricing/
Memory (MB) Free tier seconds per month Price per 100ms ($)
128 3,200,000 0.000000208
256 1,600,000 0.000000417
512 800,000 0.000000834
1024 400,000 0.000001667
2048 200,000 0.000003334
3008 136,170 0.000004897
Lambda Function use memory size 128GB and run 8 times equal 1 GB-Second. It’s mean Lambda
Function can run 3,200,000 times/month (Free tier 400,000 GB-Second/month)
Pricing Example
Reference: https://aws.amazon.com/lambda/pricing/
Function
get_product()
Allocate Memory Size
128mb
Execute Duration
200ms
6,000,000 seconds
Total execute in one month
$5.83
Total charge in one month
Compute
charges
30 million times
Total execute in one month
$5.80
Total charge in one month
Request
charges
Total charges = Compute charges + Request charges = $11.63 per month
If you allocated 128MB of memory to your function, executed it 30 million times in one month, and it ran for
200ms each time, your charges would be calculated as follows:
Pricing Example
What’s total compute number for free tier
128MB compute price is $0.000000208 per 100ms
This function execute 200ms in 1 times is $0.000000417
or 1 times using 0.2sec * 128MB/1024 = 0.025 GB-s
or 1 GB-s can run this function 40 times (or $0.00001667)
Free tier 400,000 GB-s can run this function 16,000,000 times
Calculate compute for 30 million times/month
Total compute (seconds) = 30,000,000 * 0.2sec = 6,000,000 seconds
Total compute (GB-s) = 6,000,000sec * 128MB/1024 = 750,000 GB-s
750,000 GB-s – 400,000 free tier GB-s = 350,000 GB-s
Monthly compute charges = 350,000 * $0.00001667 = $5.83
Compute
charges
What’s total request number for free tier, and request cost
- The monthly request price is $0.20 per 1 million requests
- Free tier provides 1M requests per month.
Calculate request for 30 million times/month
Total requests – Free tier request = Billable requests
30M requests – 1M free tier requests = 29M Monthly billable requests
Monthly request charges = 29M * $0.2/M = $5.80
Request
charges
Advantages/Disadvantages
● Advantages
○ Significant reduction in costs
○ No servers to manage
○ Continuous Scaling
● Disadvantages
○ Infrequently-used serverless code may suffer from greater response latency (Start time to
idle: 5 minutes)
○ Resource limits by cloud providers (Lambda Limit Concurrency 1,000/region/account)
○ Conceptual overhead of splitting a single application
○ Local development and unit testing is also harder
○ Hard to Monitoring and debugging
○ OS vulnerabilities are taken care of by the cloud provider
Reference: https://en.wikipedia.org/wiki/Serverless_computing, https://martinfowler.com/bliki/Serverless.html, https://khasathan.in.th/archives/1712/

More Related Content

What's hot

infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
Amazon Web Services
 
Amazon S3 Masterclass
Amazon S3 MasterclassAmazon S3 Masterclass
Amazon S3 Masterclass
Amazon Web Services
 
IAM Introduction
IAM IntroductionIAM Introduction
IAM Introduction
Amazon Web Services
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
Amazon Web Services
 
Aws route 53
Aws route 53Aws route 53
Amazon EMR Deep Dive & Best Practices
Amazon EMR Deep Dive & Best PracticesAmazon EMR Deep Dive & Best Practices
Amazon EMR Deep Dive & Best Practices
Amazon Web Services
 
Intro to AWS Lambda
Intro to AWS Lambda Intro to AWS Lambda
Intro to AWS Lambda
Amazon Web Services
 
Auto Scaling Groups
Auto Scaling GroupsAuto Scaling Groups
Auto Scaling Groups
Peter Sankauskas
 
Aws cloud watch
Aws cloud watchAws cloud watch
Aws cloud watch
Mahesh Raj
 
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
Amazon Web Services Korea
 
Introduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless ApplicationsIntroduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless Applications
Amazon Web Services
 
Serverless computing with AWS Lambda
Serverless computing with AWS Lambda Serverless computing with AWS Lambda
Serverless computing with AWS Lambda
Apigee | Google Cloud
 
ElastiCache & Redis
ElastiCache & RedisElastiCache & Redis
ElastiCache & Redis
Amazon Web Services
 
Introduction to AWS Organizations
Introduction to AWS OrganizationsIntroduction to AWS Organizations
Introduction to AWS Organizations
Amazon Web Services
 
IAM Introduction and Best Practices
IAM Introduction and Best PracticesIAM Introduction and Best Practices
IAM Introduction and Best Practices
Amazon Web Services
 
AWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless CloudAWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless Cloud
Amazon Web Services
 
AWS Lambda
AWS LambdaAWS Lambda
AWS Lambda
Andrew Dixon
 
Identity and Access Management: The First Step in AWS Security
Identity and Access Management: The First Step in AWS SecurityIdentity and Access Management: The First Step in AWS Security
Identity and Access Management: The First Step in AWS Security
Amazon Web Services
 
AWS CloudFormation Masterclass
AWS CloudFormation MasterclassAWS CloudFormation Masterclass
AWS CloudFormation Masterclass
Amazon Web Services
 
Introduction of AWS KMS
Introduction of AWS KMSIntroduction of AWS KMS
Introduction of AWS KMS
Ricardo Schmidt
 

What's hot (20)

infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
 
Amazon S3 Masterclass
Amazon S3 MasterclassAmazon S3 Masterclass
Amazon S3 Masterclass
 
IAM Introduction
IAM IntroductionIAM Introduction
IAM Introduction
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Aws route 53
Aws route 53Aws route 53
Aws route 53
 
Amazon EMR Deep Dive & Best Practices
Amazon EMR Deep Dive & Best PracticesAmazon EMR Deep Dive & Best Practices
Amazon EMR Deep Dive & Best Practices
 
Intro to AWS Lambda
Intro to AWS Lambda Intro to AWS Lambda
Intro to AWS Lambda
 
Auto Scaling Groups
Auto Scaling GroupsAuto Scaling Groups
Auto Scaling Groups
 
Aws cloud watch
Aws cloud watchAws cloud watch
Aws cloud watch
 
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
 
Introduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless ApplicationsIntroduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless Applications
 
Serverless computing with AWS Lambda
Serverless computing with AWS Lambda Serverless computing with AWS Lambda
Serverless computing with AWS Lambda
 
ElastiCache & Redis
ElastiCache & RedisElastiCache & Redis
ElastiCache & Redis
 
Introduction to AWS Organizations
Introduction to AWS OrganizationsIntroduction to AWS Organizations
Introduction to AWS Organizations
 
IAM Introduction and Best Practices
IAM Introduction and Best PracticesIAM Introduction and Best Practices
IAM Introduction and Best Practices
 
AWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless CloudAWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless Cloud
 
AWS Lambda
AWS LambdaAWS Lambda
AWS Lambda
 
Identity and Access Management: The First Step in AWS Security
Identity and Access Management: The First Step in AWS SecurityIdentity and Access Management: The First Step in AWS Security
Identity and Access Management: The First Step in AWS Security
 
AWS CloudFormation Masterclass
AWS CloudFormation MasterclassAWS CloudFormation Masterclass
AWS CloudFormation Masterclass
 
Introduction of AWS KMS
Introduction of AWS KMSIntroduction of AWS KMS
Introduction of AWS KMS
 

Similar to Introduce AWS Lambda for newbie and Non-IT

Making sense of service quotas of AWS Serverless services and how to deal wit...
Making sense of service quotas of AWS Serverless services and how to deal wit...Making sense of service quotas of AWS Serverless services and how to deal wit...
Making sense of service quotas of AWS Serverless services and how to deal wit...
Vadym Kazulkin
 
Serverless architectures on aws
Serverless architectures on awsServerless architectures on aws
Serverless architectures on aws
Paolo latella
 
Serverless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBMServerless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBM
RightScale
 
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Vadym Kazulkin
 
Serverless on AWS : Understanding the hard parts at Froscon 2019
Serverless on AWS : Understanding the hard parts at Froscon 2019Serverless on AWS : Understanding the hard parts at Froscon 2019
Serverless on AWS : Understanding the hard parts at Froscon 2019
Vadym Kazulkin
 
AWS Lambda Presentation (Tech Talk DC)
AWS Lambda Presentation (Tech Talk DC)AWS Lambda Presentation (Tech Talk DC)
AWS Lambda Presentation (Tech Talk DC)
Doguhan Uluca
 
SMC303 Real-time Data Processing Using AWS Lambda
SMC303 Real-time Data Processing Using AWS LambdaSMC303 Real-time Data Processing Using AWS Lambda
SMC303 Real-time Data Processing Using AWS Lambda
Amazon Web Services
 
使用 AWS 無伺服器運算服務打造您的第一個語音助理
使用 AWS 無伺服器運算服務打造您的第一個語音助理使用 AWS 無伺服器運算服務打造您的第一個語音助理
使用 AWS 無伺服器運算服務打造您的第一個語音助理
Amazon Web Services
 
Real-time Data Processing Using AWS Lambda
Real-time Data Processing Using AWS LambdaReal-time Data Processing Using AWS Lambda
Real-time Data Processing Using AWS Lambda
Amazon Web Services
 
Real Time Data Processing Using AWS Lambda - DevDay Austin 2017
Real Time Data Processing Using AWS Lambda - DevDay Austin 2017Real Time Data Processing Using AWS Lambda - DevDay Austin 2017
Real Time Data Processing Using AWS Lambda - DevDay Austin 2017Amazon Web Services
 
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D..."Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
Vadym Kazulkin
 
Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017Amazon Web Services
 
AWS Lambda Features and Uses
AWS Lambda Features and UsesAWS Lambda Features and Uses
AWS Lambda Features and Uses
GlobalLogic Ukraine
 
Building Serverless Web Applications - DevDay Los Angeles 2017
Building Serverless Web Applications - DevDay Los Angeles 2017Building Serverless Web Applications - DevDay Los Angeles 2017
Building Serverless Web Applications - DevDay Los Angeles 2017
Amazon Web Services
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
Amazon Web Services
 
Making sense of service quotas of AWS Serverless services and how to deal wit...
Making sense of service quotas of AWS Serverless services and how to deal wit...Making sense of service quotas of AWS Serverless services and how to deal wit...
Making sense of service quotas of AWS Serverless services and how to deal wit...
Vadym Kazulkin
 
Optimize Cost Efficiency on AWS
Optimize Cost Efficiency on AWSOptimize Cost Efficiency on AWS
Optimize Cost Efficiency on AWS
Amazon Web Services
 
Raleigh DevDay 2017: Real time data processing using AWS Lambda
Raleigh DevDay 2017: Real time data processing using AWS LambdaRaleigh DevDay 2017: Real time data processing using AWS Lambda
Raleigh DevDay 2017: Real time data processing using AWS Lambda
Amazon Web Services
 
Čtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal HatákČtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal Haták
Ctvrtkoncz
 
Introduction to AWS Lambda with Python
Introduction to AWS Lambda with PythonIntroduction to AWS Lambda with Python
Introduction to AWS Lambda with Python
adaplo
 

Similar to Introduce AWS Lambda for newbie and Non-IT (20)

Making sense of service quotas of AWS Serverless services and how to deal wit...
Making sense of service quotas of AWS Serverless services and how to deal wit...Making sense of service quotas of AWS Serverless services and how to deal wit...
Making sense of service quotas of AWS Serverless services and how to deal wit...
 
Serverless architectures on aws
Serverless architectures on awsServerless architectures on aws
Serverless architectures on aws
 
Serverless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBMServerless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBM
 
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
Serverless on AWS : Understanding the hard parts at Serverless Meetup Dusseld...
 
Serverless on AWS : Understanding the hard parts at Froscon 2019
Serverless on AWS : Understanding the hard parts at Froscon 2019Serverless on AWS : Understanding the hard parts at Froscon 2019
Serverless on AWS : Understanding the hard parts at Froscon 2019
 
AWS Lambda Presentation (Tech Talk DC)
AWS Lambda Presentation (Tech Talk DC)AWS Lambda Presentation (Tech Talk DC)
AWS Lambda Presentation (Tech Talk DC)
 
SMC303 Real-time Data Processing Using AWS Lambda
SMC303 Real-time Data Processing Using AWS LambdaSMC303 Real-time Data Processing Using AWS Lambda
SMC303 Real-time Data Processing Using AWS Lambda
 
使用 AWS 無伺服器運算服務打造您的第一個語音助理
使用 AWS 無伺服器運算服務打造您的第一個語音助理使用 AWS 無伺服器運算服務打造您的第一個語音助理
使用 AWS 無伺服器運算服務打造您的第一個語音助理
 
Real-time Data Processing Using AWS Lambda
Real-time Data Processing Using AWS LambdaReal-time Data Processing Using AWS Lambda
Real-time Data Processing Using AWS Lambda
 
Real Time Data Processing Using AWS Lambda - DevDay Austin 2017
Real Time Data Processing Using AWS Lambda - DevDay Austin 2017Real Time Data Processing Using AWS Lambda - DevDay Austin 2017
Real Time Data Processing Using AWS Lambda - DevDay Austin 2017
 
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D..."Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
"Production-ready Serverless Java Applications in 3 weeks" at AWS Community D...
 
Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017
 
AWS Lambda Features and Uses
AWS Lambda Features and UsesAWS Lambda Features and Uses
AWS Lambda Features and Uses
 
Building Serverless Web Applications - DevDay Los Angeles 2017
Building Serverless Web Applications - DevDay Los Angeles 2017Building Serverless Web Applications - DevDay Los Angeles 2017
Building Serverless Web Applications - DevDay Los Angeles 2017
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Making sense of service quotas of AWS Serverless services and how to deal wit...
Making sense of service quotas of AWS Serverless services and how to deal wit...Making sense of service quotas of AWS Serverless services and how to deal wit...
Making sense of service quotas of AWS Serverless services and how to deal wit...
 
Optimize Cost Efficiency on AWS
Optimize Cost Efficiency on AWSOptimize Cost Efficiency on AWS
Optimize Cost Efficiency on AWS
 
Raleigh DevDay 2017: Real time data processing using AWS Lambda
Raleigh DevDay 2017: Real time data processing using AWS LambdaRaleigh DevDay 2017: Real time data processing using AWS Lambda
Raleigh DevDay 2017: Real time data processing using AWS Lambda
 
Čtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal HatákČtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal Haták
 
Introduction to AWS Lambda with Python
Introduction to AWS Lambda with PythonIntroduction to AWS Lambda with Python
Introduction to AWS Lambda with Python
 

More from Chitpong Wuttanan

Google AMP (Accelerated Mobile Pages)
Google AMP (Accelerated Mobile Pages)Google AMP (Accelerated Mobile Pages)
Google AMP (Accelerated Mobile Pages)
Chitpong Wuttanan
 
Apple Pay
Apple PayApple Pay
Introduction Bitcoin
Introduction BitcoinIntroduction Bitcoin
Introduction Bitcoin
Chitpong Wuttanan
 
PayPal Beacon and Apple iBeacon
PayPal Beacon and Apple iBeaconPayPal Beacon and Apple iBeacon
PayPal Beacon and Apple iBeacon
Chitpong Wuttanan
 
Defining strategies from the value of website
Defining strategies from the value of websiteDefining strategies from the value of website
Defining strategies from the value of website
Chitpong Wuttanan
 
Basic of SSDLC
Basic of SSDLCBasic of SSDLC
Basic of SSDLC
Chitpong Wuttanan
 

More from Chitpong Wuttanan (10)

Google AMP (Accelerated Mobile Pages)
Google AMP (Accelerated Mobile Pages)Google AMP (Accelerated Mobile Pages)
Google AMP (Accelerated Mobile Pages)
 
Apple Pay
Apple PayApple Pay
Apple Pay
 
Introduction Bitcoin
Introduction BitcoinIntroduction Bitcoin
Introduction Bitcoin
 
PayPal Beacon and Apple iBeacon
PayPal Beacon and Apple iBeaconPayPal Beacon and Apple iBeacon
PayPal Beacon and Apple iBeacon
 
Defining strategies from the value of website
Defining strategies from the value of websiteDefining strategies from the value of website
Defining strategies from the value of website
 
E-Marketing by TARAD
E-Marketing by TARADE-Marketing by TARAD
E-Marketing by TARAD
 
Backpack to Shangrila
Backpack to ShangrilaBackpack to Shangrila
Backpack to Shangrila
 
Blog free hong kong
Blog free hong kongBlog free hong kong
Blog free hong kong
 
Introduction social network
Introduction social networkIntroduction social network
Introduction social network
 
Basic of SSDLC
Basic of SSDLCBasic of SSDLC
Basic of SSDLC
 

Recently uploaded

PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 

Recently uploaded (20)

PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 

Introduce AWS Lambda for newbie and Non-IT

  • 1. Introduce AWS Lambda By Chitpong Wuttanan (iFew) Updated as of 6 Feb 2019
  • 2. Evolving to Serverless Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
  • 3. Evolving to Serverless Reference: https://medium.com/@sdorzak/why-serverless-is-the-new-black-e4ff9e9947e0
  • 4. What’s Serverless ● Is Cloud-computing execution model ● Dynamically manages the allocation of machine resources. ● Pricing is based on the actual amount of resources consumed by an application ● Execute application logic only, but do not store data ● Client side control flow and dynamic content generation replaces the server side controllers (Event-driven) ● In serverless applications, custom code components have a lifecycle that is much shorter ● Serverless Providers such as AWS Lambda, Google Cloud Functions, Microsoft Azure Functions, IBM/Apache's OpenWhisk (open source), Oracle Cloud Fn (open source) Reference: https://en.wikipedia.org/wiki/Serverless_computing, https://martinfowler.com/bliki/Serverless.html
  • 6. Common use cases Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
  • 7. What’s Lambda ● Serverless Computing platform for stateless as a part of the AWS (Amazon Web Services) ● Release on November 2014 (4 years agos) ● FaaS (Function-as-a-Service) ● Designed for EDA (Event-driven architecture) ● Support Node.js, Python, Java, Go, Ruby and C# through .NET Core ● Official Website https://aws.amazon.com/lambda ● Logo Reference: https://en.wikipedia.org/wiki/AWS_Lambda Lambda Lambda Function
  • 8. Lambda Function Page Events Trigger Resources to access Function
  • 9. AWS Lambda models Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
  • 10. Working with AWS Lambda Reference: https://www.slideshare.net/AmazonWebServices/deep-dive-on-aws-lambda
  • 11. Example: Request to API endpoint Reference: https://medium.com/@chrishantha/ballerina-services-in-serverless-world-b54c5e7382a0 Function
  • 12. Understand the Function Lifecycle Reference: https://www.slideshare.net/AmazonWebServices/srv310designing-microservices-with-serverless
  • 14. AWS Lambda Function anatomy Handler() Function Function to start execution of your Lambda function. Event object Data sent during Lambda function Context object Context object your code can interact with AWS Lambda
  • 15. Continuous Scaling Reference: https://docs.aws.amazon.com/lambda/latest/dg/scaling.html Initial concurrency brust Concurrency Limit per Account Concurrency Limit Account 1,000 Start Concurrency (Asia Pacific - Singapore) 500 NumberofUserExecution 500 Add More (Automatic) per minute 500 0 1,000Increasingmoretraffic 1,000 * Can request an increase number of concurrent, Contact AWS 1,001+ Queue
  • 16. Setup Rate Limiting with Reserve Concurrency Reserve concurrency for this function Concurrency limit per account Speed button, if execution count is exceeding Dynamic concurrency for this function (Default)
  • 17. Function is Throttled Reserve concurrency to zero Can't call this function anyway
  • 19. Access monitoring via AWS CloudWatch
  • 20. Tracing via AWS X-Ray Duration time from Gateway Duration time from LambdaCold Start
  • 21. Should doing for develop Lambda Function ● Separate the Lambda handler from your core logic. This allows you to make a more unit-testable function. ● Take advantage of Execution Context reuse to improve the performance of your function ● Use AWS Lambda Environment Variables to pass operational parameters to your function. ● Control the dependencies in your function's deployment package. ● Minimize your deployment package size to its runtime necessities. ● Reduce the time it takes Lambda to unpack deployment packages ● Minimize the complexity of your dependencies. ● Avoid using recursive code Reference: https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html#function-code
  • 22. Should doing for develop Lambda Function ● Avoid fat/monolithic functions ● Performance Testing for your lambda, to allocate memory and control cost ● Load Test your Lambda function to determine an optimum timeout value and concurrency. ● Use most-restrictive permissions when setting IAM policies ● Delete Lambda functions that you are no longer using Reference: https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html#function-code
  • 23. AWS Lambda Pricing Reference: https://aws.amazon.com/lambda/pricing/ Charged based on the number of requests for your functions and the duration time to execution code. * 1 Gigabyte second is 1 Gigabyte of memory used for one second.
  • 24. AWS Lambda Pricing - What’s Request? Lambda counts a request each time it starts executing in response to an event notification or invoke call, including test invokes from the console. You are charged for the total number of requests across all your functions. Function1 Request to Reference: https://aws.amazon.com/lambda/pricing/
  • 25. AWS Lambda Pricing - What’s Duration? Duration is calculated from the time your code begins executing until it returns or otherwise terminates, rounded up to the nearest 100ms. The price depends on the amount of memory you allocate to your function. Reference: https://aws.amazon.com/lambda/pricing/ Billed 15.2sec Actual 0.00208sec 15.1sec * 0.256 GB-Second = 3.8656 GB-Second 0.1sec * 0.128 GB-Second = 0.0128 GB-Second Billed 0.1sec Actual 15.18536sec * 1 Gigabyte second is 1 Gigabyte of memory used for one second.
  • 26. Pricing related with Lambda Memory size Reference: https://aws.amazon.com/lambda/pricing/ Memory (MB) Free tier seconds per month Price per 100ms ($) 128 3,200,000 0.000000208 256 1,600,000 0.000000417 512 800,000 0.000000834 1024 400,000 0.000001667 2048 200,000 0.000003334 3008 136,170 0.000004897 Lambda Function use memory size 128GB and run 8 times equal 1 GB-Second. It’s mean Lambda Function can run 3,200,000 times/month (Free tier 400,000 GB-Second/month)
  • 27. Pricing Example Reference: https://aws.amazon.com/lambda/pricing/ Function get_product() Allocate Memory Size 128mb Execute Duration 200ms 6,000,000 seconds Total execute in one month $5.83 Total charge in one month Compute charges 30 million times Total execute in one month $5.80 Total charge in one month Request charges Total charges = Compute charges + Request charges = $11.63 per month If you allocated 128MB of memory to your function, executed it 30 million times in one month, and it ran for 200ms each time, your charges would be calculated as follows:
  • 28. Pricing Example What’s total compute number for free tier 128MB compute price is $0.000000208 per 100ms This function execute 200ms in 1 times is $0.000000417 or 1 times using 0.2sec * 128MB/1024 = 0.025 GB-s or 1 GB-s can run this function 40 times (or $0.00001667) Free tier 400,000 GB-s can run this function 16,000,000 times Calculate compute for 30 million times/month Total compute (seconds) = 30,000,000 * 0.2sec = 6,000,000 seconds Total compute (GB-s) = 6,000,000sec * 128MB/1024 = 750,000 GB-s 750,000 GB-s – 400,000 free tier GB-s = 350,000 GB-s Monthly compute charges = 350,000 * $0.00001667 = $5.83 Compute charges What’s total request number for free tier, and request cost - The monthly request price is $0.20 per 1 million requests - Free tier provides 1M requests per month. Calculate request for 30 million times/month Total requests – Free tier request = Billable requests 30M requests – 1M free tier requests = 29M Monthly billable requests Monthly request charges = 29M * $0.2/M = $5.80 Request charges
  • 29. Advantages/Disadvantages ● Advantages ○ Significant reduction in costs ○ No servers to manage ○ Continuous Scaling ● Disadvantages ○ Infrequently-used serverless code may suffer from greater response latency (Start time to idle: 5 minutes) ○ Resource limits by cloud providers (Lambda Limit Concurrency 1,000/region/account) ○ Conceptual overhead of splitting a single application ○ Local development and unit testing is also harder ○ Hard to Monitoring and debugging ○ OS vulnerabilities are taken care of by the cloud provider Reference: https://en.wikipedia.org/wiki/Serverless_computing, https://martinfowler.com/bliki/Serverless.html, https://khasathan.in.th/archives/1712/