Transcript
Page 1: Build Web Applications using Microservices on Node.js and Serverless AWS

Eugene Istrati, Technology Partner

Build Web Applicationsusing Microservices on Node.js and

Serverless AWS

[email protected]

http://www.meetup.com/nodejs/events/226713968

Page 2: Build Web Applications using Microservices on Node.js and Serverless AWS

© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Eugene Istrati, Partner @ Mitoc Group

Microservices Architecturefor Digital Platforms with AWS Lambda,

Amazon CloudFront, and Amazon DynamoDB

[email protected]

October 2015

ARC201

Page 3: Build Web Applications using Microservices on Node.js and Serverless AWS

Digital Platform Challenges

Note: Credits and thanks are listed at the end of the presentation

Page 4: Build Web Applications using Microservices on Node.js and Serverless AWS

Average cost of downtime• $500K - $1M / hour (IDC, Dec 2014)• $140K - $540K / hour (Garner, July 2014)• $474K / hour (Ponemon Inst., Dec 2013)

Most commonly reported consequences

• Damage to reputation (38%)• Increase in customer churn (37%)• Damage to credit rating (28%)• Increase to insurance premiums (26%)

Digital Platform Challenges

Outage

Degradation

No impact

0% 10% 20% 30% 40% 50% 60% 70%

27%

60%

13%

Impact of DoS/DDoS Attack

Note: Credits and thanks are listed at the end of the presentation

Page 5: Build Web Applications using Microservices on Node.js and Serverless AWS

Digital Enterprise End-to-end Platform on AWS

Page 6: Build Web Applications using Microservices on Node.js and Serverless AWS

About

Eugene Istrati

[email protected]

• Partner @ Mitoc Group Inc

• 15+ years in IT; 7+ years on AWS

• AWS Certified Solutions Architect (re-certified at re:Invent 2015)

• Companies: Hearst, Amazon, GrubHub, Tenaris (Europe)

Mitoc Group Inc

• www.mitocgroup.com

• Web Development Studio

• AWS Technology Partner

• Focusing on enterprise applications and platforms

• Working with customers from media and entertainment industry

Page 7: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 8: Build Web Applications using Microservices on Node.js and Serverless AWS

Demo: todo.deep.mg

• Go to the GitHub repository• github.com/MitocGroup/deep

-microservices-todo-app

• Follow the steps from Getting Started to build and deploy

• todo.deep.com

Page 9: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 10: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes

Page 11: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

Page 12: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

• Reduced operational complexity

Page 13: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

• Reduced operational complexity• Requires DevOps with experience

Page 14: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

• Reduced operational complexity• Requires DevOps with experience

• Flexible choice of technology

Page 15: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

• Reduced operational complexity• Requires DevOps with experience

• Flexible choice of technology• Requires devs with rich skill set

Page 16: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

• Reduced operational complexity• Requires DevOps with experience

• Flexible choice of technology• Requires devs with rich skill set

• Cost-effective

Page 17: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

• Reduced operational complexity• Requires DevOps with experience

• Flexible choice of technology• Requires devs with rich skill set

• Cost-effective• Over-provisioning and over-paying

Page 18: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

• Reduced operational complexity• Requires DevOps with experience

• Flexible choice of technology• Requires devs with rich skill set

• Cost-effective• Over-provisioning and over-paying

Page 19: Build Web Applications using Microservices on Node.js and Serverless AWS

AWS re:Invent 2014

Note: Credits and thanks are listed at the end of the presentation

Page 20: Build Web Applications using Microservices on Node.js and Serverless AWS

AWS Summit NY 2015

Note: Credits and thanks are listed at the end of the presentation

Page 21: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting … Reinvented

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

S3 bucket

CloudFrontdistributio

n

Web Tier

CognitoIdentity DB Tier

SQS DynamoDB

LambdaCloudFrontlogs

API Gateway

www.example.comstatic.example.com

App Tier

AWS Region RDS Aurora

Page 22: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 23: Build Web Applications using Microservices on Node.js and Serverless AWS

What does “serverless” mean?

Not involving a server; composed only of clients.http://www.wordsense.eu/serverless

Serverless doesn’t mean servers are no longer involved. It simply means that developers no longer have to think "that much" about them. Computing resources get used as services without having to manage around physical

capacities or limits.https://www.quora.com/What-is-Serverless-Computing

Page 24: Build Web Applications using Microservices on Node.js and Serverless AWS

Serverless vs. Reference

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

S3 bucket

CloudFrontdistributio

n

Web Tier

CognitoIdentity DB Tier

SQS DynamoDB

LambdaCloudFrontlogs

API Gateway

www.example.comstatic.example.com

App Tier

