Slide 1

Slide 1 text

SERVERLESS MICROSERVICES USING AWS LAMBDA AND GROOVY SkillMatters Groovy & Grails 2015 agora pulse 1 Benoit Hediard @benorama

Slide 2

Slide 2 text

GOING SERVERLESS ON AWS Part 1 2 VOTE APP Demo MONOLITH TO MICROSERVICES Part 2 HELLO WORLD Demo

Slide 3

Slide 3 text

About Me 3 Grails plugin author: AWS SDK, Facebook SDK, Raven, Segment… Entrepreneur since 2000 Passionate about: •  Lean/DevOps •  Cloud/AWS •  Java/Grails •  UX/UI •  Facebook/Twitter Platforms A Social Media Management Platform for Brands Benoit Hédiard Co-founder & CTO @benorama @benorama @benorama

Slide 4

Slide 4 text

4 LEAN STARTUP Context 1 200+ customers in 150+ countries Multiple releases per week Tech rebel team = 5 devs No Ops

Slide 5

Slide 5 text

2 revolutions lead by startups 5 Monolithic Serverless Choose your side… Startups Enterprises Infrastructure Architecture Microservices Bare metal

Slide 6

Slide 6 text

ON PREMISE INFRASTRUCTURE Pre-2006 Bare metal servers 6

Slide 7

Slide 7 text

7 CLOUD REVOLUTION AWS Elastic Compute Cloud (EC2) + Simple Storage Service (S3)

Slide 8

Slide 8 text

8 GOING SERVERLESS ON AWS Part 1

Slide 9

Slide 9 text

Compute EC2 Storage & Content Delivery S3 Application Services SQS AWS - 2006 9

Slide 10

Slide 10 text

Compute Storage & Content Delivery Application Services S3 API Gateway AppStream CloudSearch Elastic Transcoder SES SWF EC2 Lambda EC2 Container Service Elastic Beanstalk Elastic Load Balancing CloudFront EFS Glacier Storage Gateway Snowball Networking VPC Direct Connect Route 53 Analytics EMR Data Pipeline Kinesis Machine Learning QuickSight Elasticsearch Service Developer Tools Management Tools Security & Identity CodeCommit CodeDeploy CodePipeline CloudWatch Cloud Formation CloudTrail Config OpsWorks Service Catalog Identity & Access Management Directory Service Trusted Advisor Cloud HSM Key Management Service Web App Firewall Mobile Services Device Farm Mobile Analytics Cognito SNS Enterprise Applications WorkSpaces WorkDocs WorkMail IOT IoT Hubs Mobile Hub Database RDS DynamoDB ElastiCache RedShift Simple DB Database Migration Service AWS - 2015 SQS 10

Slide 11

Slide 11 text

On premise infrastructure - 2000 11 Applica:ons Data Run:me Middleware O/S Virtualiza:on Servers Storage Networking You manage 100% Bare metal

Slide 12

Slide 12 text

Infrastructure as a Service (IaaS) - 2006 12 Applica:ons Data Run:me Middleware O/S Virtualiza:on Servers Storage Networking You manage

Slide 13

Slide 13 text

Platform as a Service (PaaS) - 2011 13 Applica:ons Data Run:me Middleware O/S Virtualiza:on Servers Storage Networking You manage 90% Serverless!

Slide 14

Slide 14 text

Evolution of compute 14 Infrastructure EC2 Instance Apps running on servers EC2 Container Service Container Services running in containers Lambda Functions running in the cloud

Slide 15

Slide 15 text

What is AWS Lambda? 15

Slide 16

Slide 16 text

Servers scaling and pricing 16 2 EC2 instances 1 EC2 instance 1. Need to keep a minimum of server instances alive 2. Make sure server software stays up to date 3. Can’t scale up or down in a granular way

Slide 17

Slide 17 text

Lambda scaling and pricing 17 Lambda 1. No server to manage 2. Automated granular unlimited scaling 2. Do no pay for idle time

Slide 18

Slide 18 text

Polyglot services, Lambda supports: AWS Lambda 18 Event-driven services, Lambda reacts to: Limitations: 300s max duration, 100 concurrent execution, 50MB max package size Oct 2015 Nov 2014 Jun 2015 CloudWatch S3 API Gateway SNS DynamoDB Kinesis Jun 2015 Alarm responder Image processing Real time message handling DB triggers Real time streaming processing REST endpoints

