51
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Sascha Möllering Solutions Architect, @sascha242, Amazon Web Services Germany GmbH Reactive Microservices Architecture on AWS

Reactive Microservices Architecture on AWS

  • Upload
    others

  • View
    18

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Reactive Microservices Architecture on AWS

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

Sascha Möllering

Solutions Architect, @sascha242, Amazon Web Services Germany GmbH

Reactive Microservices Architecture

on AWS

Page 2: Reactive Microservices Architecture on AWS

https://secure.flickr.com/photos/mgifford/4525333972

Why are we

here today?

Page 3: Reactive Microservices Architecture on AWS

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

Agenda

What is Reactive Architecture?

How to build Reactive Architectures on AWS?

Application Architecture

Deployment

Page 4: Reactive Microservices Architecture on AWS

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

What is Reactive Architecture?

What is Reactive Architecture?

Page 5: Reactive Microservices Architecture on AWS

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

Database

Synchronous

User waits

for update

N-Tier architecture

StorageAPI

Frontend

Servers

Poll PollQueries

Page 6: Reactive Microservices Architecture on AWS

Software moves

faster today

Page 7: Reactive Microservices Architecture on AWS

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

Traditional style of

applications cannot deliver

on these requirements any

longer

Page 8: Reactive Microservices Architecture on AWS

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

Responsive

Elastic Resilient

Message-driven

Reactive Applications

Page 9: Reactive Microservices Architecture on AWS

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

Reactive Architecture

“A development model focusing

on the observation of data

streams, reacting on changes,

and propagating them.”

Reactive programming

“An architecture style used to

build responsive and robust

distributed systems based on

asynchronous message-

passing.”

Reactive system

Page 10: Reactive Microservices Architecture on AWS

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

Reactive Architecture

• Asynchronous message passing

• Non-blocking

• Higher throughput

• Efficient compute utilization and lower costs

Page 11: Reactive Microservices Architecture on AWS

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

Reactive Architecture

• Loosely coupled

• Location independent

• Easy to extend and maintain

• Push-based

Page 12: Reactive Microservices Architecture on AWS

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

Microservices

Page 13: Reactive Microservices Architecture on AWS

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

Microservices should be

stateless.

Keep state in managed services.

Page 14: Reactive Microservices Architecture on AWS

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

No shared libraries or

shared SDKs.

Page 15: Reactive Microservices Architecture on AWS

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

Avoid

Host-Affinity.

Page 16: Reactive Microservices Architecture on AWS

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

Use lightweight

protocols for

communication.

Page 17: Reactive Microservices Architecture on AWS

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

Use mechanisms for

registration.

Page 18: Reactive Microservices Architecture on AWS

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

How to build Reactive Architectures

on AWS?

Page 19: Reactive Microservices Architecture on AWS

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

Customer visits

websiteCustomer clicks

on a banner

Customer buys

from online-shop

Example use case

Banner

Page 20: Reactive Microservices Architecture on AWS

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

High Level Architecture

Page 21: Reactive Microservices Architecture on AWS

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

Amazon Elastic

Container Service

Application

Load Balancer

Amazon Elastic

Container Registry

Amazon

Kinesis Data

Streams

Amazon

Kinesis Data

Streams

AWS

Lambda

AWS

LambdaAmazon

ElastiCache

Data ingestion

Core data

update

Amazon

DynamoDB

Core data updates

Data Collection

Page 22: Reactive Microservices Architecture on AWS

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

High Level Architecture

• Amazon ECS and Docker used for the main

application

• Fargate launch type

• Resiliency and elasticity implemented by

using auto scaling

Amazon Elastic

Container Service

Page 23: Reactive Microservices Architecture on AWS

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

High Level Architecture

• AWS Lambda functions consume messages

• Persist data in NoSQL-store

• Update core-data in Redis

• Send notifications to main application

• Resiliency and scalability part of the service

AWS Lambda

Page 24: Reactive Microservices Architecture on AWS

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

High Level Architecture

• Amazon Kinesis Data Streams used to

decouple components

• Asynchronously push event data to NoSQL-

store

• Update core-data in Redis

Amazon Kinesis

Data Streams

Page 25: Reactive Microservices Architecture on AWS

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

High Level Architecture

• Amazon ElastiCache with Redis 3 engine

• Multi-AZ setup with failover and one shard

• Used to store core-data

