SlideShare a Scribd company logo
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SRV301 - Best Practices for using
AWS Lambda with RDS-RDBMS
solutions
Mayank Thakkar
Global Life Sciences Solutions Architect
AWS
S R V 3 0 1
Emma Zhao
Software Development Manager
AWS
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Typical Solution Architecture
AWS Cloud
VPC
Availability zone 1
Availability zone 2
Private subnet
Private subnet
Private subnet
Private subnet
DB Instance
DB instance
standby
Elastic
network
interface
Elastic
network
interface
Lambda
Functions
Security group Security group
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Lambda with RDS / RDBMS - Best Practices
• Use subnets in multiple AZs for ENI configuration
• Protects against AZ failure and IP address exhaustion
• Lambda relies on ENIs (within your VPC) to connect
• Scalability depends on available free IP addresses and ENI limits
• ENI startup penalty
• Lambda in VPC mode does not have internet access by default.
• Add Network Address Translation (NAT) gateway inside the VPC to
enable internet access
• Avoid DNS resolution of public host names if possible
• Adds billable, time consuming resolution.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Problem: Managing Database Connections
…
Lambda can scale, can your database connections?
Is Connection
pooling the answer?
Generic database
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Time
Container A
Container B
Container C
Container D
Lambda - Scaling
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How does that affect Connection Pooling?
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Connection Pooling with Lambda
Use only one connection in a container, at a time
Set Connection Pool Size = 1
OR
Initialize the connection object “above the handler”
(in the global section)
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Connection Pooling with Lambda - Challenges
• No hook to indicate destruction of Lambda containers
• Can not explicitly close connections when the container is
recycled
• Fall back on Database TTL to clean up connections
• Can lead to session leakages
• No control over lifecycle of Lambda containers
• Can result many connections sitting idle
• Different containers for different Lambda functions
• No re use of connections across Lambda functions
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Solution 1a: Account Concurrency Limit
Use AWS Organizations to manage your accounts.
AWS Account
Lambda can help
with retries of
throttled
invocations*
* - Only for asynchronous and stream based event sources.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Solution 1b: Function Concurrency Limit
Lambda can help
with retries of
throttled
invocations*
* - Only for asynchronous and stream based event sources.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Concurrency Limits - Benefits
• Lambda Concurrency limit can be set at the
account level or at function level.
• Simple to set up
• Account level limit requires AWS support
• AWS Lambda manages retries for throttled
invocations*
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Concurrency Limits - Challenges
• Account Level limit:
• Covers Lambdas across the account – Difficult to isolate DB
interfacing functions
• Possibility of accounts sprawl.
• Function Level limit:
• Prior knowledge of DB accessing functions required.
• Limit should correspond to peak concurrency – prior
application behavior knowledge required
• Can not spread out connections dynamically, as load across
Lambdas varies
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Dynamic Connection Management
Helper
Maintain atomic counter
and max count
Open / close
connections
DB operations
Do something interesting
Generic database
Alarm
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Demo Code: https://tinyurl.com/lambdards
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Dynamic Connection Management - Benefits
• Scalable solution : depends on Lambda and Amazon DynamoDB
• Connections count managed from DB perspective
No limit on number of Lambda functions
• Can spread DB connections across Lambda functions @ runtime
Eliminate choke points and better serve hotspots
• Easy update : Control usable connections count through DynamoDB
• Use published CloudWatch metrics to react to out-of-connection
errors
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Dynamic Connection Management - Challenges
• No retries of throttled invocations: requires custom solution.
• More resources to manage.
• No connection re-use.
• Slightly increased latency.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Summary
• Lambda Scaling Model and Connection pooling do not
mix
• Use a single connection, initialized in the global section
• Solutions and Best Practices:
• Account and function level concurrency Limits
• Custom Solution: Dynamic Connection Management
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
References
• AWS Organizations
https://aws.amazon.com/organizations/
• AWS Serverless :
https://aws.amazon.com/serverless/
• AWS Lambda Container Reuse:
https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/
• Lambda - Retries of throttled invocations:
http://docs.aws.amazon.com/lambda/latest/dg/concurrent-
executions.html#concurrent-execution-safety-limit
• Dynamic Connections Manager Sample Code :
https://tinyurl.com/lambdards
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Questions?
Demo Code: https://tinyurl.com/lambdards
Thank you!
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Mayank Thakkar
Global Life Sciences Solutions Architect
AWS
Emma Zhao
Software Development Manager
AWS
Demo Code: https://tinyurl.com/lambdards
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

