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 AWSaws-de-media.s3.amazonaws.com/images/AWS_Summit... · Why are we here today?

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

© 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

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

Why are we

here today?

© 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

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

What is Reactive Architecture?

What is Reactive Architecture?

© 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

Software moves

faster today

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

Traditional style of

applications cannot deliver

on these requirements any

longer

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

Responsive

Elastic Resilient

Message-driven

Reactive Applications

© 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

© 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

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

Reactive Architecture

• Loosely coupled

• Location independent

• Easy to extend and maintain

• Push-based

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

Microservices

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

Microservices should be

stateless.

Keep state in managed services.

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

No shared libraries or

shared SDKs.

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

Avoid

Host-Affinity.

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

Use lightweight

protocols for

communication.

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

Use mechanisms for

registration.

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

How to build Reactive Architectures

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

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

High Level Architecture

© 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

© 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

© 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

© 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

© 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

© 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

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

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

Application Architecture

© 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

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

Application Architecture

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

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

Application Architecture

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

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

Application Architecture

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

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

Application Architecture

© 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

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

Subscribe to event bus

Send data to Kinesis stream

Convert data

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

Application Architecture

© 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

© 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

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

AWS Lambda

Application Architecture

© 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

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

Iterate over

batch of events

Unmarshal

protobuf messages

Map to struct

© 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

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

Deployment

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

Deployment

AWS CloudFormation

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

Lambda function

configuration

S3 Bucket

and

filename

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

ECS

Launch

Type

CPU and

RAM

Network

mode

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

Amazon API

GatewayAWS Lambda Amazon

DynamoDB

Go build something!

© 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)

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

Question? Ask this guy

at the Ask an Architect

booth:

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

Please complete the session

survey in the summit mobile app.

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

Thank you!