SlideShare a Scribd company logo
Serverless Architectures with
AWS Lambda and MongoDB Atlas
Ashley Townsend
Senior Solutions Architect
Serverless?
• Landscape
• Use cases
Going Serverless
• What changes?
• Considerations
• MongoDB Atlas
AWS & MongoDB Atlas
• Simple API for Customer Single View
• Lambda & API Gateway
• MongoDB Atlas & Compass
• Postman
Agenda
Serverless
Big Iron Commodity
Hardware
Virtualized Containers Functions
Where will my code run?
Serverless Frameworks and Platforms
https://github.com/serverless/serverless
https://www.zappa.io/
Chalice (awslabs)
https://github.com/awslabs/chalice
Frameworks for Cloud
providers
On-Prem PaaS -
Now offering FaaS
1. Cloud services have matured
2. BaaS à “SaaS-ification”
3. API’s are the glue
4. Containers – now per function
5. SysOps à DevOps à NoOps
Less Ops, More Engineering
5 factors fueling Serverless Computing
https://www.forbes.com/sites/janakirammsv/2016/02/28/five-factors-that-are-fueling-serverless-computing-part-1
Thoughtworks
Technology Radar
Scheduled Jobs
• Sequencing / Orchestration (AWS Steps?)
Data Quality
• Trigger à Identify à Pass to function
Micro or Nano services
• Clicks or Taps
Event and IoT processing
• Don’t worry about scaling App Servers
Lightweight API’s
• Focus of today!
Good fit for Serverless?
Microservices
Before and After
Container-based Microservices
Payments
Service
Product Catalog
Service
Shopping Cart
Service
Domains
https://www.mongodb.com/blog/post/serverless-architectures-the-evolution-of-cloud-computing
Serverless Microservices
Command
Query
Responsibility
Segregation
Think about:
Fine or course grained
Shared logic
Start-up time!
Packaging
Deployment
Versioning
CQRS pattern on Serverless Microservices
GET
API
PUT PATCH
POST DELETE …
API
API Key
API Key
Lambda Function(s)
Lambda Function(s)
Code
Code
Lambda Function(s)
VPC
Peering
Shape
• Person
• Insurance Policies
• Shape changes per policy type
• Addresses
Operations via API
• GET Customers with soon-to-expire policies,
within a geo radius
• GET Customers / by SSN, id, etc.
• PATCH Update basic contact info (cell, email, …)
Customer Single View - Insurance Industry (hypothetical)
High-level architecture of a
single view platform
MongoDB Atlas & AWS
Required MongoDB Services – Atlas!
mgeneratejs
• https://github.com/rueckstiess/mgeneratejs
• npm install -g mgeneratejs
• Create template – generate data
• Upload to Atlas via mongoimport
• Hint: get connection string from Atlas UI!
• Browse with Compass
Generate dataset
Template (InsuranceC360_Customers.json)
mgeneratejs -n 100 InsuranceC360_Customers.json | mongoimport --host
”YOUR ATLAS CLUSTER" --numInsertionWorkers 4
--db WebinarCustomerSingleView --collection Customers --
authenticationDatabase admin --ssl --username YOURUSER --password
YOURPASSWORD
IAM
• Role with Lambda execute policies
VPC
• VPC
• Security Groups – traffic rules
• Internet Gateway – outside communication
• VPC Peering Connection - Route Table
Required AWS Services
Lambda
• VPC, Security Group and IAM role
• Develop inline or upload deployment
package (.zip)
• Use MongoDB Driver – connect with
MongoDB Atlas
API Gateway
• API definition
• API Keys & Usage Plans
• Resources and HTTP Methods
• Map Routes to Lambda functions
VPC
MongoDB Atlas
• Provision a Cluster – M10+ à need an assigned AWS region for VPC peer
• Same AWS region – (I will use us-west-2)
• Initiate VPC peer with AWS
AWS VPC
• Accept incoming Peering Connection
• Update Route Table
EC2
• Install MongoDB
• Test connection from the MongoDB Shell to ensure VPC Peer is working
• Optional but highly recommended – ensure VPC Peering is working before proceeding to Lambda
MongoDB Atlas peered with your AWS VPC
VPC Peering
Atlas AWS
VPC Peering
Atlas AWS
VPC Peering
Atlas AWS
VPC Peering
Atlas AWS
Security Group
Peering Connections
Verify VPC Peer works
Lambda
Role with lambda permissions (IAM)
Code packaging
from __future__ import print_function
import json
import pymongo
print('Loading function')
print(’=== CONNECTING TO MONGODB ATLAS ===')
connstr = ”ENTER YOUR MONGODB ATLAS CONNECTION HERE"
MONGOCLIENT = pymongo.MongoClient(connstr,
readPreference=’secondaryPreferred’)
def GET_lambda_handler(event, context):
… implement GET logic
def POST_lambda_handler(event, context):
… implement POST logic
http://docs.aws.amazon.com/lambda/latest/dg/lambda
-python-how-to-create-deployment-package.html
Lambda functions
Upload &
configure function
The handler function
The role with lambda permissions
The VPC (peered with Atlas)
The security group that allows traffic
At least 2 subnets
The code:
API Gateway
Recap: What we said we would do
High-level architecture of a
single view platform
Recap: What we said we would do
GET
API
PUT PATCH
POST DELETE …
API
API Key
API Key
Lambda
Function(s)
Lambda
Function(s)
Code
Code
Lambda
Function(s)
VPC
Peering
Read API – GET /api/v1/customers
CUD API - PATCH /api/v1/customers
Deploying the API
Deploying the API
Access and throttling via API Keys
Testing It
Test with Postman
Test with Postman #1
Test with Postman #2
Load Test
AWS CloudWatch
Connections and containers…
http://docs.aws.amazon.com/lambda/latest/dg/lambda-introduction.html
… AWS Lambda maintains the container for some time in anticipation of another Lambda function invocation. … the
service freezes the container after a function completes, and thaws the container for reuse. If AWS Lambda chooses to
reuse the container, this has the following implications:
- Any declarations in your Lambda function code (outside the handler code, see Programming Model) remains initialized,
providing additional optimization when the function is invoked again. For example, if your Lambda function establishes a
database connection, instead of reestablishing the connection, the original connection is used in subsequent
invocations. You can add logic in your code to check if a connection already exists before creating one.
MongoDB Atlas Monitoring and Alerts
MongoDB Compass
Considerations…
Scaling?
Scaling Lambda
No user intervention required - Default safety throttle of
100 concurrent executions per account per region.
Functions invoked synchronously throw 429 error code.
Functions invoked asynchronously can absorb reasonable
bursts for approx. 15-30 minutes. If exhausted, consider
using Simple Queue Service (SQS) or Simple Notification
Service (SNS) as the Dead Letter Queue (DLQ).
Read more at https://aws.amazon.com/lambda/faqs/
Scaling MongoDB Atlas
On-Demand
Zero downtime
Upscale/Downscale:
• Instance size
• Storage size
• IOPS
• Replication factor.
Pricing?
Lambda Costs
Cost depends on requests (per million), request time,
memory (GB) allocated to each function.
First 1 million requests per month free - $0.20 per 1
million requests thereafter.
$0.00001667 for every GB-second used.
Additional AWS services imply cost (e.g. API Gateway, …)
Read more at https://aws.amazon.com/lambda/pricing/
MongoDB Atlas Costs
Cost depends on instance size, storage, iops, replication
factor and backup retention.
M0 free – great for you (no VPC peering, use IP whitelist)
M10 starts at $0.08/hr – great for team Dev
M30 starts at $0.54.hr – great for Production
Read more at https://www.mongodb.com/cloud/atlas/pricing
Connections to MongoDB Atlas
Encrypt using AWS KMS – see this blog post:
https://www.mongodb.com/blog/post/serverless-
development-with-nodejs-aws-lambda-mongodb-atlas
Container freeze & recycle?
• Connection outside lambda function helps
• On scale à new containers, new connections
• Ok if API is used in bursts, but maybe not ok if
used seldomly
• If not?
Others?
Local development? à Lambda emulators
• python-lambda-local at
https://pypi.python.org/pypi/python-lambda-local
• lambda-local (node.js) at
https://www.npmjs.com/package/lambda-local
Serverless frameworks – evaluate them! … F500’s are!
• Serverless Framework
• Zappa
• Chalice
• More! - https://thenewstack.io/tns-guide-serverless-
technologies-best-frameworks-platforms-tools/
Façade à Serverless Functions – logic
querying backend API
Backend à Traditional stateful layer -
CRUD API to Data Stores
Would this be a
Serverless Architecture ??
Customer Single View - Insurance Industry (hypothetical)
High-level architecture of a
single view platform
Stateful API
Service Layer
Thank you!

More Related Content

PDF
OpenStack을 중심으로 한 오픈 소스 & 상용 하이브리드 클라우드
PDF
PPTX
Kuberenetes - From Zero to Hero
PPT
Sponges And Placozoa
PPT
lists-and-links.ppt
PDF
Phylum Ctenophora Classification.pdf
PDF
Securing Prometheus exporters using HashiCorp Vault
PDF
Introduction to docker
OpenStack을 중심으로 한 오픈 소스 & 상용 하이브리드 클라우드
Kuberenetes - From Zero to Hero
Sponges And Placozoa
lists-and-links.ppt
Phylum Ctenophora Classification.pdf
Securing Prometheus exporters using HashiCorp Vault
Introduction to docker

Similar to Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas (20)

PDF
Serverless Architectures with AWS Lambda and MongoDB Atlas by Sig Narvaez
PPTX
MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...
PDF
Getting Started with AWS Lambda & Serverless Cloud
PDF
Building serverless apps with MongoDB Atlas and AWS Lambda
PPTX
Serverless Architecture
PDF
Building serverless backends - Tech talk 5 May 2017
PDF
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
PDF
GOTO Stockholm - AWS Lambda - Logic in the cloud without a back-end
PDF
Microservices Manchester: Serverless Architectures By Rafal Gancarz
PPTX
Serverless applications
PDF
Jumpstart your idea with AWS Serverless [Oct 2020]
PDF
Čtvrtkon #64 - AWS Serverless - Michal Haták
PDF
Serverless meetup
PDF
Building Cloud-agnostic Serverless APIs
PDF
20200520 - Como empezar a desarrollar aplicaciones serverless
PDF
Build an app on aws for your first 10 million users (2)
PPTX
Serverless at Lifestage
PPTX
Building self service framework
PDF
Your Second multi-tier Serverless Architecture on AWS
PDF
Microservices with AWS Lambda and the Serverless Framework
Serverless Architectures with AWS Lambda and MongoDB Atlas by Sig Narvaez
MongoDB World 2018: Tutorial - How to Build Applications with MongoDB Atlas &...
Getting Started with AWS Lambda & Serverless Cloud
Building serverless apps with MongoDB Atlas and AWS Lambda
Serverless Architecture
Building serverless backends - Tech talk 5 May 2017
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
GOTO Stockholm - AWS Lambda - Logic in the cloud without a back-end
Microservices Manchester: Serverless Architectures By Rafal Gancarz
Serverless applications
Jumpstart your idea with AWS Serverless [Oct 2020]
Čtvrtkon #64 - AWS Serverless - Michal Haták
Serverless meetup
Building Cloud-agnostic Serverless APIs
20200520 - Como empezar a desarrollar aplicaciones serverless
Build an app on aws for your first 10 million users (2)
Serverless at Lifestage
Building self service framework
Your Second multi-tier Serverless Architecture on AWS
Microservices with AWS Lambda and the Serverless Framework
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
Ad

Recently uploaded (20)

PPTX
Global journeys: estimating international migration
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPT
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
PPTX
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PDF
.pdf is not working space design for the following data for the following dat...
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PPTX
Computer network topology notes for revision
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
Supervised vs unsupervised machine learning algorithms
Global journeys: estimating international migration
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
Miokarditis (Inflamasi pada Otot Jantung)
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
oil_refinery_comprehensive_20250804084928 (1).pptx
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
STUDY DESIGN details- Lt Col Maksud (21).pptx
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
Introduction to Knowledge Engineering Part 1
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
.pdf is not working space design for the following data for the following dat...
Moving the Public Sector (Government) to a Digital Adoption
Computer network topology notes for revision
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Supervised vs unsupervised machine learning algorithms

Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas

  • 1. Serverless Architectures with AWS Lambda and MongoDB Atlas Ashley Townsend Senior Solutions Architect
  • 2. Serverless? • Landscape • Use cases Going Serverless • What changes? • Considerations • MongoDB Atlas AWS & MongoDB Atlas • Simple API for Customer Single View • Lambda & API Gateway • MongoDB Atlas & Compass • Postman Agenda
  • 4. Big Iron Commodity Hardware Virtualized Containers Functions Where will my code run?
  • 5. Serverless Frameworks and Platforms https://github.com/serverless/serverless https://www.zappa.io/ Chalice (awslabs) https://github.com/awslabs/chalice Frameworks for Cloud providers On-Prem PaaS - Now offering FaaS
  • 6. 1. Cloud services have matured 2. BaaS à “SaaS-ification” 3. API’s are the glue 4. Containers – now per function 5. SysOps à DevOps à NoOps Less Ops, More Engineering 5 factors fueling Serverless Computing https://www.forbes.com/sites/janakirammsv/2016/02/28/five-factors-that-are-fueling-serverless-computing-part-1
  • 8. Scheduled Jobs • Sequencing / Orchestration (AWS Steps?) Data Quality • Trigger à Identify à Pass to function Micro or Nano services • Clicks or Taps Event and IoT processing • Don’t worry about scaling App Servers Lightweight API’s • Focus of today! Good fit for Serverless?
  • 10. Container-based Microservices Payments Service Product Catalog Service Shopping Cart Service Domains https://www.mongodb.com/blog/post/serverless-architectures-the-evolution-of-cloud-computing
  • 11. Serverless Microservices Command Query Responsibility Segregation Think about: Fine or course grained Shared logic Start-up time! Packaging Deployment Versioning
  • 12. CQRS pattern on Serverless Microservices GET API PUT PATCH POST DELETE … API API Key API Key Lambda Function(s) Lambda Function(s) Code Code Lambda Function(s) VPC Peering
  • 13. Shape • Person • Insurance Policies • Shape changes per policy type • Addresses Operations via API • GET Customers with soon-to-expire policies, within a geo radius • GET Customers / by SSN, id, etc. • PATCH Update basic contact info (cell, email, …) Customer Single View - Insurance Industry (hypothetical) High-level architecture of a single view platform
  • 16. mgeneratejs • https://github.com/rueckstiess/mgeneratejs • npm install -g mgeneratejs • Create template – generate data • Upload to Atlas via mongoimport • Hint: get connection string from Atlas UI! • Browse with Compass Generate dataset Template (InsuranceC360_Customers.json) mgeneratejs -n 100 InsuranceC360_Customers.json | mongoimport --host ”YOUR ATLAS CLUSTER" --numInsertionWorkers 4 --db WebinarCustomerSingleView --collection Customers -- authenticationDatabase admin --ssl --username YOURUSER --password YOURPASSWORD
  • 17. IAM • Role with Lambda execute policies VPC • VPC • Security Groups – traffic rules • Internet Gateway – outside communication • VPC Peering Connection - Route Table Required AWS Services Lambda • VPC, Security Group and IAM role • Develop inline or upload deployment package (.zip) • Use MongoDB Driver – connect with MongoDB Atlas API Gateway • API definition • API Keys & Usage Plans • Resources and HTTP Methods • Map Routes to Lambda functions
  • 18. VPC
  • 19. MongoDB Atlas • Provision a Cluster – M10+ à need an assigned AWS region for VPC peer • Same AWS region – (I will use us-west-2) • Initiate VPC peer with AWS AWS VPC • Accept incoming Peering Connection • Update Route Table EC2 • Install MongoDB • Test connection from the MongoDB Shell to ensure VPC Peer is working • Optional but highly recommended – ensure VPC Peering is working before proceeding to Lambda MongoDB Atlas peered with your AWS VPC
  • 28. Role with lambda permissions (IAM)
  • 29. Code packaging from __future__ import print_function import json import pymongo print('Loading function') print(’=== CONNECTING TO MONGODB ATLAS ===') connstr = ”ENTER YOUR MONGODB ATLAS CONNECTION HERE" MONGOCLIENT = pymongo.MongoClient(connstr, readPreference=’secondaryPreferred’) def GET_lambda_handler(event, context): … implement GET logic def POST_lambda_handler(event, context): … implement POST logic http://docs.aws.amazon.com/lambda/latest/dg/lambda -python-how-to-create-deployment-package.html
  • 31. Upload & configure function The handler function The role with lambda permissions The VPC (peered with Atlas) The security group that allows traffic At least 2 subnets
  • 34. Recap: What we said we would do High-level architecture of a single view platform
  • 35. Recap: What we said we would do GET API PUT PATCH POST DELETE … API API Key API Key Lambda Function(s) Lambda Function(s) Code Code Lambda Function(s) VPC Peering
  • 36. Read API – GET /api/v1/customers
  • 37. CUD API - PATCH /api/v1/customers
  • 40. Access and throttling via API Keys
  • 47. Connections and containers… http://docs.aws.amazon.com/lambda/latest/dg/lambda-introduction.html … AWS Lambda maintains the container for some time in anticipation of another Lambda function invocation. … the service freezes the container after a function completes, and thaws the container for reuse. If AWS Lambda chooses to reuse the container, this has the following implications: - Any declarations in your Lambda function code (outside the handler code, see Programming Model) remains initialized, providing additional optimization when the function is invoked again. For example, if your Lambda function establishes a database connection, instead of reestablishing the connection, the original connection is used in subsequent invocations. You can add logic in your code to check if a connection already exists before creating one.
  • 51. Scaling? Scaling Lambda No user intervention required - Default safety throttle of 100 concurrent executions per account per region. Functions invoked synchronously throw 429 error code. Functions invoked asynchronously can absorb reasonable bursts for approx. 15-30 minutes. If exhausted, consider using Simple Queue Service (SQS) or Simple Notification Service (SNS) as the Dead Letter Queue (DLQ). Read more at https://aws.amazon.com/lambda/faqs/ Scaling MongoDB Atlas On-Demand Zero downtime Upscale/Downscale: • Instance size • Storage size • IOPS • Replication factor.
  • 52. Pricing? Lambda Costs Cost depends on requests (per million), request time, memory (GB) allocated to each function. First 1 million requests per month free - $0.20 per 1 million requests thereafter. $0.00001667 for every GB-second used. Additional AWS services imply cost (e.g. API Gateway, …) Read more at https://aws.amazon.com/lambda/pricing/ MongoDB Atlas Costs Cost depends on instance size, storage, iops, replication factor and backup retention. M0 free – great for you (no VPC peering, use IP whitelist) M10 starts at $0.08/hr – great for team Dev M30 starts at $0.54.hr – great for Production Read more at https://www.mongodb.com/cloud/atlas/pricing
  • 53. Connections to MongoDB Atlas Encrypt using AWS KMS – see this blog post: https://www.mongodb.com/blog/post/serverless- development-with-nodejs-aws-lambda-mongodb-atlas Container freeze & recycle? • Connection outside lambda function helps • On scale à new containers, new connections • Ok if API is used in bursts, but maybe not ok if used seldomly • If not? Others? Local development? à Lambda emulators • python-lambda-local at https://pypi.python.org/pypi/python-lambda-local • lambda-local (node.js) at https://www.npmjs.com/package/lambda-local Serverless frameworks – evaluate them! … F500’s are! • Serverless Framework • Zappa • Chalice • More! - https://thenewstack.io/tns-guide-serverless- technologies-best-frameworks-platforms-tools/
  • 54. Façade à Serverless Functions – logic querying backend API Backend à Traditional stateful layer - CRUD API to Data Stores Would this be a Serverless Architecture ?? Customer Single View - Insurance Industry (hypothetical) High-level architecture of a single view platform Stateful API Service Layer