More Related Content

What's hot

Building a Recommender System on AWS
Building a Recommender System on AWSBuilding a Recommender System on AWS
Building a Recommender System on AWS
Amazon Web Services
 
Amazon Personalize 개인화 추천 모델 만들기::김태수, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Amazon Personalize 개인화 추천 모델 만들기::김태수, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나Amazon Personalize 개인화 추천 모델 만들기::김태수, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Amazon Personalize 개인화 추천 모델 만들기::김태수, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Amazon Web Services Korea
 
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
Amazon Web Services Japan
 
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
Amazon Web Services Japan
 
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
Amazon Web Services Korea
 
DeNA の AWS アカウント管理とセキュリティ監査自動化
DeNA の AWS アカウント管理とセキュリティ監査自動化DeNA の AWS アカウント管理とセキュリティ監査自動化
DeNA の AWS アカウント管理とセキュリティ監査自動化
DeNA
 
DevOps with Database on AWS
DevOps with Database on AWSDevOps with Database on AWS
DevOps with Database on AWS
Amazon Web Services Japan
 
[AWS Builders] 클라우드 비용, 어떻게 줄일 수 있을까?
[AWS Builders] 클라우드 비용, 어떻게 줄일 수 있을까?[AWS Builders] 클라우드 비용, 어떻게 줄일 수 있을까?
[AWS Builders] 클라우드 비용, 어떻게 줄일 수 있을까?
Amazon Web Services Korea
 
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
re:Invent 2022  DAT326 Deep dive into Amazon Aurora and its innovationsre:Invent 2022  DAT326 Deep dive into Amazon Aurora and its innovations
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
Grant McAlister
 
20191125 Container Security
20191125 Container Security20191125 Container Security
20191125 Container Security
Amazon Web Services Japan
 
[금융사를 위한 AWS Generative AI Day 2023] 4_AWS Generative AI 서비스의 활용 방ᄇ...
[금융사를 위한 AWS Generative AI Day 2023] 4_AWS Generative AI 서비스의 활용 방ᄇ...[금융사를 위한 AWS Generative AI Day 2023] 4_AWS Generative AI 서비스의 활용 방ᄇ...
[금융사를 위한 AWS Generative AI Day 2023] 4_AWS Generative AI 서비스의 활용 방ᄇ...
AWS Korea 금융산업팀
 
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
Amazon Web Services Japan
 
Automating AWS security and compliance
Automating AWS security and compliance Automating AWS security and compliance
Automating AWS security and compliance
John Varghese
 
Advanced Content Targeting & Personalization Within the Digital Experience Us...
Advanced Content Targeting & Personalization Within the Digital Experience Us...Advanced Content Targeting & Personalization Within the Digital Experience Us...
Advanced Content Targeting & Personalization Within the Digital Experience Us...
Perficient, Inc.
 
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
Amazon Web Services Korea
 
Amazon Sagemaker Studio를 통한 ML개발하기 - 소성운(크로키닷컴) :: AWS Community D...
Amazon Sagemaker Studio를 통한 ML개발하기 - 소성운(크로키닷컴) :: AWS Community D...Amazon Sagemaker Studio를 통한 ML개발하기 - 소성운(크로키닷컴) :: AWS Community D...
Amazon Sagemaker Studio를 통한 ML개발하기 - 소성운(크로키닷컴) :: AWS Community D...
AWSKRUG - AWS한국사용자모임
 
마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...
마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...
마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...
Amazon Web Services Korea
 
AWS Black Belt Online Seminar 2017 Amazon Kinesis
AWS Black Belt Online Seminar 2017 Amazon KinesisAWS Black Belt Online Seminar 2017 Amazon Kinesis
AWS Black Belt Online Seminar 2017 Amazon Kinesis
Amazon Web Services Japan
 
