the journey to serverless

51
1 The Journey to Serverless Çağatay Gürtürk, Martin Lindenberg Software Engineering, Home24 AG

Upload: trinhanh

Post on 14-Feb-2017

235 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: The Journey to Serverless

1

The Journey to ServerlessÇağatay Gürtürk, Martin Lindenberg Software Engineering, Home24 AG

Page 2: The Journey to Serverless

2

Agenda

• About Home24

• Our Journey to AWS and Serverless Architectures

• Use cases of Serverless Applications

• Caveats and Solutions

• Question and Answer Session

Page 3: The Journey to Serverless

3

About home24

Europe's largest online only retailer for home furniture and living

Active in 7 countries, 5 different languages

100+ IT Employees

Page 4: The Journey to Serverless

4

Desktop website

4.2 million visitors per month23 millions page views per month

Page 5: The Journey to Serverless

5

• The Best Shopping Application in 2015 in Germany

• Selected as Featured app many times by App Store

Available in IOS and Android

80000+ Monthly Active Users

Mobile applications

Page 6: The Journey to Serverless

6

There is always an invisible part of the

Iceberg.

Page 7: The Journey to Serverless

7

Endless stuff to deal with by 100+ people and 10+ teams

Order Processing

Business Intelligence Tools

Supporting Services for Customer Facing

Apps

Financial Tools

Page 8: The Journey to Serverless

8

Home24 was launched with a modified

Magento software

MAGENTO

Monolithic PHP application on on-

premise infrastructure

OWN SOFTWARE

MICROSERVICE AND CLOUD

20152011 2013

Our technical journey

Switched to Microservice

architecture. Deprecated PHP: Every new project

in GO, JAVA and JS

Migrated to AWS

Page 9: The Journey to Serverless

9

Why Microservices?

• Teams can choose the right tool for every service

• Every team can hold the ownership of a service

• Every team can manage its own infrastructure

Thus,

• Increases autonomy for teams

• Distributes the infrastructural risks

Page 10: The Journey to Serverless

10

AWS Migration

Not only a provider change, but a mindset change

Page 11: The Journey to Serverless

11

Why AWS?

• Cost efficient

• Scalable

• Requires less operation effort

Page 12: The Journey to Serverless

12

What is serverless?

• Every service managed by AWS

• Pay as you go. No need for 24/7 running infrastructure

• Less operation effort

• Focus on Dev of business requirements instead of Ops

Page 13: The Journey to Serverless

13

On-Premise Serverless

Not only Lambda but…

And more services…

Page 14: The Journey to Serverless

14

Case Studies

Page 15: The Journey to Serverless

15

Serverless Case Studies

• Parcel Service (Simple) – Our first attempt. Basic REST API

• Margin DB (Medium) – Responding to cloud events with zero custom infrastructure

• Voucher Manager (Expert) – Fully serverless application using Cognito and Lambda

Page 16: The Journey to Serverless

16

Parcel Service

Page 17: The Journey to Serverless

17

Parcel Service

Stores delivery and packaging informationfor each product

Planned as new microservice to break themonolith

Less than 10000 requests per day

Response time of less than 100ms isrequired

Page 18: The Journey to Serverless

18

Previous stack for new microservices

Page 19: The Journey to Serverless

19

Serverless stack

API Gateway

Page 20: The Journey to Serverless

20

Deployment options

Serverless framework

Cloudformation

Manually (Using CLI scripts or AWSConsole)

Page 21: The Journey to Serverless

21

Serverless stack

Page 22: The Journey to Serverless

22

The Limitations

Number of supported languages arelimited. (We like GO more then Node!)

Container startup affects response times ofsome requests

SNI-Support required

API Gateway = public visible endpoint

Page 23: The Journey to Serverless

23

The Wins

Pay only for usage(+ 1 million requests free per month)

API‘s can be secured with api keys

More memory = More CPU = Lower latency

Response times down to 30ms are possible

Page 24: The Journey to Serverless

24

Price comparison

Page 25: The Journey to Serverless

25

Margin DB

Page 26: The Journey to Serverless

26

Margin DB

How much profit do we make per product?

More than 100.000 products with multiplevarieties

Daily recalculation

Page 27: The Journey to Serverless

27

