SlideShare una empresa de Scribd logo
1 de 49
Arquitecturas
Serverless con AWS
Lambda y MongoDB
Atlas
Sigfrido “Sig”
Narváez
Sr. Solutions
Architect
sig@mongodb.com
@SigNarvaez
@SigNarvaez | #MDBEvenings | #CDMX
¿Serverless?
• ¿Como llegamos aquí?
• Casos de uso
Adoptar estrategia Serverless
• ¿qué cambia?
• Consideraciones
• MongoDB Atlas
AWS & MongoDB Atlas
• Ejemplo: API sencillo para un Single View de Clientes
• Lambda & API Gateway
• MongoDB Atlas & Compass
• Postman
Agenda
@SigNarvaez | #MDBEvenings | #CDMX
Serverless
Big Iron
(mainframe
)
Hardware
básico
Virtualizad
o
Contenedo
res
Funciones
“FaaS”
¿Dónde se ejecutará mi código?
@SigNarvaez | #MDBEvenings | #CDMX
Frameworks y Plataformas
https://github.com/serverless/serverless
https://www.zappa.io/
Chalice (awslabs)
https://github.com/awslabs/chalice
Frameworks para CloudOn-Premise PaaS y FaaS
@SigNarvaez | #MDBEvenings | #CDMX
1. Madurez de servicios cloud
2. BaaS  “SaaS-ification”
3. API’s  son la goma de las
integraciones
4. Contenderos– Ahora por función o
subrutina
5. SysOps  DevOps  NoOps
Menos operaciones, más desarrollo
5 factores que fomentan el movimiento
serverless
https://www.forbes.com/sites/janakirammsv/2016/02/28/five-factors-that-are-fueling-serverless-computing-part-1
@SigNarvaez | #MDBEvenings | #CDMX
Thoughtworks
Technology
Radar
1. Adopt
2. Trial
3. Assess
4. Hold
Trabajos recurrentes
• Secuencias / Orquestación (¿AWS Steps?)
Data Quality
• Evento  Clasificar  llamar función
Micro o Nano servicios
• Clicks o taps
Procesamiento de eventos e IoT
• No se preocupe por escalar servidores de
aplicaciones
APIs ligeros
• Demo
¿Casos de uso para Serverless?
@SigNarvaez | #MDBEvenings | #CDMX
Serverless
Micro
Servicios
Antes y después
Micro Servicios bajo Contenedores
Payments
Service
Product Catalog
Service
Shopping Cart
Service
Dominios
https://www.mongodb.com/blog/post/serverless-architectures-the-evolution-of-cloud-computing
@SigNarvaez | #MDBEvenings | #CDMX
Micro Servicios bajo Serverless
Command
Query
Responsibility
Segregation
Considerar:
Servicios específicos o generales
Lógica compartida
Tiempo de arranque
Empaquetar
Despliegue
Versionamiento
@SigNarvaez | #MDBEvenings | #CDMX
Patrón CQRS con Micro Servicios Serverless
GET
API
PUT PATCH
POST DELETE …
API
API Key
API Key
Lambda Function(s)
Lambda Function(s)
Code
Code
Lambda Function(s)
VPC
Peering
@SigNarvaez | #MDBEvenings | #CDMX
Forma / Esquema
• Persona
• Pólizas de seguro
• La forma cambia por tipo de póliza
• Direcciones, Contacto, etc.
Funcionalidad del API
• GET Clientes – pólizas próximas a expirar
por radio geoespacial
• GET Clientes / por CURP/SSN, id, etc.
• PATCH Actualizar info de contacto (cel,
email, …)
Vista única del cliente - Industria de seguros
(ejemplo)
Arquitectura de alto nivel de una
plataforma de vista única
@SigNarvaez | #MDBEvenings | #CDMX
MongoDB
Atlas &
AWS
¿Servicios de MongoDB? … Atlas!
@SigNarvaez | #MDBEvenings | #CDMX
mgeneratejs
• https://github.com/rueckstiess/mgeneratejs
• npm install -g mgeneratejs
• Crea plantilla – generar datos
• Subir a Atlas via mongoimport
• Navegar con Compass
Generar un set de datos
Plantilla (InsuranceC360_Customers.json)
mgeneratejs -n 100 InsuranceC360_Customers.json |
mongoimport --host ”TU ATLAS CLUSTER" --
numInsertionWorkers 4
--db WebinarCustomerSingleView --collection Customers --
authenticationDatabase admin --ssl --username TUUSER--
password TUPASSWORD
@SigNarvaez | #MDBEvenings | #CDMX
IAM
• Roles - póliza de ejecución para
Lambda
VPC
• VPC
• Security Groups – reglas de trafico
• Internet Gateway – conectividad
exterior
• VPC Peering Connection – Tabla de
rutas
Servicios de AWS
Lambda
• VPC, Security Group y IAM role
• Desarrolla en línea o sube un .zip
• Usar driver de MongoDB – conectarse a
Atlas
API Gateway
• Definición del API
• API Keys y Usage Plans
• Métodos HTTP y recursos (rutas)
• “Mapear” rutas contra funciones Lambda
@SigNarvaez | #MDBEvenings | #CDMX
VPC
MongoDB Atlas
• Crea un cluster – M10+  VPC Peer requiere una región de AWS
• Usar la misma región AWS – (En mi caso, us-west-2)
• Iniciar el VPC peer con AWS
AWS VPC
• Aceptar la conexión/pedido de Peering
• Actualizar la tabla de rutas (Route Table)
EC2
• Instalar MongoDB
• Probar la conexión desde el shell de MongoDB para asegurar que el VPC Peer este
funcionando
• Altamente recomendado antes de proceder con Lambda (no hay ambiente para depurar)
MongoDB Atlas peered con tu VPC de AWS
@SigNarvaez | #MDBEvenings | #CDMX
VPC Peering
Atlas AWS
Verificar que el VPC Peer funcione
@SigNarvaez | #MDBEvenings | #CDMX
Security Group
@SigNarvaez | #MDBEvenings | #CDMX
Peering Connections
@SigNarvaez | #MDBEvenings | #CDMX
Lambda
Role con permisos lambda (IAM)
@SigNarvaez | #MDBEvenings | #CDMX
Como empaquetar tu código / funciones
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/la
mbda-python-how-to-create-deployment-
@SigNarvaez | #MDBEvenings | #CDMX
Lambda functions
@SigNarvaez | #MDBEvenings | #CDMX
Subir y
configurar una
función Handler de la función
Role con permisos para lambda
El VPC peered con Atlas
Grupo de seguridad que permite
trafico
Por lo menos 2 sub-redes
@SigNarvaez | #MDBEvenings | #CDMX
API
Gateway
READ API – GET /api/v1/customers
@SigNarvaez | #MDBEvenings | #CDMX
CUD API - PATCH /api/v1/customers
@SigNarvaez | #MDBEvenings | #CDMX
Lanzamiento del API
@SigNarvaez | #MDBEvenings | #CDMX
Acceso y throttling por medio de API Keys
@SigNarvaez | #MDBEvenings | #CDMX
¡A probar!
Pruebas con Postman
@SigNarvaez | #MDBEvenings | #CDMX
Pruebas de
carga
@SigNarvaez | #MDBEvenings | #CDMX
AWS CloudWatch
@SigNarvaez | #MDBEvenings | #CDMX
Conexiones y contenedores …..
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.
@SigNarvaez | #MDBEvenings | #CDMX
MongoDB Atlas – Monitoreo y alertas
@SigNarvaez | #MDBEvenings | #CDMX
MongoDB Compass
@SigNarvaez | #MDBEvenings | #CDMX
Listo!
…
¿¿ ??
¿Escalamiento?
Lambda
No se requiere intervención del usuario - Control
de seguridad por defecto de 100 ejecuciones
simultáneas por cuenta por región.
Las funciones invocadas sincrónicamente arrojan
el código de error 429. Las funciones invocadas
de forma asíncrona pueden absorber ráfagas
razonables durante aprox. 15-30 minutos. Si se
agota, considere el uso de Simple Queue
Service (SQS) o Simple Notification Service
(SNS) como la Dead Letter Queue(DLQ).
Mas en https://aws.amazon.com/lambda/faqs/
MongoDB Atlas
On-Demand
Zero downtime
Upscale/Downscale:
• Instancia
• Storage
• IOPS
• Factor de
replicación
@SigNarvaez | #MDBEvenings | #CDMX
¿Precios?
Lambda
El costo depende de: las solicitudes (por millón),
del tiempo de solicitud, de la memoria (GB)
asignada a cada función.
Primero 1 millón de solicitudes por mes gratis - $
0.20 por cada 1 millón de solicitudes posteriores.
$ 0.00001667 por cada segundo GB utilizado
Los servicios adicionales de AWS implican un
costo (por ejemplo, API Gateway, ...)
Mas en https://aws.amazon.com/lambda/pricing/
MongoDB Atlas
El costo depende del tamaño de la instancia,
almacenamiento, iops, factor de replicación y
retención de copias de seguridad.
M0 gratis– (no VPC peering, usar IP whitelist)
M10 comienza en $0.08/hr – genial para desarrollo
M30 comienza en $0.54.hr – genial para productiva
Mas en https://www.mongodb.com/cloud/atlas/pricing
@SigNarvaez | #MDBEvenings | #CDMX
Conexiones a MongoDB Atlas
Encriptar por medio de AWS KMS – blog post:
https://www.mongodb.com/blog/post/serverless-
development-with-nodejs-aws-lambda-mongodb-
atlas
Contenedores: congelar y reciclar
• Definir conexión fuera de función lambda
• Bajo escala  nuevos contendores, nuevas
conexiones
• Ok si el API se consume en ráfagas, más no
si es de uso ocasional
• ¿Y si no?
¿Otros?
Desarrollo local  emuladores Lambda
• python-lambda-local
https://pypi.python.org/pypi/python-lambda-local
• lambda-local (node.js)
https://www.npmjs.com/package/lambda-local
Serverless frameworks
• Serverless Framework
• Zappa
• Chalice
• ¡ Y más! - https://thenewstack.io/tns-guide-
serverless-technologies-best-frameworks-
platforms-tools/
@SigNarvaez | #MDBEvenings | #CDMX
Forma / Esquema
• Persona
• Pólizas de seguro
• La forma cambia por tipo de póliza
• Direcciones, Contacto, etc.
Funcionalidad del API
• GET Clientes – pólizas próximas a expirar
por radio geoespacial
• GET Clientes / por CURP/SSN, id, etc.
• PATCH Actualizar info de contacto (cel,
email, …)
Vista única del cliente - Industria de seguros
(ejemplo)
Arquitectura de alto nivel de una
plataforma de vista única
@SigNarvaez | #MDBEvenings | #CDMX
Façade  Funciones Serverless
contra API del backend
Backend  API tradicional,
stateful directo hacia las bases
de datos
¿Esto seria una arquitectura
Serverless?
Vista única del cliente - Industria de seguros
(ejemplo)
Arquitectura de alto nivel de una
plataforma de vista única
Stateful API
Service Layer
@SigNarvaez | #MDBEvenings | #CDMX
@SigNarvaez | #MDBEvenings | #CDMX
Arquitecturas
Serverless con AWS
Lambda y MongoDB
Atlas Código "Sig"  ¡descuento adicional!
Sigfrido Sig
Narváez
Sr. Solutions
Architect
sig@mongodb.com
@SigNarvaez
@SigNarvaez | #MDBEvenings | #CDMX