Deep dive into AWS IAM
Deep dive into AWS IAMDeep dive into AWS IAM
Deep dive into AWS IAM
Amazon Web Services
 
Day 1 with Amazon Web Services - AWSご利用開始時に最低限おさえておきたい10のこと
Day 1 with Amazon Web Services - AWSご利用開始時に最低限おさえておきたい10のことDay 1 with Amazon Web Services - AWSご利用開始時に最低限おさえておきたい10のこと
Day 1 with Amazon Web Services - AWSご利用開始時に最低限おさえておきたい10のこと
Amazon Web Services Japan
 

What's hot (20)

Building a Recommender System on AWS
Building a Recommender System on AWSBuilding a Recommender System on AWS
Building a Recommender System on AWS
 
Amazon Personalize 개인화 추천 모델 만들기::김태수, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Amazon Personalize 개인화 추천 모델 만들기::김태수, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나Amazon Personalize 개인화 추천 모델 만들기::김태수, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Amazon Personalize 개인화 추천 모델 만들기::김태수, 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
 
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
 
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
 
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
데브옵스 엔지니어를 위한 신규 운영 서비스 - 김필중, AWS 개발 전문 솔루션즈 아키텍트 / 김현민, 메가존클라우드 솔루션즈 아키텍트 :...
 
DeNA の AWS アカウント管理とセキュリティ監査自動化
DeNA の AWS アカウント管理とセキュリティ監査自動化DeNA の AWS アカウント管理とセキュリティ監査自動化
DeNA の AWS アカウント管理とセキュリティ監査自動化
 
DevOps with Database on AWS
DevOps with Database on AWSDevOps with Database on AWS
DevOps with Database on AWS
 
[AWS Builders] 클라우드 비용, 어떻게 줄일 수 있을까?
[AWS Builders] 클라우드 비용, 어떻게 줄일 수 있을까?[AWS Builders] 클라우드 비용, 어떻게 줄일 수 있을까?
[AWS Builders] 클라우드 비용, 어떻게 줄일 수 있을까?
 
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
re:Invent 2022  DAT326 Deep dive into Amazon Aurora and its innovationsre:Invent 2022  DAT326 Deep dive into Amazon Aurora and its innovations
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
 
20191125 Container Security
20191125 Container Security20191125 Container Security
20191125 Container Security
 
[금융사를 위한 AWS Generative AI Day 2023] 4_AWS Generative AI 서비스의 활용 방ᄇ...
[금융사를 위한 AWS Generative AI Day 2023] 4_AWS Generative AI 서비스의 활용 방ᄇ...[금융사를 위한 AWS Generative AI Day 2023] 4_AWS Generative AI 서비스의 활용 방ᄇ...
[금융사를 위한 AWS Generative AI Day 2023] 4_AWS Generative AI 서비스의 활용 방ᄇ...
 
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
 
Automating AWS security and compliance
Automating AWS security and compliance Automating AWS security and compliance
Automating AWS security and compliance
 
Advanced Content Targeting & Personalization Within the Digital Experience Us...
Advanced Content Targeting & Personalization Within the Digital Experience Us...Advanced Content Targeting & Personalization Within the Digital Experience Us...
Advanced Content Targeting & Personalization Within the Digital Experience Us...
 
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
 
Amazon Sagemaker Studio를 통한 ML개발하기 - 소성운(크로키닷컴) :: AWS Community D...
Amazon Sagemaker Studio를 통한 ML개발하기 - 소성운(크로키닷컴) :: AWS Community D...Amazon Sagemaker Studio를 통한 ML개발하기 - 소성운(크로키닷컴) :: AWS Community D...
Amazon Sagemaker Studio를 통한 ML개발하기 - 소성운(크로키닷컴) :: AWS Community D...
 
마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...
마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...
마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...
 
AWS Black Belt Online Seminar 2017 Amazon Kinesis
AWS Black Belt Online Seminar 2017 Amazon KinesisAWS Black Belt Online Seminar 2017 Amazon Kinesis
AWS Black Belt Online Seminar 2017 Amazon Kinesis
 