AWS Region RDS Aurora

vs

Page 25: Build Web Applications using Microservices on Node.js and Serverless AWS

Serverless Architecture – Web Tier

S3 bucket

CloudFrontdistribution

Web Tier

CognitoIdentity

CloudFrontlogs

www.example.comstatic.example.com

Availability Zone A Availability Zone B

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

Page 26: Build Web Applications using Microservices on Node.js and Serverless AWS

Serverless Architecture – Web Tier

S3 bucket

CloudFrontdistribution

Web Tier

CognitoIdentity

CloudFrontlogs

www.example.comstatic.example.com

• Static Assets• Same as in reference architecture• css, js, docs, images, videos + html

• Dynamic Functionality• Use JS framework (e.g. Angular)• SEO-friendly (Custom Error

Response + HTML5 History API)

• Completely Serverless• Pre-scaled• Low-cost• Low-maintenance

Page 27: Build Web Applications using Microservices on Node.js and Serverless AWS

Serverless Architecture – Web Tier

S3 bucket

CloudFrontdistribution

Web Tier

CognitoIdentity

CloudFrontlogs

www.example.comstatic.example.com

• Static Assets• Same as in reference architecture• css, js, docs, images, videos + html

• Dynamic Functionality• Use JS framework (e.g. Angular)• SEO-friendly (Custom Error

Response + HTML5 History API)

• Completely Serverless• Pre-scaled• Low-cost• Low-maintenance

Page 28: Build Web Applications using Microservices on Node.js and Serverless AWS

Serverless Architecture – Web Tier

S3 bucket

CloudFrontdistribution

Web Tier

CognitoIdentity

CloudFrontlogs

www.example.comstatic.example.com

• Static Assets• Same as in reference architecture• css, js, docs, images, videos + html

• Dynamic Functionality• Use JS framework (e.g. Angular)• SEO-friendly (Custom Error

Response + HTML5 History API)

• Completely Serverless• Pre-scaled• Low-cost• Low-maintenance

Page 29: Build Web Applications using Microservices on Node.js and Serverless AWS

Serverless Architecture – App Tier

CognitoIdentity

SQS

Lambda

API Gateway

App Tier

Availability Zone A Availability Zone B

Auto Scaling Group

appservers

appservers

Page 30: Build Web Applications using Microservices on Node.js and Serverless AWS

CognitoIdentity

SQS

Lambda

API Gateway

App Tier • Accelerated Backend• Write node.js functions and load

into Lambda• Power up Lambda with RESTful

endpoints on API Gateway• Cache, throttle, meter, version, etc.

• Completely Serverless• Pre-scaled• Low-cost• Low-maintenance

Serverless Architecture – App Tier

Page 31: Build Web Applications using Microservices on Node.js and Serverless AWS

• Accelerated Backend• Write node.js functions and load

into Lambda• Power up Lambda with RESTful

endpoints on API Gateway• Cache, throttle, meter, version, etc.

• Completely Serverless• Pre-scaled• Low-cost• Low-maintenance

Serverless Architecture – App Tier

CognitoIdentity

SQS

Lambda

API Gateway

App Tier

Page 32: Build Web Applications using Microservices on Node.js and Serverless AWS

Availability Zone A Availability Zone B

Serverless Architecture – DB TierDB Tier

SQS DynamoDB

RDS Aurora

Page 33: Build Web Applications using Microservices on Node.js and Serverless AWS

DB Tier

SQS DynamoDB

RDS Aurora

Serverless Architecture – DB Tier• First choice – DynamoDB + SQS

• Schema-free• Scale only reads and writes

• Completely Serverless• Pre-scaled• Low-cost• Low-maintenance

• Next choice – RDS Aurora• Relational• MySQL-like approach, but 5x better

Page 34: Build Web Applications using Microservices on Node.js and Serverless AWS

Serverless Architecture – DB Tier• First choice – DynamoDB + SQS

• Schema-free• Scale only reads and writes

• Completely Serverless• Pre-scaled• Low-cost• Low-maintenance

• Next choice – RDS Aurora• Relational• MySQL-like approach, but 5x better

DB Tier

SQS DynamoDB

RDS Aurora

Page 35: Build Web Applications using Microservices on Node.js and Serverless AWS

Serverless Architecture – DB Tier• First choice – DynamoDB + SQS

• Schema-free• Scale only reads and writes

• Completely Serverless• Pre-scaled• Low-cost• Low-maintenance

• Next choice – RDS Aurora• Relational• MySQL-like approach, but 5x better

DB Tier

SQS DynamoDB

RDS Aurora

Page 36: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 37: Build Web Applications using Microservices on Node.js and Serverless AWS

