SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS re:INVENT
Best Practices for Using AWS
Lambda with RDS/RDBMS Solutions
M a y a n k T h a k k a r , H C L S S o l u t i o n s A r c h i t e c t
E m m a Z h a o , S o f t w a r e D e v e l o p m e n t M a n a g e r , L a m b d a
D e c e m b e r 1 , 2 0 1 7
S R V 3 2 0
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Problem: Managing database connections
…
AWS Lambda can scale, can your database connections?
Is connection pooling
the answer?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda: The scaling background
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Time
Container A
Container B
Container C
Container D
Lambda—scaling
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How does that affect connection pooling?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Connection pooling with Lambda
• Only one connection is used at a time in a
container
• Connection pool size = 1
• Just initialize a connection object in the
global section of Lambda and use that
connection
OR
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Connection pooling with Lambda —challenges
• No hook to indicate destruction of Lambda containers
• Cannot explicitly close connections when the container is
recycled
• Fall back on database TTL to clean up connections
• No control over lifecycle of Lambda containers
• Can result in many connections sitting idle
• Different containers for different Lambda functions
• No reuse of connections across Lambda functions
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Managing concurrency
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Solution 1
Set concurrency limits
© 2017, 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*
*Refer to references section for details
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Solution 1b: Function concurrency limit
Lambda can help
with retries of
throttled
invocations*
*Refer to references section for details
© 2017, 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 the function level
• Simple to set up
• Account level limit requires AWS support
• AWS Lambda manages retries for throttled
invocations*
© 2017, 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
• Cannot spread out connections dynamically because load
across Lambdas varies
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Solution 2
Dynamic connection management
c u s t o m s o l u t i o n
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Dynamic connection management
Amazon DynamoDB
Helper
Maintain atomic counter
and max count
Open/close
connections
DB operations
Amazon CloudWatch
CloudWatch AlarmDo something interesting
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Dynamic connection management
Demo
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Benefits
• Scalable solution: depends on Lambda and DynamoDB
• Connections count managed from DB perspective
• No limit on number of Lambda functions
• Can spread DB connections across Lambda functions at 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
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Challenges
• No retries of throttled invocations: requires custom
solution
• More resources to manage
• No connection reuse
• Slightly increased latency
© 2017, 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
• Manage concurrency using:
• Account and function level concurrency Limits
• Custom solution: dynamic connection management
© 2017, 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://github.com/awslabs/LambdaRDS-ManageConnections
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Questions
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

진화하는 CloudFront 의 이해와 글로벌 서비스 활용 - 안수일 시니어 솔루션즈 아키텍트, GS NEOTEK :: AWS Summit...
진화하는 CloudFront 의 이해와 글로벌 서비스 활용 - 안수일 시니어 솔루션즈 아키텍트, GS NEOTEK :: AWS Summit...진화하는 CloudFront 의 이해와 글로벌 서비스 활용 - 안수일 시니어 솔루션즈 아키텍트, GS NEOTEK :: AWS Summit...
진화하는 CloudFront 의 이해와 글로벌 서비스 활용 - 안수일 시니어 솔루션즈 아키텍트, GS NEOTEK :: AWS Summit...
 
Introduction to AWS Security
Introduction to AWS SecurityIntroduction to AWS Security
Introduction to AWS Security
 
Aws Architecture Fundamentals
Aws Architecture FundamentalsAws Architecture Fundamentals
Aws Architecture Fundamentals
 
AWS Secrets Manager
AWS Secrets ManagerAWS Secrets Manager
AWS Secrets Manager
 
How to Design a Multi-Region Active-Active Architecture
How to Design a Multi-Region Active-Active ArchitectureHow to Design a Multi-Region Active-Active Architecture
How to Design a Multi-Region Active-Active Architecture
 
AWS Security Hub
AWS Security HubAWS Security Hub
AWS Security Hub
 
Monitoring and Alerting
Monitoring and AlertingMonitoring and Alerting
Monitoring and Alerting
 
Architecting-for-the-cloud-Best-Practices
Architecting-for-the-cloud-Best-PracticesArchitecting-for-the-cloud-Best-Practices
Architecting-for-the-cloud-Best-Practices
 
AWS Route53
AWS Route53AWS Route53
AWS Route53
 