Más contenido relacionado

La actualidad más candente

Introduction to Amazon Elasticsearch Service
Introduction to  Amazon Elasticsearch ServiceIntroduction to  Amazon Elasticsearch Service
Introduction to Amazon Elasticsearch ServiceAmazon Web Services
 
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar SeriesImproving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar SeriesAmazon Web Services
 
SQL vs MongoDB
SQL vs MongoDBSQL vs MongoDB
SQL vs MongoDBcalltutors
 
클라우드 네이티브 IT를 위한 4가지 요소와 상관관계 - DevOps, CI/CD, Container, 그리고 MSA
클라우드 네이티브 IT를 위한 4가지 요소와 상관관계 - DevOps, CI/CD, Container, 그리고 MSA클라우드 네이티브 IT를 위한 4가지 요소와 상관관계 - DevOps, CI/CD, Container, 그리고 MSA
클라우드 네이티브 IT를 위한 4가지 요소와 상관관계 - DevOps, CI/CD, Container, 그리고 MSAVMware Tanzu Korea
 
Docker and kubernetes_introduction
Docker and kubernetes_introductionDocker and kubernetes_introduction
Docker and kubernetes_introductionJason Hu
 
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...Weaveworks
 
ElasticSearch in action
ElasticSearch in actionElasticSearch in action
ElasticSearch in actionCodemotion
 