Demo: Setup Serverless AWS1. Security - Create IAM roles2. Front-end - Create S3 bucket - Enable static website hosting - Add bucket policy - Create CloudFront distribution3. Back-end - Create Lambda function - Upload code into Lambda - Create API Gateway endpoint4. Database - Create DynamoDB table5. Code - Load code into S3 bucket - View via CloudFront (S3 as backup)

S3 bucket

CloudFrontdistribution

Web Tier

CognitoIdentity DB Tier

SQS DynamoDB

LambdaCloudFrontlogs

API Gateway

www.example.comstatic.example.com

App Tier

AWS RegionRDS Aurora

Page 38: Build Web Applications using Microservices on Node.js and Serverless AWS

Lessons Learned

• Serverless approach is challengingly awesome

• Frontend is restricted to JS (and JS Frameworks)• Backend is restricted to Python, Java or JS (for now)• SOA and APIs are required by design

Page 39: Build Web Applications using Microservices on Node.js and Serverless AWS

Lessons Learned

• Serverless approach is challengingly awesome

• Frontend is restricted to JS (and JS Frameworks)• Backend is restricted to Python, Java or JS (for now)• SOA and APIs are required by design

• Services must be as small as possible

• AWS Lambda constrains• Browser limitations (on mobile devices)

Page 40: Build Web Applications using Microservices on Node.js and Serverless AWS

Lessons Learned

• Serverless approach is challengingly awesome

• Frontend is restricted to JS (and JS Frameworks)• Backend is restricted to Python, Java or JS (for now)• SOA and APIs are required by design

• Services must be as small as possible => microservices

• AWS Lambda constrains• Browser limitations (on mobile devices)

Page 41: Build Web Applications using Microservices on Node.js and Serverless AWS

Let’s Recap

Page 42: Build Web Applications using Microservices on Node.js and Serverless AWS

Recap

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Reference architecture for web application hosting on AWS

Page 43: Build Web Applications using Microservices on Node.js and Serverless AWS

Recap• Reference architecture for web

application hosting on AWS

• Transformed to serverless architecture on AWS

S3 bucket

CloudFrontdistributio

n

Web Tier

CognitoIdentity DB Tier

SQS DynamoDB

LambdaCloudFrontlogs

API Gateway

www.example.comstatic.example.com

App Tier

AWS Region RDS Aurora

Page 44: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 45: Build Web Applications using Microservices on Node.js and Serverless AWS

What does “microservices” mean?

In computing, microservices is a software architecture style in which complex applications are composed of small, independent processes communicating with each other using language-agnostic APIs. These services are small, highly

decoupled and focus on doing a small task, facilitating a modular approach to system-

building.https://en.wikipedia.org/wiki/Microservices

Page 46: Build Web Applications using Microservices on Node.js and Serverless AWS

Microservices Architecture

Keynote GOTO Conference: Microservices by Martin Fowler - https://www.youtube.com/watch?v=wgdBVIX9ifA

State of the Art in Microservices - https://www.youtube.com/watch?v=nMTaS07i3jk

Sam Newman atThoughtWorksLondon 2015:Deploying and OperatingMicroservices - https://www.youtube.com/watch?v=OTSlg7_y3bA

Page 47: Build Web Applications using Microservices on Node.js and Serverless AWS

Speeding Up Digital Platforms on AWS

Deploy in weeksLive for years

Deploy in minutesLive for weeks

Deploy in secondsLive for minutes/hours

Deploy in millisecondsLive for seconds

On-Premises Amazon EC2 Amazon ECS AWS Lambda

Page 48: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 49: Build Web Applications using Microservices on Node.js and Serverless AWS

Powered by AWS Lambda

Page 50: Build Web Applications using Microservices on Node.js and Serverless AWS

AWS Lambda in Action

• AWS Lambda scaled with no effort for us

• 70M+ invocations / day• 10K+ concurrent invocations / second

Page 51: Build Web Applications using Microservices on Node.js and Serverless AWS

Web Apps Hosting / Reference Architecture

Availability Zone A Availability Zone B

Auto Scaling Group

Auto Scaling Group

www.example.com

static.example.com

webservers

webservers

appservers

appservers

• Scales in minutes• Huge challenge for breaking

news, viral content, or attacks

• Reduced operational complexity• Requires DevOps with experience

• Flexible choice of technology• Requires devs with rich skill set

• Cost-effective• Over-provisioning and over-paying

Page 52: Build Web Applications using Microservices on Node.js and Serverless AWS

AWS Lambda in Action

• AWS Lambda scaled with no effort for us

• 70M+ invocations / day• 10K+ concurrent invocations / second

• AWS Lambda made it really easy for us