Deep dive into AWS IAM
Deep dive into AWS IAMDeep dive into AWS IAM
Deep dive into AWS IAM
 
Day 1 with Amazon Web Services - AWSご利用開始時に最低限おさえておきたい10のこと
Day 1 with Amazon Web Services - AWSご利用開始時に最低限おさえておきたい10のことDay 1 with Amazon Web Services - AWSご利用開始時に最低限おさえておきたい10のこと
Day 1 with Amazon Web Services - AWSご利用開始時に最低限おさえておきたい10のこと
 

Similar to Best Practices for Using AWS Lambda with RDS/RDBMS Solutions (SRV301-R1) - AWS re:Invent 2018

Serverless use cases with AWS Lambda - More Serverless Event
Serverless use cases with AWS Lambda - More Serverless EventServerless use cases with AWS Lambda - More Serverless Event
Serverless use cases with AWS Lambda - More Serverless Event
Boaz Ziniman
 
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Chris Munns
 
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Amazon Web Services
 
Serverless Architectural Patterns: Collision 2018
Serverless Architectural Patterns: Collision 2018Serverless Architectural Patterns: Collision 2018
Serverless Architectural Patterns: Collision 2018
Amazon Web Services
 
Serverless Architecture - Design Patterns and Best Practices
Serverless Architecture - Design Patterns and Best PracticesServerless Architecture - Design Patterns and Best Practices
Serverless Architecture - Design Patterns and Best Practices
Amazon Web Services
 
Scale up a Web Application (ARC409-R) - AWS re:Invent 2018
Scale up a Web Application (ARC409-R) - AWS re:Invent 2018Scale up a Web Application (ARC409-R) - AWS re:Invent 2018
Scale up a Web Application (ARC409-R) - AWS re:Invent 2018
Amazon Web Services
 
SRV315 Building Enterprise-Grade Serverless Apps
 SRV315 Building Enterprise-Grade Serverless Apps SRV315 Building Enterprise-Grade Serverless Apps
SRV315 Building Enterprise-Grade Serverless Apps
Amazon Web Services
 
Serverless SaaS apllications on AWS
Serverless SaaS apllications on AWSServerless SaaS apllications on AWS
Serverless SaaS apllications on AWS
Amazon Web Services
 
Become a Serverless Black Belt - Optimizing Your Serverless Applications - AW...
Become a Serverless Black Belt - Optimizing Your Serverless Applications - AW...Become a Serverless Black Belt - Optimizing Your Serverless Applications - AW...
Become a Serverless Black Belt - Optimizing Your Serverless Applications - AW...
Amazon Web Services
 
All the Ops you need to know to Dev Serverless
All the Ops you need to know to Dev ServerlessAll the Ops you need to know to Dev Serverless
All the Ops you need to know to Dev Serverless
Chris Munns
 
AWS Lambda use cases and best practices - Builders Day Israel
AWS Lambda use cases and best practices - Builders Day IsraelAWS Lambda use cases and best practices - Builders Day Israel
AWS Lambda use cases and best practices - Builders Day Israel
Amazon Web Services
 
Serverless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversServerless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about servers
Amazon Web Services
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural Patterns
Amazon Web Services
 
Ci/CD for AWS Lambda Projects - JLM CTO Club
Ci/CD for AWS Lambda Projects - JLM CTO ClubCi/CD for AWS Lambda Projects - JLM CTO Club
Ci/CD for AWS Lambda Projects - JLM CTO Club
Boaz Ziniman
 
Serverless on AWS: Architectural Patterns and Best Practices
Serverless on AWS: Architectural Patterns and Best PracticesServerless on AWS: Architectural Patterns and Best Practices
Serverless on AWS: Architectural Patterns and Best Practices
Vladimir Simek
 
Serverless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about serversServerless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about servers
Amazon Web Services
 
Microservices & Data Design
Microservices & Data DesignMicroservices & Data Design
Microservices & Data Design
Amazon Web Services
 
Microservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San FranciscoMicroservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San Francisco
Amazon Web Services
 
Microservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SFMicroservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SF
Amazon Web Services
 
Microservices and Data Design
Microservices and Data DesignMicroservices and Data Design
Microservices and Data Design
AWS Germany
 