Margin DB: event based workers

Page 28: The Journey to Serverless

28

Cost

Service Usage Cost ($)

S3 170 GB-Mo 5.01

Lambda 39 million sec. 690

SNS 110 Millions Req. 45

SQS 232 Millions Req. 116

SWF 38000 0.79

EC2 0 Hours 0!

Note: usage and cost information are approximate.

Previous EC2 cost was 800$ but it was difficult to scale

Page 29: The Journey to Serverless

29

Voucher Manager

Page 30: The Journey to Serverless

30

Lets users store their vouchers in their mobile devices and use them in their purchases with 1-click

Lets us send new vouchers or remove old ones over the air

Voucher Manager

Project started with AWS

Page 31: The Journey to Serverless

31

Voucher Manager

Page 32: The Journey to Serverless

32

Voucher Manager

Page 33: The Journey to Serverless

33

Cognito & Lambda

Stores user data in cloud with zero-backend

code

Support custom authentication as well as

social logins

Lambda hooks for more functionality

+

Page 34: The Journey to Serverless

34

Case 1: Users add a voucher on mobile device

Page 35: The Journey to Serverless

35

Case 1: Users add a voucher on mobile device

Nerdy LLDB output

Objective-C Code - Not for home use

Insanely easy implementation on mobile applicationOnly use AWS Cognito SDK

Page 36: The Journey to Serverless

36

Case 1: Users add a voucher on mobile device

Page 37: The Journey to Serverless

37

Case 2: Voucher data changes on Backend

We have an auxiliary DynamoDB tableto keep this relationship

Page 38: The Journey to Serverless

38

Case 3: Add Voucher from other channels

Page 39: The Journey to Serverless

39

Cost

Service Usage Cost ($)

API Gateway 2.1 million req. 7.57

Lambda 385000 seconds 6.19

Cognito Sync 344.410 Sync operations 5.17

Amazon EC2 0 Hours 0!

Note: usage and cost information are approximate. Negligible costs of SNS and DynamoDB are not included.

Page 40: The Journey to Serverless

40

How we build?

Page 41: The Journey to Serverless

41

Tooling

• Native JAVA• Homemade deployment tools built by Gradle and Cloudformation

• Node.js• Serverless framework (Formerly JAWS)

Page 42: The Journey to Serverless

42

Problems and Solutions

Encountered problems, fixed and addressed ones

Page 43: The Journey to Serverless

43

AWS Lambda Problems and Solutions

Problem: Less control over server optimizations

Solution: It is natural. Still you can increase RAM and CPU usage

Page 44: The Journey to Serverless

44

AWS Lambda Problems and Solutions

Problem: Lack of standard deployment tools

Solution: AWS is not providing any automatic deployment tool but there are open source solutions or it is easy to develop your own

Page 45: The Journey to Serverless

45

AWS Lambda Problems and Solutions

Problem: Long cold start times. (Especially on JVM.)

Solution: Keep it warm. Invoke the function periodically using Route53 Health Check or Cloudwatch scheduled event

Page 46: The Journey to Serverless

46

API Gateway Problems and Solutions

Problem: Slower than classical EC2-ELB stack

Solution: According to our experience, for many applications API Gateway’s performance is satisfying. But if you are developing a really low-latency service, API Gateway might not be the right solution at the moment

Page 47: The Journey to Serverless

47

API Gateway Problems and Solutions

Problem: ACM support, GZIP compression and HTTP caching are missing

Solution: Put a Cloudfront distribution in front of API Gateway. With Cloudfront you can enable all these features

Page 48: The Journey to Serverless

48

DynamoDB Problems and Solutions

Problem: Auto-scaling is missing

Solution: Use Dynamic DynamoDB or implement a custom Lambda autoscalingmechanism.

Fingers crossed for Autoscaling support from AWS

Dynamic DynamoDB available at: https://github.com/sebdah/dynamic-dynamodb

Page 49: The Journey to Serverless

49

Future

Running the whole platform without EC2 Instances

Page 50: The Journey to Serverless

50

Selection criteria for Serverless

• Performance requirements

• Language/Framework requirements

• Scalability and High Availability Requirements

• Budget Constraints

Page 51: The Journey to Serverless

51

QUESTIONS & ANSWERS SESSION