Introduction to Apache Solr
Introduction to Apache SolrIntroduction to Apache Solr
Introduction to Apache SolrChristos Manios
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
쿠알못이 Amazon EKS로 안정적인 서비스 운영하기 - 최용호(넥슨코리아) :: AWS Community Day 2020
쿠알못이 Amazon EKS로 안정적인 서비스 운영하기 - 최용호(넥슨코리아) :: AWS Community Day 2020쿠알못이 Amazon EKS로 안정적인 서비스 운영하기 - 최용호(넥슨코리아) :: AWS Community Day 2020
쿠알못이 Amazon EKS로 안정적인 서비스 운영하기 - 최용호(넥슨코리아) :: AWS Community Day 2020AWSKRUG - AWS한국사용자모임
 
An Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - WebinarAn Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - WebinarAmazon Web Services
 
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Edureka!
 
Introduction to AWS
Introduction to AWSIntroduction to AWS
Introduction to AWSHesham Amin
 

La actualidad más candente (20)

Introduction to Amazon Elasticsearch Service
Introduction to  Amazon Elasticsearch ServiceIntroduction to  Amazon Elasticsearch Service
Introduction to Amazon Elasticsearch Service
 
MongoDB Avanzado
MongoDB AvanzadoMongoDB Avanzado
MongoDB Avanzado
 
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar SeriesImproving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
Improving Infrastructure Governance on AWS - AWS June 2016 Webinar Series
 