• Notification channel

• Redis supports pub/sub

Amazon ElastiCache

Page 26: Reactive Microservices Architecture on AWS

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

High Level Architecture

• Amazon DynamoDB NoSQL-store used to

persist event-data

• Backup and restore

• Encryption at rest

Amazon DynamoDB

Page 27: Reactive Microservices Architecture on AWS

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

Page 28: Reactive Microservices Architecture on AWS

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

Application Architecture

Page 29: Reactive Microservices Architecture on AWS

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

Application

Load Balancer

Amazon

Kinesis Data

Streams

Amazon

Kinesis Data

Streams

AWS

Lambda

AWS

LambdaAmazon

ElastiCache

Data ingestion

Core data

update

Amazon

DynamoDB

Core data updates

You are here now!Data Collection

Amazon Elastic

Container Service

Amazon Elastic

Container Registry

Page 30: Reactive Microservices Architecture on AWS

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

Application Architecture

Page 31: Reactive Microservices Architecture on AWS

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

Source: http://vertx.io/docs/guide-for-java-devs/

Application Architecture

Page 32: Reactive Microservices Architecture on AWS

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

Source: http://vertx.io/docs/guide-for-java-devs/

Application Architecture

Page 33: Reactive Microservices Architecture on AWS

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

Source: http://vertx.io/docs/guide-for-java-devs/

Application Architecture

Page 34: Reactive Microservices Architecture on AWS

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

Application Architecture

• HttpVerticle: exposes HTTP endpoint

• CacheVerticle: implements L1 cache

• RedisVerticle: implements Redis access

• KinesisVerticle: messages to Amazon Kinesis Data

Stream

Page 35: Reactive Microservices Architecture on AWS

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

Subscribe to event bus

Send data to Kinesis stream

Convert data

Page 36: Reactive Microservices Architecture on AWS

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

Application Architecture

Page 37: Reactive Microservices Architecture on AWS

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

Subscribe to EB

Subscribe to

Redis channel

Consume

data from

event bus

Send data to

cache verticle

Page 38: Reactive Microservices Architecture on AWS

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

Application

Load Balancer

Amazon

Kinesis Data

Streams

Amazon

Kinesis Data

Streams

AWS

Lambda

AWS

LambdaAmazon

ElastiCache

Data ingestion

Core data

update

Amazon

DynamoDB

Core data updates

You are here now!Data Collection

Amazon Elastic

Container Registry

Amazon Elastic

Container Service

Page 39: Reactive Microservices Architecture on AWS

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

AWS Lambda

Application Architecture

Page 40: Reactive Microservices Architecture on AWS

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

Lambda considerations and best practices

AWS Lambda is stateless—architect accordingly

• Assume no affinity with underlying compute

infrastructure

• Local filesystem access and child process may not

extend beyond the lifetime of the Lambda request

Page 41: Reactive Microservices Architecture on AWS

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

Iterate over

batch of events

Unmarshal

protobuf messages

Map to struct

Page 42: Reactive Microservices Architecture on AWS

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

Design principles

• Use push instead of pull

• Avoid blocking calls

• Decouple your services using async message passing

• Keep state in managed services

• Use caching

Page 43: Reactive Microservices Architecture on AWS

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

Deployment

Page 44: Reactive Microservices Architecture on AWS

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

Deployment

AWS CloudFormation

Page 45: Reactive Microservices Architecture on AWS

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

Lambda function

configuration

S3 Bucket

and

filename

Page 46: Reactive Microservices Architecture on AWS

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

ECS

Launch

Type

CPU and

RAM

Network

mode

Page 47: Reactive Microservices Architecture on AWS

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

Amazon API

GatewayAWS Lambda Amazon

DynamoDB

Go build something!

Page 48: Reactive Microservices Architecture on AWS

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

Related Sessions

Container-based Architectures on AWS (Blackfoot)

Kubernetes Running on AWS (Blackfoot)

Serverless Architectural Patterns (Amelia)

Deep Dive into Concepts and Tools for Analyzing

Streaming Data on AWS (Coral)

Page 49: Reactive Microservices Architecture on AWS

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

Question? Ask this guy

at the Ask an Architect

booth:

Page 50: Reactive Microservices Architecture on AWS

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

Please complete the session

survey in the summit mobile app.

Page 51: Reactive Microservices Architecture on AWS

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

Thank you!