Slide 19

Slide 19 text

HELLO WORLD Demo 19

Slide 20

Slide 20 text

20 FROM MONOLITH TO MICROSERVICES Part 2

Slide 21

Slide 21 text

Quote 21 Source: http://martinfowler.com/bliki/MonolithFirst.html “Almost all the successful microservice stories have started with a monolith that got too big and was broken up” – Martin Fowler, Monolith first approach, 2015

Slide 22

Slide 22 text

Paul Graham’s Startup Curve 22 TROUGH OF SORROW J L Scale Initial enthusiasm Reality sets in Experimenting & pivoting Hockey stick Starts working Minimum Viable Product From search mode Move fast, break things Monolith Product Market Fit To execution mode Grow fast, scale things Microservices

Slide 23

Slide 23 text

0. Layered monolith architecture 23 Domain Services Controllers Views Browser Simple to ✔ Develop ✔ Deploy (single war) ✔ Scale Issues (when the app grows) ✗ Large code base ✗ Heavy app ✗ No granular deployment ✗ No granular scaling ✗ Dev team size ✗ Single tech stack Perfect for MVP! Minimum Viable Product to validate your business hypothesis Lasagna-oriented architecture

Slide 24

Slide 24 text

1. Back / Front boundary 24 Domain Services API Mobile client Web client Back / Front boundary Single page app (Angular, React, etc) Documented APIs

Slide 25

Slide 25 text

2. Data boundaries 25 Domain Services API Mobile client Web client Domain SQL or NoSQL (depending on scaling/transaction requirements) Business data boundary

Slide 26

Slide 26 text

3. Service boundaries 26 Services API Services API Domain Mobile client Web client Domain Business context boundary

Slide 27

Slide 27 text

4. Microservices architecture 27 Services API Domain Services API Domain Services API Domain Web client Mobile client Drawbacks ✗ Service boundaries hard to defined ✗ Distributed system ✗ Deployment complexity (DevOps required) ✗ Operational overhead Benefits ✔ Small code bases ✔ Lightweight independent apps ✔ Granular scaling ✔ Independent cross- functional teams ✔ Independent tech stack Ravioli-driven architecture Perfect for growth!

Slide 28

Slide 28 text

Which microservices framework/lib? 28 ✗ Heavyweight ✗ Server required ✔ Fastest way to build an app ✔ Plugin ecosystem Minimum package size 50MB to 60MB

Slide 29

Slide 29 text

Which microservices framework/lib? 29 ✔ Lightweight ✗ Server required ✗ Plumbing required ✔ Very fast/scalable Minimum package size 11MB to 16MB

Slide 30

Slide 30 text

Minimum package size 4KB or 4MB Which microservices framework/lib? 30 ✔ Lightweight ✔ Serverless ✗ Vendor lock-in ✗ Limitations (duration, size…) AWS Lambda (java) (groovy)

Slide 31

Slide 31 text

31 VOTE APP Demo

Slide 32

Slide 32 text

Demo app 32 http://localhost:8080 Bare metal monolith

Slide 33

Slide 33 text

1. API CONTROLLER + SERVICE 33 Microservice: QuizVoteAPIController Data: QuizVote

Slide 34

Slide 34 text

2. REST API GATEWAY 34 Microservice: QuizVoteAPIController Data: QuizVote

Slide 35

Slide 35 text

3. DB EVENT PROCESSOR 35 Microservice: QuizVoteDBEventProcessor Microservice: QuizVoteAPIController Data: QuizVote QuizInsight

Slide 36

Slide 36 text

4. FINAL ARCHITECTURE 36 Microservice: QuizVoteDBEventProcessor Static resources: VoteApp (html, js, png, …) Microservice: QuizVoteAPIController Data: QuizVote QuizInsight CDN DNS

Slide 37

Slide 37 text

Demo app 37 http://starwars.benorama.com 100% Serverless microservices!

Slide 38

Slide 38 text

38 VICTORY!!! Bare metal servers defeated 100% serverless microservices Responsive Resilient Elastic Message-driven 100% managed by AWS

Slide 39

Slide 39 text

39 THANK YOU The end @benorama @benorama Demo source code: https://github.com/benorama/skillsmatter-demo