Similar to Best Practices for Using AWS Lambda with RDS/RDBMS Solutions (SRV301-R1) - AWS re:Invent 2018 (20)

Serverless use cases with AWS Lambda - More Serverless Event
Serverless use cases with AWS Lambda - More Serverless EventServerless use cases with AWS Lambda - More Serverless Event
Serverless use cases with AWS Lambda - More Serverless Event
 
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
 
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
 
Serverless Architectural Patterns: Collision 2018
Serverless Architectural Patterns: Collision 2018Serverless Architectural Patterns: Collision 2018
Serverless Architectural Patterns: Collision 2018
 
Serverless Architecture - Design Patterns and Best Practices
Serverless Architecture - Design Patterns and Best PracticesServerless Architecture - Design Patterns and Best Practices
Serverless Architecture - Design Patterns and Best Practices
 
Scale up a Web Application (ARC409-R) - AWS re:Invent 2018
Scale up a Web Application (ARC409-R) - AWS re:Invent 2018Scale up a Web Application (ARC409-R) - AWS re:Invent 2018
Scale up a Web Application (ARC409-R) - AWS re:Invent 2018
 
SRV315 Building Enterprise-Grade Serverless Apps
 SRV315 Building Enterprise-Grade Serverless Apps SRV315 Building Enterprise-Grade Serverless Apps
SRV315 Building Enterprise-Grade Serverless Apps
 
Serverless SaaS apllications on AWS
Serverless SaaS apllications on AWSServerless SaaS apllications on AWS
Serverless SaaS apllications on AWS
 
Become a Serverless Black Belt - Optimizing Your Serverless Applications - AW...
Become a Serverless Black Belt - Optimizing Your Serverless Applications - AW...Become a Serverless Black Belt - Optimizing Your Serverless Applications - AW...
Become a Serverless Black Belt - Optimizing Your Serverless Applications - AW...
 
All the Ops you need to know to Dev Serverless
All the Ops you need to know to Dev ServerlessAll the Ops you need to know to Dev Serverless
All the Ops you need to know to Dev Serverless
 
AWS Lambda use cases and best practices - Builders Day Israel
AWS Lambda use cases and best practices - Builders Day IsraelAWS Lambda use cases and best practices - Builders Day Israel
AWS Lambda use cases and best practices - Builders Day Israel
 
Serverless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversServerless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about servers
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural Patterns
 
Ci/CD for AWS Lambda Projects - JLM CTO Club
Ci/CD for AWS Lambda Projects - JLM CTO ClubCi/CD for AWS Lambda Projects - JLM CTO Club
Ci/CD for AWS Lambda Projects - JLM CTO Club
 
Serverless on AWS: Architectural Patterns and Best Practices
Serverless on AWS: Architectural Patterns and Best PracticesServerless on AWS: Architectural Patterns and Best Practices
Serverless on AWS: Architectural Patterns and Best Practices
 
Serverless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about serversServerless Computing: build and run applications without thinking about servers
Serverless Computing: build and run applications without thinking about servers
 
Microservices & Data Design
Microservices & Data DesignMicroservices & Data Design
Microservices & Data Design
 
Microservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San FranciscoMicroservices & Data Design: Database Week San Francisco
Microservices & Data Design: Database Week San Francisco
 
Microservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SFMicroservices & Data Design: Database Week SF
Microservices & Data Design: Database Week SF
 
