BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions...

41
BARCELONA ©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved

Transcript of BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions...

Page 1: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

BARCELONA

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

Page 2: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

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

From Monolithic to MicroservicesEvolving Architecture Patterns in the Cloud

Daniele Stroppa, AWS Solutions Architect

Teo Ruiz, VP Engineering @ Jobandtalent

Page 3: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.
Page 4: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Common Challenges and

Patterns

Page 5: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Monolithic Microservices

• Simple deployments

• Binary failure modes

• Inter-module refactoring

• Technology monoculture

• Vertical scaling

• Partial deployments

• Graceful degradation

• Strong module boundaries

• Technology diversity

• Horizontal scaling

Page 6: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

• Organization

• Discovery

• Data management

• Deployment

• I/O explosion

• Monitoring

Common Challenges and Patterns

Page 7: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Organization

Page 8: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Monolithic Ownership

• Organized on technology capabilities

UI Team

DBA Team

App Logic Team

Web Tier

App Tier

DB

Organizational Structure Application Architecture

Page 9: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Microservices Ownership

• Organized on business responsibilities

Login

Registration

Order

Personalization

Accounts team

Mobile

Personalization team Mobile team

Page 10: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Microservices Ownership

• Requirements

• Technology selection

• Development

• Quality

• Deployment

• Support

Page 11: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

How to Be a Good Citizen (Service Consumer)

• Design for failure

• Expect to be throttled

• Retry w/ exponential backoff

• Degrade gracefully

• Cache when appropriate

Page 12: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

How to Be a Good Citizen (Service Provider)

• Publish your metrics

• Protect yourself

• Keep your implementation details private

• Maintain backwards compatibility

Page 13: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Amazon API Gateway

• Throttling (global and per-method)

• Caching (with TTLs and invalidation)

• Monitoring (RPS, latency, error rate)

• Versioning

• Authentication

Page 14: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Discovery

Page 15: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Use DNS

• Convention-based naming

<service-name>-<environment>.domain.com

shoppingcart-gamma.example.com

<service-name>.<environment>.domain.com

shoppingcart.gamma.example.com

Page 16: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Use a Dynamic Service Registry

• Avoids the DNS TTL issue

• More than service registry & discovery– Configuration management

– Health checks

• Plenty of options– ZooKeeper (Apache)

– Eureka (Netflix)

– Consul (HashiCorp)

– SmartStack (Airbnb)

Page 17: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Data management

Page 18: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Challenge: Centralized Database

Monolithic applications typically have a monolithic data store:

• Difficult to make schema changes

• Technology lock-in

• Vertical scaling

• Single point of failure

user-svc account-svccart-svc

DB

Page 19: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Centralized Database – Anti-pattern

Monolithic applications typically have a monolithic data store:

• Difficult to make schema changes

• Technology lock-in

• Vertical scaling

• Single point of failure

user-svc account-svccart-svc

DB

Page 20: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Decentralized Data Stores

• Each service chooses its

data store technologies

• Low impact schema

changes

• Independent scalability

• Data is gated through

the service API

account-

svc

cart-

svc

DynamoDB RDS

user-

svc

ElastiCache RDS

Page 21: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Challenge: Transactional Integrity

• Use a pessimistic model• Handle it in the client

• Add a transaction manager / distributed locking service

• Rethink your design

• Use an optimistic model• Accept eventual consistency

• Retry (if idempotent)

• Fix it later

• Write it off

Page 22: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Challenge: Aggregation

• Pull: Make the data available via your service API

• Push: To Amazon S3, Amazon CloudWatch, or

another service you create

• Pub/sub: Via Amazon Kinesis or Amazon SQS

Page 23: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Deployment

Page 24: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Continuous Delivery & Continuous

Deployment

• Create the right build pipeline for each service

• AWS CodeDeploy

• AWS Elastic Beanstalk

• Jenkins, CircleCI, Travis,…

Integration

& perf tests

Build &

unit testsbeta Produser-svc

Integration &

perf tests

Build &

unit testsbeta gamma Prodcart-svc

Page 25: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

AWS CodePipeline

Page 26: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Multiple Services per Container/Instance

• Independent monitoring

• Independent scaling

• Clear ownership

• Immutable deployments

user-svc

cart-svc

account-svc

Container or instance

Page 27: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Multiple Services per Container/Instance – Anti-pattern

• Independent monitoring

• Independent scaling

• Clear ownership

• Immutable deployments

user-svc

cart-svc

account-svc

Container or instance

Page 28: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Single Service per Container/Instance

• Independent monitoring

• Independent scaling

• Clear ownership

• Immutable deployments

user-svc

container or instance

account-svc

cart-svc

container or instance

container or instance

Page 29: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

…Or Just Use AWS Lambda

LambdaAPI Gateway

RDS

DynamoDB

Page 30: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

I/O explosion

Photo credit: maf04 (CC by-sa-2.0)

Page 31: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Challenge: Request Multiplication

checkout-

svc

cart-svc

account-svc

user-svc

Single request

Page 32: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Add Client Caching

checkout-

svc

cart-svc

account-svc

user-svc

Single request

cache

user & account cache

Page 33: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Challenge: Hotspots

cart-svc order-svcshipping-

svc

user-svc

single request

get (user x, col y) get (user x, col y) get (user x, col y)

Page 34: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Use Dependency Injection

cart-svc order-svcshipping-

svc

user-svc

single request

get (user x, col y)

(user x, col y) (user x, col y)

Page 35: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Monitoring

Page 36: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Challenge: monitoring

• Publish externally relevant metrics– Latency

– RPS

– Error rate

• Understand internally relevant metrics– Basic – CloudWatch

– OS

– Application

Page 37: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Challenge: Logging

• Pick a common log aggregation solution

• Agree on log entry formats

• Use naming conventions

• Agree on correlation strategy

Page 38: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Challenge: Correlating Requests

ui-svc catalog-

svc

checkout-

svc

shipping-

svc

payment-

svc

request

Page 39: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

Use Correlation IDs

• 09-02-2015 15:03:24 ui-svc INFO [uuid-123] ……

• 09-02-2015 15:03:25 catalog-svc INFO [uuid-123] ……

• 09-02-2015 15:03:26 checkout-svc ERROR [uuid-123] ……

• 09-02-2015 15:03:27 payment-svc INFO [uuid-123] ……

• 09-02-2015 15:03:27 shipping-svc INFO [uuid-123] ……

ui-svc catalog-

svc

checkout-

svc

shipping-

svc

payment-

svc

request correlation id:

“uuid-123”correlation id:

“uuid-123”

Page 40: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

What did we cover?

• Ownership

• Discovery

• Data management

• Deployment

• I/O explosion

• Monitoring

Page 41: BARCELONA - Amazon S3 · Evolving Architecture Patterns in the Cloud Daniele Stroppa, AWS Solutions Architect ... (Netflix) – Consul (HashiCorp) – SmartStack (Airbnb) Data management.

BARCELONA