SQL vs MongoDB
SQL vs MongoDBSQL vs MongoDB
SQL vs MongoDB
 
클라우드 네이티브 IT를 위한 4가지 요소와 상관관계 - DevOps, CI/CD, Container, 그리고 MSA
클라우드 네이티브 IT를 위한 4가지 요소와 상관관계 - DevOps, CI/CD, Container, 그리고 MSA클라우드 네이티브 IT를 위한 4가지 요소와 상관관계 - DevOps, CI/CD, Container, 그리고 MSA
클라우드 네이티브 IT를 위한 4가지 요소와 상관관계 - DevOps, CI/CD, Container, 그리고 MSA
 
Docker and kubernetes_introduction
Docker and kubernetes_introductionDocker and kubernetes_introduction
Docker and kubernetes_introduction
 
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
 
Deep Dive: AWS CloudFormation
Deep Dive: AWS CloudFormationDeep Dive: AWS CloudFormation
Deep Dive: AWS CloudFormation
 
ElasticSearch in action
ElasticSearch in actionElasticSearch in action
ElasticSearch in action
 
Kubernetes Introduction
Kubernetes IntroductionKubernetes Introduction
Kubernetes Introduction
 
Introduction to Apache Solr
Introduction to Apache SolrIntroduction to Apache Solr
Introduction to Apache Solr
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
쿠알못이 Amazon EKS로 안정적인 서비스 운영하기 - 최용호(넥슨코리아) :: AWS Community Day 2020
쿠알못이 Amazon EKS로 안정적인 서비스 운영하기 - 최용호(넥슨코리아) :: AWS Community Day 2020쿠알못이 Amazon EKS로 안정적인 서비스 운영하기 - 최용호(넥슨코리아) :: AWS Community Day 2020
쿠알못이 Amazon EKS로 안정적인 서비스 운영하기 - 최용호(넥슨코리아) :: AWS Community Day 2020
 
An Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - WebinarAn Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - Webinar
 
Elasticsearch
ElasticsearchElasticsearch
Elasticsearch
 
Introduction to DevOps on AWS
Introduction to DevOps on AWSIntroduction to DevOps on AWS
Introduction to DevOps on AWS
 
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
Elasticsearch Tutorial | Getting Started with Elasticsearch | ELK Stack Train...
 
Aws VPC
Aws VPCAws VPC
Aws VPC
 
Introduction to AWS
Introduction to AWSIntroduction to AWS
Introduction to AWS
 
Cloud Formation
Cloud FormationCloud Formation
Cloud Formation
 

Similar a Arquitectura Serverless con AWS Lambda y MongoDB Atlas

Comenzando con aplicaciones serverless en AWS
Comenzando con aplicaciones serverless en AWSComenzando con aplicaciones serverless en AWS
Comenzando con aplicaciones serverless en AWSAmazon Web Services LATAM
 
AWS Summits América Latina 2015- Sin servidores: Mobile backend como servicio...
AWS Summits América Latina 2015- Sin servidores: Mobile backend como servicio...AWS Summits América Latina 2015- Sin servidores: Mobile backend como servicio...
AWS Summits América Latina 2015- Sin servidores: Mobile backend como servicio...Amazon Web Services LATAM
 
