Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serverless microservices using AWS Lambda and G...

Benoit Hediard
December 15, 2015

Serverless microservices using AWS Lambda and Groovy

In this talk we'll explore how two revolutionary ideas come together with AWS Lambda: microservice architectures, and serverless event-driven code.

You will see how we can break a Grails monolithic app into microservices with live code, implemented in Groovy and based on AWS Lambda and Amazon DynamoDB. No servers, no instances, and no containers were harmed in the making of this session.

If you love to focus on building your applications and pushing new features instead of managing/scaling infrastructure, this talk is for you!

Demo source code: https://github.com/benorama/skillsmatter-demo

Benoit Hediard

December 15, 2015
Tweet

More Decks by Benoit Hediard

Other Decks in Technology

Transcript

  1. SERVERLESS MICROSERVICES USING AWS LAMBDA AND GROOVY SkillMatters Groovy &

    Grails 2015 agora pulse 1 Benoit Hediard @benorama
  2. GOING SERVERLESS ON AWS Part 1 2 VOTE APP Demo

    MONOLITH TO MICROSERVICES Part 2 HELLO WORLD Demo
  3. 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
  4. 4 LEAN STARTUP Context 1 200+ customers in 150+ countries

    Multiple releases per week Tech rebel team = 5 devs No Ops
  5. 2 revolutions lead by startups 5 Monolithic Serverless Choose your

    side… Startups Enterprises Infrastructure Architecture Microservices Bare metal
  6. 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
  7. On premise infrastructure - 2000 11 Applica:ons Data Run:me Middleware

    O/S Virtualiza:on Servers Storage Networking You manage 100% Bare metal
  8. Infrastructure as a Service (IaaS) - 2006 12 Applica:ons Data

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

    Run:me Middleware O/S Virtualiza:on Servers Storage Networking You manage 90% Serverless!
  10. 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
  11. 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
  12. Lambda scaling and pricing 17 Lambda 1. No server to

    manage 2. Automated granular unlimited scaling 2. Do no pay for idle time
  13. 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
  14. 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
  15. 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
  16. 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
  17. 1. Back / Front boundary 24 Domain Services API Mobile

    client Web client Back / Front boundary Single page app (Angular, React, etc) Documented APIs
  18. 2. Data boundaries 25 Domain Services API Mobile client Web

    client Domain SQL or NoSQL (depending on scaling/transaction requirements) Business data boundary
  19. 3. Service boundaries 26 Services API Services API Domain Mobile

    client Web client Domain Business context boundary
  20. 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!
  21. Which microservices framework/lib? 28 ✗ Heavyweight ✗ Server required ✔

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

    Plumbing required ✔ Very fast/scalable Minimum package size 11MB to 16MB
  23. Minimum package size 4KB or 4MB Which microservices framework/lib? 30

    ✔ Lightweight ✔ Serverless ✗ Vendor lock-in ✗ Limitations (duration, size…) AWS Lambda (java) (groovy)
  24. 4. FINAL ARCHITECTURE 36 Microservice: QuizVoteDBEventProcessor Static resources: VoteApp (html,

    js, png, …) Microservice: QuizVoteAPIController Data: QuizVote QuizInsight CDN DNS
  25. 38 VICTORY!!! Bare metal servers defeated 100% serverless microservices Responsive

    Resilient Elastic Message-driven 100% managed by AWS
  26. 39 THANK YOU The end @benorama @benorama Demo source code:

    https://github.com/benorama/skillsmatter-demo