SlideShare a Scribd company logo
1 of 29
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

AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017
AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017
AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017
Amazon Web Services Korea
 
게임서비스를 위한 ElastiCache 활용 전략 :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS 2016
게임서비스를 위한 ElastiCache 활용 전략 :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS 2016게임서비스를 위한 ElastiCache 활용 전략 :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS 2016
게임서비스를 위한 ElastiCache 활용 전략 :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS 2016
Amazon Web Services Korea
 

What's hot (20)

Intro to Amazon ECS
Intro to Amazon ECSIntro to Amazon ECS
Intro to Amazon ECS
 
AWS Lambda Features and Uses
AWS Lambda Features and UsesAWS Lambda Features and Uses
AWS Lambda Features and Uses
 
Introduction To AWS & AWS Lambda
Introduction To AWS & AWS LambdaIntroduction To AWS & AWS Lambda
Introduction To AWS & AWS Lambda
 
Introduction to Amazon EC2
Introduction to Amazon EC2Introduction to Amazon EC2
Introduction to Amazon EC2
 
Application & Account Monitoring in AWS
Application & Account Monitoring in AWSApplication & Account Monitoring in AWS
Application & Account Monitoring in AWS
 
Introduction to AWS Organizations
Introduction to AWS OrganizationsIntroduction to AWS Organizations
Introduction to AWS Organizations
 
AWS Lambda
AWS LambdaAWS Lambda
AWS Lambda
 
AWS CloudFormation Masterclass
AWS CloudFormation MasterclassAWS CloudFormation Masterclass
AWS CloudFormation Masterclass
 
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
 
AWS - Lambda Fundamentals
AWS - Lambda FundamentalsAWS - Lambda Fundamentals
AWS - Lambda Fundamentals
 
Amazon Personalize Event Tracker 실시간 고객 반응을 고려한 추천::김태수, 솔루션즈 아키텍트, AWS::AWS ...
Amazon Personalize Event Tracker 실시간 고객 반응을 고려한 추천::김태수, 솔루션즈 아키텍트, AWS::AWS ...Amazon Personalize Event Tracker 실시간 고객 반응을 고려한 추천::김태수, 솔루션즈 아키텍트, AWS::AWS ...
Amazon Personalize Event Tracker 실시간 고객 반응을 고려한 추천::김태수, 솔루션즈 아키텍트, AWS::AWS ...
 
CloudWatch 성능 모니터링과 신속한 대응을 위한 노하우 - 박선용 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
CloudWatch 성능 모니터링과 신속한 대응을 위한 노하우 - 박선용 솔루션즈 아키텍트:: AWS Cloud Track 3 GamingCloudWatch 성능 모니터링과 신속한 대응을 위한 노하우 - 박선용 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
CloudWatch 성능 모니터링과 신속한 대응을 위한 노하우 - 박선용 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
 
데이터 분석가를 위한 신규 분석 서비스 - 김기영, AWS 분석 솔루션즈 아키텍트 / 변규현, 당근마켓 소프트웨어 엔지니어 :: AWS r...
데이터 분석가를 위한 신규 분석 서비스 - 김기영, AWS 분석 솔루션즈 아키텍트 / 변규현, 당근마켓 소프트웨어 엔지니어 :: AWS r...데이터 분석가를 위한 신규 분석 서비스 - 김기영, AWS 분석 솔루션즈 아키텍트 / 변규현, 당근마켓 소프트웨어 엔지니어 :: AWS r...
데이터 분석가를 위한 신규 분석 서비스 - 김기영, AWS 분석 솔루션즈 아키텍트 / 변규현, 당근마켓 소프트웨어 엔지니어 :: AWS r...
 
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
 
AWS SQS SNS
AWS SQS SNSAWS SQS SNS
AWS SQS SNS
 
AWS Lambda
AWS LambdaAWS Lambda
AWS Lambda
 
AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017
AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017
AWS 고객이 주로 겪는 운영 이슈에 대한 해법-AWS Summit Seoul 2017
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
 
AWS EC2
AWS EC2AWS EC2
AWS EC2
 
게임서비스를 위한 ElastiCache 활용 전략 :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS 2016
게임서비스를 위한 ElastiCache 활용 전략 :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS 2016게임서비스를 위한 ElastiCache 활용 전략 :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS 2016
게임서비스를 위한 ElastiCache 활용 전략 :: 구승모 솔루션즈 아키텍트 :: Gaming on AWS 2016
 

Similar to Introduce AWS Lambda for newbie and Non-IT

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
Amazon Web Services
 
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
Amazon Web Services
 

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
 
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
 
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
Skillenza Build with Serverless Challenge -  Advanced Serverless ConceptsSkillenza Build with Serverless Challenge -  Advanced Serverless Concepts
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
 

More from 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

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

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/