• Comes pre-scaled and charges in 100ms blocks• No under- or over-provisioning (by design)• Developers love it (especially frontend JS folks)• DevOps still in play mode (learning to build ops code)

Page 53: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 54: Build Web Applications using Microservices on Node.js and Serverless AWS

Tips and Tricks

• AWS Lambda is continuously evolving

• Set up alarms for all 4 Lambda metrics in Amazon CloudWatch• Avoid S3 throttling by integrating S3 => SNS => Lambda• Beware of potential infinite loops

Page 55: Build Web Applications using Microservices on Node.js and Serverless AWS

Tips and Tricks

• AWS Lambda is continuously evolving

• Set up alarms for all 4 Lambda metrics in Amazon CloudWatch• Avoid S3 throttling by integrating S3 => SNS => Lambda• Beware of potential infinite loops

• Microservices are game changers

• The shorter TTL, the more secure it becomes• First, build a service or a feature• Next, break it down into microservices

Page 56: Build Web Applications using Microservices on Node.js and Serverless AWS

Tips and Tricks – From Monolithic Approach

applicationsdevelopers

Build Test Release

development cycle

Page 57: Build Web Applications using Microservices on Node.js and Serverless AWS

Tips and Tricks – To Microservices Approach

applicationsdevelopers

Build Test Release

development cycle

Build Test Release

Build Test Release

Build Test Release

Build Test Release

Build Test Release

Build Test Release

Page 58: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 59: Build Web Applications using Microservices on Node.js and Serverless AWS

Demo: todo.deep.mg

• Go to the GitHub repository• github.com/MitocGroup/deep

-microservices-todo-app

• Follow the steps from Getting Started to build and deploy

• todo.deep.com

Page 60: Build Web Applications using Microservices on Node.js and Serverless AWS

Let’s Recap

Page 61: Build Web Applications using Microservices on Node.js and Serverless AWS

Recap• Reference architecture for web

application hosting on AWS

• Transformed to serverless architecture on AWS

• Microservices Architecture Powered by AWS Lambda

Page 62: Build Web Applications using Microservices on Node.js and Serverless AWS

Recap• Reference architecture for web

application hosting on AWS

• Transformed to serverless architecture on AWS

• Microservices Architecture Powered by AWS Lambda

• Tips and tricks

applicationsdevelopers

Build Test Release

development cycle

Build Test Release

Build Test Release

Build Test Release

Build Test Release

Build Test Release

Build Test Release

Page 63: Build Web Applications using Microservices on Node.js and Serverless AWS

Agenda• Web Apps Hosting on AWS

• Reference Architecture• Serverless Architecture• Demo: Setup Serverless AWS

• Microservices Architecture• Powered by AWS Lambda• Tips and Tricks• Demo: todo.deep.mg

• Q&A + Next Steps

Page 64: Build Web Applications using Microservices on Node.js and Serverless AWS

Q&A + Next Steps

github.com/MitocGroup medium.com/@[email protected]

http://www.meetup.com/nodejs/events/226713968

Thanks:

Matt Walters from Nodejs NYC Meetup

Hosting Team from Shutterstock

Page 65: Build Web Applications using Microservices on Node.js and Serverless AWS

Credits and Thanks• Slide 3: Digital Platforms Challenges

• http://www.buzzfeed.com/daozers/what-its-like-to-work-on-buzzfeeds-tech-team-during-record-t#.axR6WG9Yr• http://www.dailydot.com/crime/new-york-magazine-ddos-bill-cosby-cover/• http://www.cio.in/topstory/flipkart%E2%80%99s-cto-explains-the-xiaome-launch-outage

• Slide 4: Digital Platforms Challenges• http://www.slideshare.net/Radware/radware-cmg2014-tammyevertsslowtimevsdowntime• http://www.statuscast.com/application-downtime-according-to-idc-gartner-and-others• https://press.kaspersky.com/files/2014/11/B2B-International-2014-Survey-DDoS-Summary-Report.pdf

• Slide 19: AWS re:Invent 2014• https://venturebeat.com/wp-content/uploads/2014/11/aws-reinvent-lambda.png

• Slide 20: AWS Summit NY 2015• https://d0.awsstatic.com/events/aws-hosted-events/2015/AWS-Global-Summit-Series/new-york/press-room/introducing-amazon-api-

gateway.jpg

• Slide 46: Microservices Architecture• https://www.youtube.com/watch?v=nMTaS07i3jk - State of the Art in Microservices by Adrian Cockcroft• https://www.youtube.com/watch?v=wgdBVIX9ifA - Microservices by Martin Fowler• https://www.youtube.com/watch?v=OTSlg7_y3bA - Deploying and Operating Microservices by Sam Newman


Top Related