SlideShare una empresa de Scribd logo
1 de 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/

Más contenido relacionado

La actualidad más candente

[NEW LAUNCH!] Introducti[NEW LAUNCH!] Introduction to event-driven architectu...
[NEW LAUNCH!] Introducti[NEW LAUNCH!] Introduction to event-driven architectu...[NEW LAUNCH!] Introducti[NEW LAUNCH!] Introduction to event-driven architectu...
[NEW LAUNCH!] Introducti[NEW LAUNCH!] Introduction to event-driven architectu...Amazon Web Services
 
DEV323_Introduction to the AWS CLI
DEV323_Introduction to the AWS CLIDEV323_Introduction to the AWS CLI
DEV323_Introduction to the AWS CLIAmazon Web Services
 
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나
Amazon RDS Proxy 집중 탐구 - 윤석찬 :: AWS Unboxing 온라인 세미나Amazon Web Services Korea
 
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) Amazon Web Services Korea
 
Introduction To AWS & AWS Lambda
Introduction To AWS & AWS LambdaIntroduction To AWS & AWS Lambda
Introduction To AWS & AWS LambdaAn Nguyen
 
Getting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and ServerlessGetting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and ServerlessAmazon Web Services
 
Building AWS Lambda Applications with the AWS Serverless Application Model (A...
Building AWS Lambda Applications with the AWS Serverless Application Model (A...Building AWS Lambda Applications with the AWS Serverless Application Model (A...
Building AWS Lambda Applications with the AWS Serverless Application Model (A...Amazon Web Services
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesAmazon Web Services
 
Amazon EventBridge
Amazon EventBridgeAmazon EventBridge
Amazon EventBridgeDhaval Nagar
 
Serverless computing with AWS Lambda
Serverless computing with AWS Lambda Serverless computing with AWS Lambda
Serverless computing with AWS Lambda Apigee | Google Cloud
 
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
Elastic  Load Balancing Deep Dive - AWS Online Tech TalkElastic  Load Balancing Deep Dive - AWS Online Tech Talk
Elastic Load Balancing Deep Dive - AWS Online Tech TalkAmazon Web Services
 
Auto scaling using Amazon Web Services ( AWS )
Auto scaling using Amazon Web Services ( AWS )Auto scaling using Amazon Web Services ( AWS )
Auto scaling using Amazon Web Services ( AWS )Harish Ganesan
 

La actualidad más candente (20)

[NEW LAUNCH!] Introducti[NEW LAUNCH!] Introduction to event-driven architectu...
[NEW LAUNCH!] Introducti[NEW LAUNCH!] Introduction to event-driven architectu...[NEW LAUNCH!] Introducti[NEW LAUNCH!] Introduction to event-driven architectu...
[NEW LAUNCH!] Introducti[NEW LAUNCH!] Introduction to event-driven architectu...
 
DEV323_Introduction to the AWS CLI
DEV323_Introduction to the AWS CLIDEV323_Introduction to the AWS CLI
DEV323_Introduction to the AWS CLI
 
AWS Lambda
AWS LambdaAWS Lambda
AWS Lambda
 
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
 
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
 
Introduction To AWS & AWS Lambda
Introduction To AWS & AWS LambdaIntroduction To AWS & AWS Lambda
Introduction To AWS & AWS Lambda
 
Getting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and ServerlessGetting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and Serverless
 
Building AWS Lambda Applications with the AWS Serverless Application Model (A...
Building AWS Lambda Applications with the AWS Serverless Application Model (A...Building AWS Lambda Applications with the AWS Serverless Application Model (A...
Building AWS Lambda Applications with the AWS Serverless Application Model (A...
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Amazon EventBridge
Amazon EventBridgeAmazon EventBridge
Amazon EventBridge
 
Introduction to Serverless
Introduction to ServerlessIntroduction to Serverless
Introduction to Serverless
 
AWS ELB
AWS ELBAWS ELB
AWS ELB
 
Serverless computing with AWS Lambda
Serverless computing with AWS Lambda Serverless computing with AWS Lambda
Serverless computing with AWS Lambda
 
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
Elastic  Load Balancing Deep Dive - AWS Online Tech TalkElastic  Load Balancing Deep Dive - AWS Online Tech Talk
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
 
AWS Tagging Strategy
AWS Tagging StrategyAWS Tagging Strategy
AWS Tagging Strategy
 
AWS Lambda
AWS LambdaAWS Lambda
AWS Lambda
 
Auto scaling using Amazon Web Services ( AWS )
Auto scaling using Amazon Web Services ( AWS )Auto scaling using Amazon Web Services ( AWS )
Auto scaling using Amazon Web Services ( AWS )
 
Cloud Custodian
Cloud CustodianCloud Custodian
Cloud Custodian
 
Amazon ECS
Amazon ECSAmazon ECS
Amazon ECS
 

Similar a Introduce AWS Lambda for newbie and Non-IT

Serverless architectures on aws
Serverless architectures on awsServerless architectures on aws
Serverless architectures on awsPaolo 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 IBMRightScale
 
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 2019Vadym 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 LambdaAmazon 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 LambdaAmazon 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
 
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 2017Amazon 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 CloudAmazon 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
 
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 LambdaAmazon 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ákCtvrtkoncz
 
Introduction to AWS Lambda with Python
Introduction to AWS Lambda with PythonIntroduction to AWS Lambda with Python
Introduction to AWS Lambda with Pythonadaplo
 
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 ConceptsDhaval Nagar
 

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

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

Más de Chitpong Wuttanan

Más de 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
 

Último

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 Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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 WorkerThousandEyes
 
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...Igalia
 
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.pptxHampshireHUG
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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 MenDelhi Call girls
 
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 Processorsdebabhi2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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 slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Último (20)

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)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
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
 
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...
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

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/