Microservices and Data Design
Microservices and Data DesignMicroservices and Data Design
Microservices and Data Design
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
Amazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
Amazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
Amazon Web Services
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Amazon Web Services
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
Amazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
Amazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Amazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
Amazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Amazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Best Practices for Using AWS Lambda with RDS/RDBMS Solutions (SRV301-R1) - AWS re:Invent 2018

  • 1. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. SRV301 - Best Practices for using AWS Lambda with RDS-RDBMS solutions Mayank Thakkar Global Life Sciences Solutions Architect AWS S R V 3 0 1 Emma Zhao Software Development Manager AWS
  • 2. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 3. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Typical Solution Architecture AWS Cloud VPC Availability zone 1 Availability zone 2 Private subnet Private subnet Private subnet Private subnet DB Instance DB instance standby Elastic network interface Elastic network interface Lambda Functions Security group Security group
  • 4. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS Lambda with RDS / RDBMS - Best Practices • Use subnets in multiple AZs for ENI configuration • Protects against AZ failure and IP address exhaustion • Lambda relies on ENIs (within your VPC) to connect • Scalability depends on available free IP addresses and ENI limits • ENI startup penalty • Lambda in VPC mode does not have internet access by default. • Add Network Address Translation (NAT) gateway inside the VPC to enable internet access • Avoid DNS resolution of public host names if possible • Adds billable, time consuming resolution.
  • 5. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Problem: Managing Database Connections … Lambda can scale, can your database connections? Is Connection pooling the answer? Generic database
  • 6. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 7. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Time Container A Container B Container C Container D Lambda - Scaling
  • 8. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. How does that affect Connection Pooling?
  • 9. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Connection Pooling with Lambda Use only one connection in a container, at a time Set Connection Pool Size = 1 OR Initialize the connection object “above the handler” (in the global section)
  • 10. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Connection Pooling with Lambda - Challenges • No hook to indicate destruction of Lambda containers • Can not explicitly close connections when the container is recycled • Fall back on Database TTL to clean up connections • Can lead to session leakages • No control over lifecycle of Lambda containers • Can result many connections sitting idle • Different containers for different Lambda functions • No re use of connections across Lambda functions
  • 11. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 12. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 13. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Solution 1a: Account Concurrency Limit Use AWS Organizations to manage your accounts. AWS Account Lambda can help with retries of throttled invocations* * - Only for asynchronous and stream based event sources.
  • 14. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Solution 1b: Function Concurrency Limit Lambda can help with retries of throttled invocations* * - Only for asynchronous and stream based event sources.
  • 15. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Concurrency Limits - Benefits • Lambda Concurrency limit can be set at the account level or at function level. • Simple to set up • Account level limit requires AWS support • AWS Lambda manages retries for throttled invocations*
  • 16. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Concurrency Limits - Challenges • Account Level limit: • Covers Lambdas across the account – Difficult to isolate DB interfacing functions • Possibility of accounts sprawl. • Function Level limit: • Prior knowledge of DB accessing functions required. • Limit should correspond to peak concurrency – prior application behavior knowledge required • Can not spread out connections dynamically, as load across Lambdas varies
  • 17. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 18. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dynamic Connection Management Helper Maintain atomic counter and max count Open / close connections DB operations Do something interesting Generic database Alarm
  • 19. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Demo Code: https://tinyurl.com/lambdards
  • 20. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dynamic Connection Management - Benefits • Scalable solution : depends on Lambda and Amazon DynamoDB • Connections count managed from DB perspective No limit on number of Lambda functions • Can spread DB connections across Lambda functions @ runtime Eliminate choke points and better serve hotspots • Easy update : Control usable connections count through DynamoDB • Use published CloudWatch metrics to react to out-of-connection errors
  • 21. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Dynamic Connection Management - Challenges • No retries of throttled invocations: requires custom solution. • More resources to manage. • No connection re-use. • Slightly increased latency.
  • 22. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Summary • Lambda Scaling Model and Connection pooling do not mix • Use a single connection, initialized in the global section • Solutions and Best Practices: • Account and function level concurrency Limits • Custom Solution: Dynamic Connection Management
  • 23. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. References • AWS Organizations https://aws.amazon.com/organizations/ • AWS Serverless : https://aws.amazon.com/serverless/ • AWS Lambda Container Reuse: https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/ • Lambda - Retries of throttled invocations: http://docs.aws.amazon.com/lambda/latest/dg/concurrent- executions.html#concurrent-execution-safety-limit • Dynamic Connections Manager Sample Code : https://tinyurl.com/lambdards
  • 24. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Questions? Demo Code: https://tinyurl.com/lambdards
  • 25. Thank you! © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Mayank Thakkar Global Life Sciences Solutions Architect AWS Emma Zhao Software Development Manager AWS Demo Code: https://tinyurl.com/lambdards
  • 26. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.