aws re:invent 2016: serverless computing patterns at expedia (svr306) )

73
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Kuldeep Chowhan 12/01/2016 SVR306 Serverless Computing Patterns @ Expedia, Inc.

Upload: amazon-web-services

Post on 07-Jan-2017

173 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

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

Kuldeep Chowhan

12/01/2016

SVR306

Serverless Computing

Patterns @ Expedia, Inc.

Page 2: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Kuldeep Chowhan

Principal Engineer @ Expedia, Inc.

@this_is_kuldeep

Page 3: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Expedia, Inc., at a glance

Notes: Expedia, Inc. results shown for 2015. 1Gross bookings is an operating and statistical metric that captures the total dollar value, generally inclusive of taxes and fees, of travel services booked by

our customers; gross bookings excludes HomeAway. 2Monthly visits based on data for Brand Expedia (including Travelocity and Wotif), Hotels.com, Orbitz Worldwide, HomeAway, trivago and Hotwire

combined during 2015.

Sources: Overall travel industry growth rate based on Phocuswright data for 2015 Y/Y.

Largest travel company

$60B gross bookings1

$6.6B revenue growing

>2X faster vs. industry

18K+ employees globally

450M+ monthly site visits2

75+ countries served1.5M+ lodging options

for travelers

Page 4: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

What to Expect from the Session

• AWS Lambda Usage at Expedia

• Serverless Apps Creation at Expedia

• Different Serverless App architectures

• Demo

Page 5: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

AWS Usage @ Expedia

Page 6: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )
Page 7: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

What is AWS Lambda?

• Run code for virtually any type of application

• No Servers to Manage

• Zero administration

• Continuous Scaling

• Sub second Metering

Page 8: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

How does AWS Lambda works?

Page 9: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Primer – AWS Lambda

Creation

Page 10: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )
Page 11: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )
Page 12: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )
Page 13: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Demo

Page 14: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Serverless Architectures

@ Expedia

Page 15: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD Platform utilizing

Serverless Computing

Page 16: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Page 17: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Page 18: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Page 19: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Lambda

Decider/Decorator

Page 20: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Amazon

SNSLambda

Decider/Decorator

Page 21: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Amazon

SNS

Lambda

Deployment

Config

Changes

Lambda

Decider/Decorator

Page 22: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Amazon

SNS

Lambda

Deployment

Config

Changes

Amazon

Elasticsearch Service

Lambda

Decider/Decorator

Page 23: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Amazon

SNS

Lambda

Deployment

Config

Changes

Lambda

Developers

pushing to

master

directly

Amazon

Elasticsearch Service

Lambda

Decider/Decorator

Page 24: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Amazon

SNS

Lambda

Deployment

Config

Changes

Lambda

Developers

pushing to

master

directly

Amazon

Elasticsearch Service

Amazon

SES

Lambda

Decider/Decorator

Page 25: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Amazon

SNS

Lambda

Deployment

Config

Changes

Lambda

App Details

Changes

Lambda

Developers

pushing to

master

directly

Amazon

Elasticsearch Service

Amazon

SES

Lambda

Decider/Decorator

Page 26: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

CI/CD System Platform utilizing Serverless Computing

GitHub

Webhooks

(Push Events)

Amazon API

Gateway

Amazon

SNS

Lambda

Deployment

Config

Changes

Lambda

App Details

Changes

Lambda

Developers

pushing to

master

directly

Amazon

DynamoDBAmazon

Elasticsearch Service

Amazon

SES

Lambda

Decider/Decorator

Page 27: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )
Page 28: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Demo

Page 29: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for Expedia’s

AWS Infrastructure

Governance

Page 30: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrail

Page 31: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Page 32: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

Lambda

Page 33: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

Page 34: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Page 35: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Dispatcher

Lambda

Page 36: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Dispatcher

Lambda

Amazon

SNS

Page 37: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Dispatcher

Lambda

Amazon

SNSValidator

Lambda

Page 38: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Dispatcher

Lambda

Amazon

SNSValidator

Lambda

Amazon

SNS

Page 39: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Dispatcher

Lambda

Amazon

SNSValidator

Lambda

Destroyer

Lambda

Amazon

SNS

Page 40: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Dispatcher

Lambda

Amazon

SNSValidator

Lambda

Destroyer

Lambda

Amazon

SNSAmazon

SNS

Page 41: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Dispatcher

Lambda

Amazon