Access Control for the Cloud: AWS Identity and Access Management (IAM) (SEC20...
Access Control for the Cloud: AWS Identity and Access Management (IAM) (SEC20...Access Control for the Cloud: AWS Identity and Access Management (IAM) (SEC20...
Access Control for the Cloud: AWS Identity and Access Management (IAM) (SEC20...
 
Amazon_SNS.pptx
Amazon_SNS.pptxAmazon_SNS.pptx
Amazon_SNS.pptx
 
Aws IAM
Aws IAMAws IAM
Aws IAM
 
AWS Cloud Watch
AWS Cloud WatchAWS Cloud Watch
AWS Cloud Watch
 
Deep Dive on AWS Lambda
Deep Dive on AWS LambdaDeep Dive on AWS Lambda
Deep Dive on AWS Lambda
 
IAM Deep Dive - Custom IAM Policies with Conditions
IAM Deep Dive - Custom IAM Policies with ConditionsIAM Deep Dive - Custom IAM Policies with Conditions
IAM Deep Dive - Custom IAM Policies with Conditions
 
AWS Basics .pdf
AWS Basics .pdfAWS Basics .pdf
AWS Basics .pdf
 
Backing up Amazon EC2 with Amazon EBS Snapshots - June 2017 AWS Online Tech T...
Backing up Amazon EC2 with Amazon EBS Snapshots - June 2017 AWS Online Tech T...Backing up Amazon EC2 with Amazon EBS Snapshots - June 2017 AWS Online Tech T...
Backing up Amazon EC2 with Amazon EBS Snapshots - June 2017 AWS Online Tech T...
 
Aws
AwsAws
Aws
 
Introduction to EC2
Introduction to EC2Introduction to EC2
Introduction to EC2
 
AWS Deployment Best Practices
AWS Deployment Best PracticesAWS Deployment Best Practices
AWS Deployment Best Practices
 

Similar a Best Practices for using AWS Lambda with RDS-RDBMS Solutions (SRV320)

Data Design for Microservices - DevDay Austin 2017 Day 2
Data Design for Microservices - DevDay Austin 2017 Day 2Data Design for Microservices - DevDay Austin 2017 Day 2
Data Design for Microservices - DevDay Austin 2017 Day 2
Amazon Web Services
 
Serverless Architecture and Best Practices
Serverless Architecture and Best PracticesServerless Architecture and Best Practices
Serverless Architecture and Best Practices
Amazon Web Services
 
A Modern Data Architecture for Microservices
A Modern Data Architecture for MicroservicesA Modern Data Architecture for Microservices
A Modern Data Architecture for Microservices
Amazon Web Services
 
Serverless architecture-patterns-and-best-practices
Serverless architecture-patterns-and-best-practicesServerless architecture-patterns-and-best-practices
Serverless architecture-patterns-and-best-practices
saifam
 
How to Build Scalable Serverless Applications
How to Build Scalable Serverless ApplicationsHow to Build Scalable Serverless Applications
How to Build Scalable Serverless Applications
Amazon Web Services
 

Similar a Best Practices for using AWS Lambda with RDS-RDBMS Solutions (SRV320) (20)

Data Design for Microservices - DevDay Austin 2017 Day 2
Data Design for Microservices - DevDay Austin 2017 Day 2Data Design for Microservices - DevDay Austin 2017 Day 2
Data Design for Microservices - DevDay Austin 2017 Day 2
 
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
 
AWSomeDay Zurich 2018 - How to go serverless
AWSomeDay Zurich 2018 - How to go serverless AWSomeDay Zurich 2018 - How to go serverless
AWSomeDay Zurich 2018 - How to go serverless
 
What's New in Serverless - SRV305 - re:Invent 2017
What's New in Serverless - SRV305 - re:Invent 2017What's New in Serverless - SRV305 - re:Invent 2017
What's New in Serverless - SRV305 - re:Invent 2017
 
SRV310_Designing Microservices with Serverless
SRV310_Designing Microservices with ServerlessSRV310_Designing Microservices with Serverless
SRV310_Designing Microservices with Serverless
 
Serverless Architecture and Best Practices
Serverless Architecture and Best PracticesServerless Architecture and Best Practices
Serverless Architecture and Best Practices
 
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWSServerless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
 
Getting started with Serverless on AWS
Getting started with Serverless on AWSGetting started with Serverless on AWS
Getting started with Serverless on AWS
 
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDB
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDBSRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDB
SRV301-Optimizing Serverless Application Data Tiers with Amazon DynamoDB
 
SRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless ApplicationsSRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless Applications
 
A Modern Data Architecture for Microservices
A Modern Data Architecture for MicroservicesA Modern Data Architecture for Microservices
A Modern Data Architecture for Microservices
 
SID301_Using AWS Lambda as a Security Team
SID301_Using AWS Lambda as a Security TeamSID301_Using AWS Lambda as a Security Team
SID301_Using AWS Lambda as a Security Team
 
Serverless: State of The Union I AWS Dev Day 2018
Serverless: State of The Union I AWS Dev Day 2018Serverless: State of The Union I AWS Dev Day 2018
Serverless: State of The Union I AWS Dev Day 2018
 
GPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to MoveGPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
 
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
 
What's New in Serverless
What's New in ServerlessWhat's New in Serverless
What's New in Serverless
 
Serverless architecture-patterns-and-best-practices
Serverless architecture-patterns-and-best-practicesServerless architecture-patterns-and-best-practices
Serverless architecture-patterns-and-best-practices
 
Application Performance Management on AWS
Application Performance Management on AWSApplication Performance Management on AWS
Application Performance Management on AWS
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural Patterns
 
How to Build Scalable Serverless Applications
How to Build Scalable Serverless ApplicationsHow to Build Scalable Serverless Applications
How to Build Scalable Serverless Applications
 

Más de 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 AWS
Amazon 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 Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon 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
 

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

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

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
 
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...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
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
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 

Best Practices for using AWS Lambda with RDS-RDBMS Solutions (SRV320)

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS re:INVENT Best Practices for Using AWS Lambda with RDS/RDBMS Solutions M a y a n k T h a k k a r , H C L S S o l u t i o n s A r c h i t e c t E m m a Z h a o , S o f t w a r e D e v e l o p m e n t M a n a g e r , L a m b d a D e c e m b e r 1 , 2 0 1 7 S R V 3 2 0
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Problem: Managing database connections … AWS Lambda can scale, can your database connections? Is connection pooling the answer?
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda: The scaling background
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Time Container A Container B Container C Container D Lambda—scaling
  • 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How does that affect connection pooling?
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Connection pooling with Lambda • Only one connection is used at a time in a container • Connection pool size = 1 • Just initialize a connection object in the global section of Lambda and use that connection OR
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Connection pooling with Lambda —challenges • No hook to indicate destruction of Lambda containers • Cannot explicitly close connections when the container is recycled • Fall back on database TTL to clean up connections • No control over lifecycle of Lambda containers • Can result in many connections sitting idle • Different containers for different Lambda functions • No reuse of connections across Lambda functions
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Managing concurrency
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Solution 1 Set concurrency limits
  • 10. © 2017, 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* *Refer to references section for details
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Solution 1b: Function concurrency limit Lambda can help with retries of throttled invocations* *Refer to references section for details
  • 12. © 2017, 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 the function level • Simple to set up • Account level limit requires AWS support • AWS Lambda manages retries for throttled invocations*
  • 13. © 2017, 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 • Cannot spread out connections dynamically because load across Lambdas varies
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Solution 2 Dynamic connection management c u s t o m s o l u t i o n
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Dynamic connection management Amazon DynamoDB Helper Maintain atomic counter and max count Open/close connections DB operations Amazon CloudWatch CloudWatch AlarmDo something interesting
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Dynamic connection management Demo
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Benefits • Scalable solution: depends on Lambda and DynamoDB • Connections count managed from DB perspective • No limit on number of Lambda functions • Can spread DB connections across Lambda functions at 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
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Challenges • No retries of throttled invocations: requires custom solution • More resources to manage • No connection reuse • Slightly increased latency
  • 19. © 2017, 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 • Manage concurrency using: • Account and function level concurrency Limits • Custom solution: dynamic connection management
  • 20. © 2017, 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://github.com/awslabs/LambdaRDS-ManageConnections
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Questions
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you!