AWS Summit Bogotá Track Avanzado: Sin servidores: Mobile backend como servici...
AWS Summit Bogotá Track Avanzado: Sin servidores: Mobile backend como servici...AWS Summit Bogotá Track Avanzado: Sin servidores: Mobile backend como servici...
AWS Summit Bogotá Track Avanzado: Sin servidores: Mobile backend como servici...Amazon Web Services
 
Transformation Track AWS Cloud Experience Argentina - Despegando y Desarrolla...
Transformation Track AWS Cloud Experience Argentina - Despegando y Desarrolla...Transformation Track AWS Cloud Experience Argentina - Despegando y Desarrolla...
Transformation Track AWS Cloud Experience Argentina - Despegando y Desarrolla...Amazon Web Services LATAM
 
Presentación Damian Traverso | Amazon Web Services - eCommerce IT Camp 2017
Presentación Damian Traverso | Amazon Web Services - eCommerce IT Camp 2017Presentación Damian Traverso | Amazon Web Services - eCommerce IT Camp 2017
Presentación Damian Traverso | Amazon Web Services - eCommerce IT Camp 2017eCommerce Institute
 
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...Amazon Web Services LATAM
 
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...Amazon Web Services LATAM
 
Micro vs Nano (servicios)
Micro vs Nano (servicios)Micro vs Nano (servicios)
Micro vs Nano (servicios)Pedro J. Molina
 
Arquitecturas y estrategias para generar aplicaciones modernas en AWS - MXO20...
Arquitecturas y estrategias para generar aplicaciones modernas en AWS - MXO20...Arquitecturas y estrategias para generar aplicaciones modernas en AWS - MXO20...
Arquitecturas y estrategias para generar aplicaciones modernas en AWS - MXO20...Amazon Web Services
 
Extendiendo su centro de datos a la nube de AWS
Extendiendo su centro de datos a la nube de AWSExtendiendo su centro de datos a la nube de AWS
Extendiendo su centro de datos a la nube de AWSAmazon Web Services LATAM
 
Comenzando con los servicios móviles en AWS
Comenzando con los servicios móviles en AWSComenzando con los servicios móviles en AWS
Comenzando con los servicios móviles en AWSAmazon Web Services LATAM
 
Extendiendo su centro de datos a la nube de AWS
Extendiendo su centro de datos a la nube de AWSExtendiendo su centro de datos a la nube de AWS
Extendiendo su centro de datos a la nube de AWSAmazon Web Services LATAM
 
Meetup AWS User Group chile - Diciembre 2018
Meetup AWS User Group chile - Diciembre 2018Meetup AWS User Group chile - Diciembre 2018
Meetup AWS User Group chile - Diciembre 2018Gonzalo Vásquez
 
AWS para desarrolladores
AWS para desarrolladoresAWS para desarrolladores
AWS para desarrolladoresRaul Hugo
 

Similar a Arquitectura Serverless con AWS Lambda y MongoDB Atlas (20)

Clase 4 Electiva Profesional 3 AWS Lambda
Clase 4 Electiva Profesional 3 AWS LambdaClase 4 Electiva Profesional 3 AWS Lambda
Clase 4 Electiva Profesional 3 AWS Lambda
 
Comenzando con aplicaciones serverless en AWS
Comenzando con aplicaciones serverless en AWSComenzando con aplicaciones serverless en AWS
Comenzando con aplicaciones serverless en AWS
 
AWS Summits América Latina 2015- Sin servidores: Mobile backend como servicio...
AWS Summits América Latina 2015- Sin servidores: Mobile backend como servicio...AWS Summits América Latina 2015- Sin servidores: Mobile backend como servicio...
AWS Summits América Latina 2015- Sin servidores: Mobile backend como servicio...
 
AWS Summit Bogotá Track Avanzado: Sin servidores: Mobile backend como servici...
AWS Summit Bogotá Track Avanzado: Sin servidores: Mobile backend como servici...AWS Summit Bogotá Track Avanzado: Sin servidores: Mobile backend como servici...
AWS Summit Bogotá Track Avanzado: Sin servidores: Mobile backend como servici...
 
Transformation Track AWS Cloud Experience Argentina - Despegando y Desarrolla...
Transformation Track AWS Cloud Experience Argentina - Despegando y Desarrolla...Transformation Track AWS Cloud Experience Argentina - Despegando y Desarrolla...
Transformation Track AWS Cloud Experience Argentina - Despegando y Desarrolla...
 
