SlideShare a Scribd company logo
#MDBW17
Overview, best practices
BUILDING SERVERLESS APPS
WITH MONGODB ATLAS, AWS
LAMBDA AND STEP FUNCTIONS
#MDBW17
RAPHAEL LONDNER
Developer Advocate,
MongoDB
PAUL SEARS
Solutions Architect,
AWS
paulsear@amazon.com
@rlondner
#MDBW17
AGENDA
• Lambda overview and common use cases
• Lambda code deep dive
• Lambda demo with MongoDB Atlas
• Lambda best practices
• Step Functions
• Step Functions demo
AWS LAMBDA
OVERVIEW
#MDBW17
SERVERLESS COMPUTING - AWS LAMBDA
Run code without provisioning or managing servers – pay only for the
compute time you consume.
#MDBW17
Continuous ScalingNo Servers to
Manage
Subsecond
Metering
BENEFITS OF AWS LAMBDA
AWS Lambda handles:
• Operations and
management
• Provisioning and utilization
• Scaling
• Availability and fault
tolerance
Automatically scales your
application, running code in
response to each trigger
Your code runs in parallel and
processes each trigger
individually, scaling precisely
with the size of the workload
Pricing
• CPU and Network
scaled based on
RAM (128 MB to
1500 MB)
• $0.20 per
1M requests
• Price per 100ms
#MDBW17
AWS LAMBDA USE CASES
• Web applications
• Data processing (real-time streaming analytics)
• Scalable back ends (mobile apps, IoT devices)
• Amazon Alexa
• Chatbots
#MDBW17
Web
Applications
• Static
websites
• Complex web
apps
• Packages for
Flask and
Express
Data
Processing
• Real time
• MapReduce
• Batch
Chatbots
• Powering
chatbot logic
Backends
• Apps &
services
• Mobile
• IoT
</></>
Amazon
Alexa
• Powering
voice-enabled
apps
• Alexa Skills Kit
Autonomous
IT
• Policy engines
• Extending
AWS services
• Infrastructure
management
Data processing: Lambda + S3
COMMON USE CASES
#MDBW17
Data
Processing
• Real time
• MapReduce
• Batch
Data processing: Lambda + Kinesis
COMMON USE CASES
#MDBW17
Web
Applications
• Static
websites
• Complex web
apps
• Packages for
Flask and
Express
Data
Processing
• Real time
• MapReduce
• Batch
Chatbots
• Powering
chatbot logic
Backends
• Apps &
services
• Mobile
• IoT
</></>
Amazon
Alexa
• Powering
voice-enabled
apps
• Alexa Skills Kit
Autonomous
IT
• Policy engines
• Extending
AWS services
• Infrastructure
management
COMMON USE CASES
#MDBW17
Web
Applications
• Static
websites
• Complex web
apps
• Packages for
Flask and
Express
Data
Processing
• Real time
• MapReduce
• Batch
Chatbots
• Powering
chatbot logic
Backends
• Apps &
services
• Mobile
• IoT
</></>
Amazon
Alexa
• Powering
voice-enabled
apps
• Alexa Skills Kit
Autonomous
IT
• Policy engines
• Extending
AWS services
• Infrastructure
management
COMMON USE CASES
CODE DEEP DIVE
#MDBW17
COMPONENTS OF A SERVERLESS APP
EVENT SOURCE
Requests to
endpoints
Changes in
resource state
FUNCTION SERVICES
#MDBW17
ANATOMY OF A LAMBDA FUNCTION
• Handler function (or method)
• An input parameter
‒ Integer, double, string, JSON…
• A context parameter
‒ Provides information such as
o Remaining time until timeout, log group and stream, request ID, etc…
‒ Exposes public properties
• A return value (optional)
#MDBW17
ANATOMY OF A LAMBDA FUNCTION (NODE.JS)
• Handler function in index.js
exports.myHandler = function(event, context, callback)
=> {…}
• Handler format in AWS Lambda: [moduleName].[functionName]
index.myHandler
#MDBW17
ANATOMY OF A LAMBDA FUNCTION (JAVA)
• Handler function in example.Hello class
package example;
public class Hello {
public String myHandler(type inputVal, Context context) {...}
• Handler format in Lambda: [package].[className]::[functionName]
#MDBW17
ANATOMY OF A LAMBDA FUNCTION (PYTHON)
• Handler function in hello_python.py file
def my_handler(event, context):
…
return some_value
• Handler format in Lambda: [fileName].[functionName]
#MDBW17
ANATOMY OF A LAMBDA FUNCTION (C#)
• Handler function in Example.Hello
namespace Example;
public class Hello {
public Stream MyHandler(type inputVal, ILambdaContext context) {...}
• Handler forma in Lambda:
[assemblyName]::[namespace].[className]::[methodName]
#MDBW17
HOW TO DEVELOP FOR LAMBDA & ATLAS
IN NODE.JS
Sign up for
Atlas
Create
a
cluster
Copy cluster
URI to a safe
location
Create
a DB
user
Init a
Node
project
Write code!
Import
MongoDB
Node driver
#MDBW17
HOW TO TEST AND DEPLOY YOUR LAMBDA
Upload your
package to
AWS Lambda
Use lambda-
local to test
locally
Zip your
Node.js
code
Create
your
Lambda
function
Set env.
variables,
memory,
security…
Test in AWS
(Console,
API
Gateway)
LAMBDA DEMO
BIT.LY/LAMBDATUTORIAL
AWS BEST PRACTICES
#MDBW17
BEST PRACTICES: LAMBDA FUNCTION
ü Use the right “timeout”
ü Utilize the functions local storage which is 500MB in size in the /tmp
ü Lower costs and improve performance by minimizing the use of startup code
not directly related to processing the current event
ü Use the built-in CloudWatch monitoring of your Lambda functions to view and
optimize request latencies
#MDBW17
THINGS TO REMEMBER: LAMBDA FUNCTION
ü Memory = “Power level”
q Higher levels offer more memory and more CPU power
ü Functions don’t have a notion of state
q Use MongoDB Atlas, S3, or Elasticache, or AWS Step Functions
q Wrap your config in a function and call it from your published code
ü Use the right access control for downstream services
q IAM roles and permissions for AWS services
q VPC for private endpoints
q KMS for storing credentials for downstream endpoints
#MDBW17
THINGS TO REMEMBER: LAMBDA
APPLICATION
ü Lambda scales by events/requests
q Plan for concurrent request rate on downstream services
ü Shared scaling responsibility for VPC enabled functions
q Sufficient IPs to match your expected concurrency
q at least one subnet in each availability zone
ü Retries are built in for asynchronous and Stream invokes
q Plan for retries for synchronous applications
#MDBW17
WHERE NOT TO CONSIDER LAMBDA (TODAY)
• Large software dependencies: Custom software applications with
licensing agreements such as MS-Office document processing, EDA
tools, Oracle databases, etc.
• OS dependencies: Software packages or applications which rely on
calling underlying Windows RPCs
• Custom hardware: GPU acceleration, hardware affinity
ATLAS WITH AWS
BEST PRACTICES
#MDBW17
AWS LAMBDA WITH MONGODB ATLAS
• Store database connection string in an environment variable
‒ Use –E parameter with lambda-local
‒ Reference it with process.env['MONGODB_ATLAS_URI']
• Encrypt database connection string in AWS Lambda
‒ Use AWS.KMS() to decrypt() the connection string
#MDBW17
PERFORMANCE BEST PRACTICES WITH NODE.JS
• Declare the db object outside the handler method
• Do NOT close the db object!
• Set context.callbackWaitsForEmptyEventLoop to
‘false’
• Try to re-use the db object if
db.serverConfig.isConnected() returns true
LAMBDA
BEST PRACTICES
DEMO
AWS STEP
FUNCTIONS
#MDBW17
λλ
λ
DBMS
λ
λ
λ
λ
λ
λ λ
λ
λ
Queue
MODERN
APP
#MDBW17
MODERN
APP
#MDBW17
“I WANT TO SEQUENCE FUNCTIONS”
“I want to select functions based on data”
“I want to retry functions”
“I want try/catch/finally”
Turning functions into apps
“I have code that runs for hours”
“I want to run functions in parallel”
#MDBW17
BENEFITS OF AWS STEP FUNCTIONS
Diagnose and debug
problems faster
Adapt to change
Easy to connect and
coordinate
distributed components and
microservices to quickly
create apps
Manages the operations
and infrastructure of
service coordination to
ensure availability at
scale, and
under failure
Productivity Agility Resilience
#MDBW17
RUN EACH STEP IN SEQUENCE
Vendor A
Vendor B
Vendor C
#MDBW17
…AND UNWIND IF MY PLANS FAIL AT ANY POINT
Vendor A
Vendor B
Vendor C
#MDBW17
COORDINATION MUST-HAVES
• Scales out
• Doesn’t lose state
• Deals with errors/timeouts
• Easy to build & operate
• Auditable
#MDBW17
APPLICATION LIFECYCLE IN AWS STEP FUNCTIONS
Visualize in the
Console
Define in JSON Monitor
Executions
DEFINE IN JSON AND THEN VISUALIZE IN THE
CONSOLE• {
• ”Comment”: “Hello World Example",
• "StartAt” : "HelloWorld”,
• "States” : {
• "HelloWorld” : {
• "Type” : "Task",
• "Resource” :
"arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTI
ON_NAME”,
• "End” : true
• }
• }
#MDBW17
EXECUTE ONE OR ONE MILLION
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
#MDBW17
MONITOR EXECUTIONS FROM THE CONSOLE
#MDBW17
SEVEN STATE TYPES
Task A single unit of work
Choice Adds branching logic
Parallel Fork and join the data across tasks
Wait Delay for a specified time
Fail
Stops an execution and marks it as a
failure
Succeed Stops an execution successfully
Pass Passes its input to its output
#MDBW17
BUILD VISUAL WORKFLOWS FROM STATE TYPES
Task
Choice
Fail
Parallel
#MDBW17
STEP FUNCTIONS: CUSTOMER USE-CASES
• Workflow/Order management
• Batch processing
• Shell-script replacement
• Enterprise application workflows
• Data gathering and processing
#MDBW17
INTEGRATE WITH OTHER AWS SERVICES
• Create state machines and Activities with AWS CloudFormation
• Call Step Functions with Amazon API Gateway
• Start state machines in response to events or on a schedule with
CloudWatch Events
• Monitor state machine executions with CloudWatch
• Log API calls with CloudTrail
STEP FUNCTIONS
DEMO
BIT.LY/SFTUTORIAL
#MDBW17
#MDBW17
FOLLOW-ON SESSION
• What: MongoDB Atlas and Serverless Architectures
• When: Wednesday, June 21 at 4.30PM
• Where: Crystal A
• Who: Tosin Ajayi, Sr. Solutions Architect
#MDBW17
REFERENCE LINKS
• Serverless development with Node.js, Lambda and MongoDB Atlas
• Optimizing AWS Lambda performance with MongoDB Atlas and
Node.js
• Step Functions with MongoDB Atlas Part 1
• Step Functions with MongoDB Atlas Part 2
• Lambda with MongoDB GitHub repository
• Step Functions with MongoDB GitHub repository
BUILDING Serverless apps with MongoDB AtLAS, AWS Lambda and Step Functions
Ad

More Related Content

What's hot (11)

What is AWS lambda?
What is AWS lambda?What is AWS lambda?
What is AWS lambda?
Whizlabs
 
Bridging the Gap: Connecting AWS and Kafka
Bridging the Gap: Connecting AWS and KafkaBridging the Gap: Connecting AWS and Kafka
Bridging the Gap: Connecting AWS and Kafka
Pengfei (Jason) Li
 
Building resilient serverless systems with non serverless components
Building resilient serverless systems with non serverless componentsBuilding resilient serverless systems with non serverless components
Building resilient serverless systems with non serverless components
Jeremy Daly
 
How to fail with serverless
How to fail with serverlessHow to fail with serverless
How to fail with serverless
Jeremy Daly
 
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache KafkaExploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Lightbend
 
Infinite Scaling using Lambda and Aws - Atlogys Tech Talk
Infinite Scaling using Lambda and Aws - Atlogys Tech TalkInfinite Scaling using Lambda and Aws - Atlogys Tech Talk
Infinite Scaling using Lambda and Aws - Atlogys Tech Talk
Atlogys Technical Consulting
 
Serverless Architecture Patterns - Manoj Ganapathi
Serverless Architecture Patterns - Manoj GanapathiServerless Architecture Patterns - Manoj Ganapathi
Serverless Architecture Patterns - Manoj Ganapathi
CodeOps Technologies LLP
 
AWS Jungle - Lambda
AWS Jungle - LambdaAWS Jungle - Lambda
AWS Jungle - Lambda
Squash Apps Pvt Ltd
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
ecobold
 
AWS Lambda
AWS LambdaAWS Lambda
AWS Lambda
Muhammed YALÇIN
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
Lecole Cole
 
What is AWS lambda?
What is AWS lambda?What is AWS lambda?
What is AWS lambda?
Whizlabs
 
Bridging the Gap: Connecting AWS and Kafka
Bridging the Gap: Connecting AWS and KafkaBridging the Gap: Connecting AWS and Kafka
Bridging the Gap: Connecting AWS and Kafka
Pengfei (Jason) Li
 
Building resilient serverless systems with non serverless components
Building resilient serverless systems with non serverless componentsBuilding resilient serverless systems with non serverless components
Building resilient serverless systems with non serverless components
Jeremy Daly
 
How to fail with serverless
How to fail with serverlessHow to fail with serverless
How to fail with serverless
Jeremy Daly
 
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache KafkaExploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Lightbend
 
Infinite Scaling using Lambda and Aws - Atlogys Tech Talk
Infinite Scaling using Lambda and Aws - Atlogys Tech TalkInfinite Scaling using Lambda and Aws - Atlogys Tech Talk
Infinite Scaling using Lambda and Aws - Atlogys Tech Talk
Atlogys Technical Consulting
 
Serverless Architecture Patterns - Manoj Ganapathi
Serverless Architecture Patterns - Manoj GanapathiServerless Architecture Patterns - Manoj Ganapathi
Serverless Architecture Patterns - Manoj Ganapathi
CodeOps Technologies LLP
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
ecobold
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
Lecole Cole
 

Similar to BUILDING Serverless apps with MongoDB AtLAS, AWS Lambda and Step Functions (14)

AWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialAWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
MongoDB
 
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB AtlasWebinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
MongoDB
 
Contruyendo tu primera aplicación con AWS
Contruyendo tu primera aplicación con AWSContruyendo tu primera aplicación con AWS
Contruyendo tu primera aplicación con AWS
Amazon Web Services LATAM
 
Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless Cloud
Ian Massingham
 
AWS Lambda Functions A Comprehensive Guide
AWS Lambda Functions A Comprehensive GuideAWS Lambda Functions A Comprehensive Guide
AWS Lambda Functions A Comprehensive Guide
Inexture Solutions
 
Introduction to AWS lambda & Serverless Application1.pptx
Introduction to AWS lambda & Serverless Application1.pptxIntroduction to AWS lambda & Serverless Application1.pptx
Introduction to AWS lambda & Serverless Application1.pptx
Mohammed Shefeeq
 
What’s new in serverless - re:Invent 2020
What’s new in serverless - re:Invent 2020What’s new in serverless - re:Invent 2020
What’s new in serverless - re:Invent 2020
AWS Chicago
 
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Vadym Kazulkin
 
Aws lambda and accesing AWS RDS - Clouddictive
Aws lambda and accesing AWS RDS - ClouddictiveAws lambda and accesing AWS RDS - Clouddictive
Aws lambda and accesing AWS RDS - Clouddictive
Clouddictive
 
Serverless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best PracticesServerless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best Practices
Daniel Zivkovic
 
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Serverless APIs with JavaScript - Matt Searle - ChocPandaServerless APIs with JavaScript - Matt Searle - ChocPanda
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Paul Dykes
 
DevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureDevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless Architecture
Mikhail Prudnikov
 
Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2
kartraj
 
AWS Accelerated Program - Session 3 - Serverless Services.pptx
AWS Accelerated Program - Session 3 - Serverless Services.pptxAWS Accelerated Program - Session 3 - Serverless Services.pptx
AWS Accelerated Program - Session 3 - Serverless Services.pptx
DipaliKulshrestha2
 
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialAWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
MongoDB
 
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB AtlasWebinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
MongoDB
 
Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless Cloud
Ian Massingham
 
AWS Lambda Functions A Comprehensive Guide
AWS Lambda Functions A Comprehensive GuideAWS Lambda Functions A Comprehensive Guide
AWS Lambda Functions A Comprehensive Guide
Inexture Solutions
 
Introduction to AWS lambda & Serverless Application1.pptx
Introduction to AWS lambda & Serverless Application1.pptxIntroduction to AWS lambda & Serverless Application1.pptx
Introduction to AWS lambda & Serverless Application1.pptx
Mohammed Shefeeq
 
What’s new in serverless - re:Invent 2020
What’s new in serverless - re:Invent 2020What’s new in serverless - re:Invent 2020
What’s new in serverless - re:Invent 2020
AWS Chicago
 
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Production Ready Serverless Java Applications in 3 Weeks AWS UG Cologne Febru...
Vadym Kazulkin
 
Aws lambda and accesing AWS RDS - Clouddictive
Aws lambda and accesing AWS RDS - ClouddictiveAws lambda and accesing AWS RDS - Clouddictive
Aws lambda and accesing AWS RDS - Clouddictive
Clouddictive
 
Serverless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best PracticesServerless Architectural Patterns & Best Practices
Serverless Architectural Patterns & Best Practices
Daniel Zivkovic
 
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Serverless APIs with JavaScript - Matt Searle - ChocPandaServerless APIs with JavaScript - Matt Searle - ChocPanda
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Paul Dykes
 
DevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureDevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless Architecture
Mikhail Prudnikov
 
Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2
kartraj
 
AWS Accelerated Program - Session 3 - Serverless Services.pptx
AWS Accelerated Program - Session 3 - Serverless Services.pptxAWS Accelerated Program - Session 3 - Serverless Services.pptx
AWS Accelerated Program - Session 3 - Serverless Services.pptx
DipaliKulshrestha2
 
Ad

Recently uploaded (20)

Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Cryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptxCryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptx
riyageorge2024
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Innovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at allInnovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at all
ayeshakanwal75
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025
younisnoman75
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Creating Automated Tests with AI - Cory House - Applitools.pdf
Creating Automated Tests with AI - Cory House - Applitools.pdfCreating Automated Tests with AI - Cory House - Applitools.pdf
Creating Automated Tests with AI - Cory House - Applitools.pdf
Applitools
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Cryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptxCryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptx
riyageorge2024
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Innovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at allInnovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at all
ayeshakanwal75
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025
younisnoman75
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Creating Automated Tests with AI - Cory House - Applitools.pdf
Creating Automated Tests with AI - Cory House - Applitools.pdfCreating Automated Tests with AI - Cory House - Applitools.pdf
Creating Automated Tests with AI - Cory House - Applitools.pdf
Applitools
 
Ad

BUILDING Serverless apps with MongoDB AtLAS, AWS Lambda and Step Functions

  • 1. #MDBW17 Overview, best practices BUILDING SERVERLESS APPS WITH MONGODB ATLAS, AWS LAMBDA AND STEP FUNCTIONS
  • 3. #MDBW17 AGENDA • Lambda overview and common use cases • Lambda code deep dive • Lambda demo with MongoDB Atlas • Lambda best practices • Step Functions • Step Functions demo
  • 5. #MDBW17 SERVERLESS COMPUTING - AWS LAMBDA Run code without provisioning or managing servers – pay only for the compute time you consume.
  • 6. #MDBW17 Continuous ScalingNo Servers to Manage Subsecond Metering BENEFITS OF AWS LAMBDA AWS Lambda handles: • Operations and management • Provisioning and utilization • Scaling • Availability and fault tolerance Automatically scales your application, running code in response to each trigger Your code runs in parallel and processes each trigger individually, scaling precisely with the size of the workload Pricing • CPU and Network scaled based on RAM (128 MB to 1500 MB) • $0.20 per 1M requests • Price per 100ms
  • 7. #MDBW17 AWS LAMBDA USE CASES • Web applications • Data processing (real-time streaming analytics) • Scalable back ends (mobile apps, IoT devices) • Amazon Alexa • Chatbots
  • 8. #MDBW17 Web Applications • Static websites • Complex web apps • Packages for Flask and Express Data Processing • Real time • MapReduce • Batch Chatbots • Powering chatbot logic Backends • Apps & services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit Autonomous IT • Policy engines • Extending AWS services • Infrastructure management Data processing: Lambda + S3 COMMON USE CASES
  • 9. #MDBW17 Data Processing • Real time • MapReduce • Batch Data processing: Lambda + Kinesis COMMON USE CASES
  • 10. #MDBW17 Web Applications • Static websites • Complex web apps • Packages for Flask and Express Data Processing • Real time • MapReduce • Batch Chatbots • Powering chatbot logic Backends • Apps & services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit Autonomous IT • Policy engines • Extending AWS services • Infrastructure management COMMON USE CASES
  • 11. #MDBW17 Web Applications • Static websites • Complex web apps • Packages for Flask and Express Data Processing • Real time • MapReduce • Batch Chatbots • Powering chatbot logic Backends • Apps & services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit Autonomous IT • Policy engines • Extending AWS services • Infrastructure management COMMON USE CASES
  • 13. #MDBW17 COMPONENTS OF A SERVERLESS APP EVENT SOURCE Requests to endpoints Changes in resource state FUNCTION SERVICES
  • 14. #MDBW17 ANATOMY OF A LAMBDA FUNCTION • Handler function (or method) • An input parameter ‒ Integer, double, string, JSON… • A context parameter ‒ Provides information such as o Remaining time until timeout, log group and stream, request ID, etc… ‒ Exposes public properties • A return value (optional)
  • 15. #MDBW17 ANATOMY OF A LAMBDA FUNCTION (NODE.JS) • Handler function in index.js exports.myHandler = function(event, context, callback) => {…} • Handler format in AWS Lambda: [moduleName].[functionName] index.myHandler
  • 16. #MDBW17 ANATOMY OF A LAMBDA FUNCTION (JAVA) • Handler function in example.Hello class package example; public class Hello { public String myHandler(type inputVal, Context context) {...} • Handler format in Lambda: [package].[className]::[functionName]
  • 17. #MDBW17 ANATOMY OF A LAMBDA FUNCTION (PYTHON) • Handler function in hello_python.py file def my_handler(event, context): … return some_value • Handler format in Lambda: [fileName].[functionName]
  • 18. #MDBW17 ANATOMY OF A LAMBDA FUNCTION (C#) • Handler function in Example.Hello namespace Example; public class Hello { public Stream MyHandler(type inputVal, ILambdaContext context) {...} • Handler forma in Lambda: [assemblyName]::[namespace].[className]::[methodName]
  • 19. #MDBW17 HOW TO DEVELOP FOR LAMBDA & ATLAS IN NODE.JS Sign up for Atlas Create a cluster Copy cluster URI to a safe location Create a DB user Init a Node project Write code! Import MongoDB Node driver
  • 20. #MDBW17 HOW TO TEST AND DEPLOY YOUR LAMBDA Upload your package to AWS Lambda Use lambda- local to test locally Zip your Node.js code Create your Lambda function Set env. variables, memory, security… Test in AWS (Console, API Gateway)
  • 24. #MDBW17 BEST PRACTICES: LAMBDA FUNCTION ü Use the right “timeout” ü Utilize the functions local storage which is 500MB in size in the /tmp ü Lower costs and improve performance by minimizing the use of startup code not directly related to processing the current event ü Use the built-in CloudWatch monitoring of your Lambda functions to view and optimize request latencies
  • 25. #MDBW17 THINGS TO REMEMBER: LAMBDA FUNCTION ü Memory = “Power level” q Higher levels offer more memory and more CPU power ü Functions don’t have a notion of state q Use MongoDB Atlas, S3, or Elasticache, or AWS Step Functions q Wrap your config in a function and call it from your published code ü Use the right access control for downstream services q IAM roles and permissions for AWS services q VPC for private endpoints q KMS for storing credentials for downstream endpoints
  • 26. #MDBW17 THINGS TO REMEMBER: LAMBDA APPLICATION ü Lambda scales by events/requests q Plan for concurrent request rate on downstream services ü Shared scaling responsibility for VPC enabled functions q Sufficient IPs to match your expected concurrency q at least one subnet in each availability zone ü Retries are built in for asynchronous and Stream invokes q Plan for retries for synchronous applications
  • 27. #MDBW17 WHERE NOT TO CONSIDER LAMBDA (TODAY) • Large software dependencies: Custom software applications with licensing agreements such as MS-Office document processing, EDA tools, Oracle databases, etc. • OS dependencies: Software packages or applications which rely on calling underlying Windows RPCs • Custom hardware: GPU acceleration, hardware affinity
  • 28. ATLAS WITH AWS BEST PRACTICES
  • 29. #MDBW17 AWS LAMBDA WITH MONGODB ATLAS • Store database connection string in an environment variable ‒ Use –E parameter with lambda-local ‒ Reference it with process.env['MONGODB_ATLAS_URI'] • Encrypt database connection string in AWS Lambda ‒ Use AWS.KMS() to decrypt() the connection string
  • 30. #MDBW17 PERFORMANCE BEST PRACTICES WITH NODE.JS • Declare the db object outside the handler method • Do NOT close the db object! • Set context.callbackWaitsForEmptyEventLoop to ‘false’ • Try to re-use the db object if db.serverConfig.isConnected() returns true
  • 35. #MDBW17 “I WANT TO SEQUENCE FUNCTIONS” “I want to select functions based on data” “I want to retry functions” “I want try/catch/finally” Turning functions into apps “I have code that runs for hours” “I want to run functions in parallel”
  • 36. #MDBW17 BENEFITS OF AWS STEP FUNCTIONS Diagnose and debug problems faster Adapt to change Easy to connect and coordinate distributed components and microservices to quickly create apps Manages the operations and infrastructure of service coordination to ensure availability at scale, and under failure Productivity Agility Resilience
  • 37. #MDBW17 RUN EACH STEP IN SEQUENCE Vendor A Vendor B Vendor C
  • 38. #MDBW17 …AND UNWIND IF MY PLANS FAIL AT ANY POINT Vendor A Vendor B Vendor C
  • 39. #MDBW17 COORDINATION MUST-HAVES • Scales out • Doesn’t lose state • Deals with errors/timeouts • Easy to build & operate • Auditable
  • 40. #MDBW17 APPLICATION LIFECYCLE IN AWS STEP FUNCTIONS Visualize in the Console Define in JSON Monitor Executions
  • 41. DEFINE IN JSON AND THEN VISUALIZE IN THE CONSOLE• { • ”Comment”: “Hello World Example", • "StartAt” : "HelloWorld”, • "States” : { • "HelloWorld” : { • "Type” : "Task", • "Resource” : "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTI ON_NAME”, • "End” : true • } • }
  • 42. #MDBW17 EXECUTE ONE OR ONE MILLION Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld
  • 44. #MDBW17 SEVEN STATE TYPES Task A single unit of work Choice Adds branching logic Parallel Fork and join the data across tasks Wait Delay for a specified time Fail Stops an execution and marks it as a failure Succeed Stops an execution successfully Pass Passes its input to its output
  • 45. #MDBW17 BUILD VISUAL WORKFLOWS FROM STATE TYPES Task Choice Fail Parallel
  • 46. #MDBW17 STEP FUNCTIONS: CUSTOMER USE-CASES • Workflow/Order management • Batch processing • Shell-script replacement • Enterprise application workflows • Data gathering and processing
  • 47. #MDBW17 INTEGRATE WITH OTHER AWS SERVICES • Create state machines and Activities with AWS CloudFormation • Call Step Functions with Amazon API Gateway • Start state machines in response to events or on a schedule with CloudWatch Events • Monitor state machine executions with CloudWatch • Log API calls with CloudTrail
  • 51. #MDBW17 FOLLOW-ON SESSION • What: MongoDB Atlas and Serverless Architectures • When: Wednesday, June 21 at 4.30PM • Where: Crystal A • Who: Tosin Ajayi, Sr. Solutions Architect
  • 52. #MDBW17 REFERENCE LINKS • Serverless development with Node.js, Lambda and MongoDB Atlas • Optimizing AWS Lambda performance with MongoDB Atlas and Node.js • Step Functions with MongoDB Atlas Part 1 • Step Functions with MongoDB Atlas Part 2 • Lambda with MongoDB GitHub repository • Step Functions with MongoDB GitHub repository