SNSValidator

Lambda

Destroyer

LambdaACK

Lambda

Amazon

SNSAmazon

SNS

Page 42: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Control System for our AWS Infrastructure Governance

AWS

CloudTrailS3 Bucket

Collector

LambdaDynamoDB

Events Table

CloudWatch

Events -

Schedule

Dispatcher

Lambda

Amazon

SNSValidator

Lambda

Destroyer

LambdaACK

Lambda

DynamoDB

Sim Table

DynamoDB

History Table

Amazon

SNSAmazon

SNS

Page 43: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Demo

Page 44: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Test & Learn Dashboard

Aggregations

Page 45: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Test & Learn Dashboard Aggregations

Amazon

DynamoDB

Stream

Page 46: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Test & Learn Dashboard Aggregations

Amazon

DynamoDB

Stream

Amazon

Lambda

Page 47: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Test & Learn Dashboard Aggregations

Amazon

DynamoDB

Stream

Amazon

LambdaAmazon

SQS

Page 48: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Test & Learn Dashboard Aggregations

Amazon

DynamoDB

Stream

Amazon

LambdaAmazon

SQS

Page 49: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to trigger

Typeahead Memory Refresh

Page 50: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Typeahead (ESS – Expedia Suggest Service)

• Typeahead is the first feature that users interact with while

searching for what they are looking for, so providing best

possible suggestions to them is very essential

• ElasticCache Redis + IN-MEMORY data for cache misses

• 25 GB Heap Size per EC2 Instance

• Daily refresh of this data and it takes 15 mins to load the data

Page 51: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )
Page 52: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

The Problem

• Currently each instance that runs ESS in prod has to have

enough memory to support this data refresh process while

still serving requests

• When the occupied heap reaches its maximum limit, the

application:

• often freezes resulting in not able to recommend right

suggestions to the customers

• pauses until garbage collection completes discarding the

large, outdated BLOB from memory

Page 53: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Solution

• Eliminate data refresh process via crontab

• Launch N new instances by modifying the Auto Scaling group

every day during refresh time

• Modify Auto Scaling group to terminate N instances using

OldestFirst EC2 instance termination policy when 2N

instances are InService

• Schedule AWS Lambda to own this responsibility everyday to

scale up and down

Page 54: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale up the

Auto Scaling group

Page 55: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale up the Auto Scaling group

CloudWatch

Events -

Schedule

Page 56: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale up the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Page 57: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale up the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Validate

ASG for

Scale UP

Page 58: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale up the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Validate

ASG for

Scale UP

Update

Reference Tag

on ASG

Abort & Exit

Failure

Page 59: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale up the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Validate

ASG for

Scale UP

Update

Reference Tag

on ASG

Scale up ASG

Abort & Exit

Failure

Failure

Page 60: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale up the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Validate

ASG for

Scale UP

Update

Reference Tag

on ASG

Scale up ASG

Notify & Exit

Abort & Exit

Failure

Failure

Failure

Page 61: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale down

the Auto Scaling group

Page 62: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale down the Auto Scaling group

CloudWatch

Events -

Schedule

Page 63: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale down the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Page 64: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale down the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Validate ASG

for Scale

DOWN

Page 65: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale down the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Validate ASG

for Scale

DOWN

Scale

DOWN ASG

Abort & Exit

Failure

Page 66: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale down the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Validate ASG

for Scale

DOWN

Scale

DOWN ASG

Remove the

tag from ASG

Abort & Exit

Failure

Failure

Page 67: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Using Lambda to scale down the Auto Scaling group

CloudWatch

Events -

Schedule

Amazon

Lambda

Validate ASG

for Scale

DOWN

Scale

DOWN ASG

Remove the

tag from ASG

Notify & Exit

Abort & Exit

Failure

Failure

Failure

Page 68: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Traveler Profile Generation

Using Homegrown Lambda

Page 69: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )
Page 70: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Benefits of Serverless Computing

• Cost

• Operations

• Scale

• Opportunity

• Time to market

Page 71: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

What’s next?

• Improve API Gateway integration in Lambda creation process

• Add support for logging to different sources other than

CloudWatch

• Process hotel images using Lambda

Page 72: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Thank you!

Kuldeep Chowhan

@this_is_kuldeep

Page 73: AWS re:Invent 2016: Serverless Computing Patterns at Expedia (SVR306) )

Remember to complete

your evaluations!