Presentación Damian Traverso | Amazon Web Services - eCommerce IT Camp 2017
Presentación Damian Traverso | Amazon Web Services - eCommerce IT Camp 2017Presentación Damian Traverso | Amazon Web Services - eCommerce IT Camp 2017
Presentación Damian Traverso | Amazon Web Services - eCommerce IT Camp 2017
 
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
 
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
Arquitecturas Serverless com IoT, Machine Learning y Assistente de Voz en Prá...
 
Construyedo Aplicaciones Serverless
Construyedo Aplicaciones ServerlessConstruyedo Aplicaciones Serverless
Construyedo Aplicaciones Serverless
 
Como reducir costos en AWS
Como reducir costos en AWSComo reducir costos en AWS
Como reducir costos en AWS
 
Micro vs Nano (servicios)
Micro vs Nano (servicios)Micro vs Nano (servicios)
Micro vs Nano (servicios)
 
Arquitecturas y estrategias para generar aplicaciones modernas en AWS - MXO20...
Arquitecturas y estrategias para generar aplicaciones modernas en AWS - MXO20...Arquitecturas y estrategias para generar aplicaciones modernas en AWS - MXO20...
Arquitecturas y estrategias para generar aplicaciones modernas en AWS - MXO20...
 
Meetup serverless
Meetup serverlessMeetup serverless
Meetup serverless
 
Extendiendo su centro de datos a la nube de AWS
Extendiendo su centro de datos a la nube de AWSExtendiendo su centro de datos a la nube de AWS
Extendiendo su centro de datos a la nube de AWS
 
Comenzando con los servicios móviles en AWS
Comenzando con los servicios móviles en AWSComenzando con los servicios móviles en AWS
Comenzando con los servicios móviles en AWS
 
Builders' Day - Naranja
Builders' Day - NaranjaBuilders' Day - Naranja
Builders' Day - Naranja
 
Extendiendo su centro de datos a la nube de AWS
Extendiendo su centro de datos a la nube de AWSExtendiendo su centro de datos a la nube de AWS
Extendiendo su centro de datos a la nube de AWS
 
Meetup AWS User Group chile - Diciembre 2018
Meetup AWS User Group chile - Diciembre 2018Meetup AWS User Group chile - Diciembre 2018
Meetup AWS User Group chile - Diciembre 2018
 
Comenzando con Arquitecturas sin servidores
Comenzando con Arquitecturas sin servidoresComenzando con Arquitecturas sin servidores
Comenzando con Arquitecturas sin servidores
 
AWS para desarrolladores
AWS para desarrolladoresAWS para desarrolladores
AWS para desarrolladores
 

Más de MongoDB

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

Más de MongoDB (20)

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

Arquitectura Serverless con AWS Lambda y MongoDB Atlas

  • 1. Arquitecturas Serverless con AWS Lambda y MongoDB Atlas Sigfrido “Sig” Narváez Sr. Solutions Architect sig@mongodb.com @SigNarvaez @SigNarvaez | #MDBEvenings | #CDMX
  • 2. ¿Serverless? • ¿Como llegamos aquí? • Casos de uso Adoptar estrategia Serverless • ¿qué cambia? • Consideraciones • MongoDB Atlas AWS & MongoDB Atlas • Ejemplo: API sencillo para un Single View de Clientes • Lambda & API Gateway • MongoDB Atlas & Compass • Postman Agenda @SigNarvaez | #MDBEvenings | #CDMX
  • 5. Frameworks y Plataformas https://github.com/serverless/serverless https://www.zappa.io/ Chalice (awslabs) https://github.com/awslabs/chalice Frameworks para CloudOn-Premise PaaS y FaaS @SigNarvaez | #MDBEvenings | #CDMX
  • 6. 1. Madurez de servicios cloud 2. BaaS  “SaaS-ification” 3. API’s  son la goma de las integraciones 4. Contenderos– Ahora por función o subrutina 5. SysOps  DevOps  NoOps Menos operaciones, más desarrollo 5 factores que fomentan el movimiento serverless https://www.forbes.com/sites/janakirammsv/2016/02/28/five-factors-that-are-fueling-serverless-computing-part-1 @SigNarvaez | #MDBEvenings | #CDMX
  • 8. Trabajos recurrentes • Secuencias / Orquestación (¿AWS Steps?) Data Quality • Evento  Clasificar  llamar función Micro o Nano servicios • Clicks o taps Procesamiento de eventos e IoT • No se preocupe por escalar servidores de aplicaciones APIs ligeros • Demo ¿Casos de uso para Serverless? @SigNarvaez | #MDBEvenings | #CDMX
  • 11. Micro Servicios bajo Contenedores Payments Service Product Catalog Service Shopping Cart Service Dominios https://www.mongodb.com/blog/post/serverless-architectures-the-evolution-of-cloud-computing @SigNarvaez | #MDBEvenings | #CDMX
  • 12. Micro Servicios bajo Serverless Command Query Responsibility Segregation Considerar: Servicios específicos o generales Lógica compartida Tiempo de arranque Empaquetar Despliegue Versionamiento @SigNarvaez | #MDBEvenings | #CDMX
  • 13. Patrón CQRS con Micro Servicios Serverless GET API PUT PATCH POST DELETE … API API Key API Key Lambda Function(s) Lambda Function(s) Code Code Lambda Function(s) VPC Peering @SigNarvaez | #MDBEvenings | #CDMX
  • 14. Forma / Esquema • Persona • Pólizas de seguro • La forma cambia por tipo de póliza • Direcciones, Contacto, etc. Funcionalidad del API • GET Clientes – pólizas próximas a expirar por radio geoespacial • GET Clientes / por CURP/SSN, id, etc. • PATCH Actualizar info de contacto (cel, email, …) Vista única del cliente - Industria de seguros (ejemplo) Arquitectura de alto nivel de una plataforma de vista única @SigNarvaez | #MDBEvenings | #CDMX
  • 16. ¿Servicios de MongoDB? … Atlas! @SigNarvaez | #MDBEvenings | #CDMX
  • 17. mgeneratejs • https://github.com/rueckstiess/mgeneratejs • npm install -g mgeneratejs • Crea plantilla – generar datos • Subir a Atlas via mongoimport • Navegar con Compass Generar un set de datos Plantilla (InsuranceC360_Customers.json) mgeneratejs -n 100 InsuranceC360_Customers.json | mongoimport --host ”TU ATLAS CLUSTER" -- numInsertionWorkers 4 --db WebinarCustomerSingleView --collection Customers -- authenticationDatabase admin --ssl --username TUUSER-- password TUPASSWORD @SigNarvaez | #MDBEvenings | #CDMX
  • 18. IAM • Roles - póliza de ejecución para Lambda VPC • VPC • Security Groups – reglas de trafico • Internet Gateway – conectividad exterior • VPC Peering Connection – Tabla de rutas Servicios de AWS Lambda • VPC, Security Group y IAM role • Desarrolla en línea o sube un .zip • Usar driver de MongoDB – conectarse a Atlas API Gateway • Definición del API • API Keys y Usage Plans • Métodos HTTP y recursos (rutas) • “Mapear” rutas contra funciones Lambda @SigNarvaez | #MDBEvenings | #CDMX
  • 19. VPC
  • 20. MongoDB Atlas • Crea un cluster – M10+  VPC Peer requiere una región de AWS • Usar la misma región AWS – (En mi caso, us-west-2) • Iniciar el VPC peer con AWS AWS VPC • Aceptar la conexión/pedido de Peering • Actualizar la tabla de rutas (Route Table) EC2 • Instalar MongoDB • Probar la conexión desde el shell de MongoDB para asegurar que el VPC Peer este funcionando • Altamente recomendado antes de proceder con Lambda (no hay ambiente para depurar) MongoDB Atlas peered con tu VPC de AWS @SigNarvaez | #MDBEvenings | #CDMX
  • 22. Verificar que el VPC Peer funcione @SigNarvaez | #MDBEvenings | #CDMX
  • 23. Security Group @SigNarvaez | #MDBEvenings | #CDMX
  • 24. Peering Connections @SigNarvaez | #MDBEvenings | #CDMX
  • 26. Role con permisos lambda (IAM) @SigNarvaez | #MDBEvenings | #CDMX
  • 27. Como empaquetar tu código / funciones 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/la mbda-python-how-to-create-deployment- @SigNarvaez | #MDBEvenings | #CDMX
  • 28. Lambda functions @SigNarvaez | #MDBEvenings | #CDMX
  • 29. Subir y configurar una función Handler de la función Role con permisos para lambda El VPC peered con Atlas Grupo de seguridad que permite trafico Por lo menos 2 sub-redes @SigNarvaez | #MDBEvenings | #CDMX
  • 31. READ API – GET /api/v1/customers @SigNarvaez | #MDBEvenings | #CDMX
  • 32. CUD API - PATCH /api/v1/customers @SigNarvaez | #MDBEvenings | #CDMX
  • 33. Lanzamiento del API @SigNarvaez | #MDBEvenings | #CDMX
  • 34. Acceso y throttling por medio de API Keys @SigNarvaez | #MDBEvenings | #CDMX
  • 36. Pruebas con Postman @SigNarvaez | #MDBEvenings | #CDMX
  • 37. Pruebas de carga @SigNarvaez | #MDBEvenings | #CDMX
  • 38. AWS CloudWatch @SigNarvaez | #MDBEvenings | #CDMX
  • 39. Conexiones y contenedores ….. 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. @SigNarvaez | #MDBEvenings | #CDMX
  • 40. MongoDB Atlas – Monitoreo y alertas @SigNarvaez | #MDBEvenings | #CDMX
  • 41. MongoDB Compass @SigNarvaez | #MDBEvenings | #CDMX
  • 43. ¿Escalamiento? Lambda No se requiere intervención del usuario - Control de seguridad por defecto de 100 ejecuciones simultáneas por cuenta por región. Las funciones invocadas sincrónicamente arrojan el código de error 429. Las funciones invocadas de forma asíncrona pueden absorber ráfagas razonables durante aprox. 15-30 minutos. Si se agota, considere el uso de Simple Queue Service (SQS) o Simple Notification Service (SNS) como la Dead Letter Queue(DLQ). Mas en https://aws.amazon.com/lambda/faqs/ MongoDB Atlas On-Demand Zero downtime Upscale/Downscale: • Instancia • Storage • IOPS • Factor de replicación @SigNarvaez | #MDBEvenings | #CDMX
  • 44. ¿Precios? Lambda El costo depende de: las solicitudes (por millón), del tiempo de solicitud, de la memoria (GB) asignada a cada función. Primero 1 millón de solicitudes por mes gratis - $ 0.20 por cada 1 millón de solicitudes posteriores. $ 0.00001667 por cada segundo GB utilizado Los servicios adicionales de AWS implican un costo (por ejemplo, API Gateway, ...) Mas en https://aws.amazon.com/lambda/pricing/ MongoDB Atlas El costo depende del tamaño de la instancia, almacenamiento, iops, factor de replicación y retención de copias de seguridad. M0 gratis– (no VPC peering, usar IP whitelist) M10 comienza en $0.08/hr – genial para desarrollo M30 comienza en $0.54.hr – genial para productiva Mas en https://www.mongodb.com/cloud/atlas/pricing @SigNarvaez | #MDBEvenings | #CDMX
  • 45. Conexiones a MongoDB Atlas Encriptar por medio de AWS KMS – blog post: https://www.mongodb.com/blog/post/serverless- development-with-nodejs-aws-lambda-mongodb- atlas Contenedores: congelar y reciclar • Definir conexión fuera de función lambda • Bajo escala  nuevos contendores, nuevas conexiones • Ok si el API se consume en ráfagas, más no si es de uso ocasional • ¿Y si no? ¿Otros? Desarrollo local  emuladores Lambda • python-lambda-local https://pypi.python.org/pypi/python-lambda-local • lambda-local (node.js) https://www.npmjs.com/package/lambda-local Serverless frameworks • Serverless Framework • Zappa • Chalice • ¡ Y más! - https://thenewstack.io/tns-guide- serverless-technologies-best-frameworks- platforms-tools/ @SigNarvaez | #MDBEvenings | #CDMX
  • 46. Forma / Esquema • Persona • Pólizas de seguro • La forma cambia por tipo de póliza • Direcciones, Contacto, etc. Funcionalidad del API • GET Clientes – pólizas próximas a expirar por radio geoespacial • GET Clientes / por CURP/SSN, id, etc. • PATCH Actualizar info de contacto (cel, email, …) Vista única del cliente - Industria de seguros (ejemplo) Arquitectura de alto nivel de una plataforma de vista única @SigNarvaez | #MDBEvenings | #CDMX
  • 47. Façade  Funciones Serverless contra API del backend Backend  API tradicional, stateful directo hacia las bases de datos ¿Esto seria una arquitectura Serverless? Vista única del cliente - Industria de seguros (ejemplo) Arquitectura de alto nivel de una plataforma de vista única Stateful API Service Layer @SigNarvaez | #MDBEvenings | #CDMX
  • 49. Arquitecturas Serverless con AWS Lambda y MongoDB Atlas Código "Sig"  ¡descuento adicional! Sigfrido Sig Narváez Sr. Solutions Architect sig@mongodb.com @SigNarvaez @SigNarvaez | #MDBEvenings | #CDMX