© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Sascha Möllering, Solutions Architect, @sascha242
07.11.2017
Reactive Architectures with
Microservices
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
https://secure.flickr.com/photos/mgifford/4525333972
Why are we
here today?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Agenda
• What is Reactive Architecture?
• How to build Reactive Architectures in AWS?
• Application Architecture
• Global Rollout
• Q&A
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What is Reactive Architecture?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Front-end
server
Internal
API
Internal
APIAPI
Poll
Poll
Database
Storage
Queries
Synchronous
User waits
for update
N-Tier architecture
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Software moves
faster today
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Traditional style of
applications cannot deliver
on these requirements any
longer
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Responsive
Elastic Resilient
Message-driven
Reactive Applications
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Reactive programming
“A development model focusing
on the observation of data
streams, reacting on changes, and
propagating them”
Reactive Architecture
Reactive system
“An architecture style used to
build responsive and robust
distributed systems based on
asynchronous message-passing.”
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Reactive Architecture
• Asynchronous message passing
• Non-blocking
• Higher throughput
• Effective hardware utilization and lower costs
• Loosely coupled
• Location independent
• Easy to extend and maintain
• Push-based
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microservices
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Microservices should be stateless.
Keep state in external systems.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Avoid
Host-Affinity.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Use lightweight
protocols for
communication.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Use mechanisms for
registration.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How to build Reactive
Architectures in AWS?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Example use case
Banner
Icon made by Freepik from www.flaticon.com
Customer visits
website
Customer clicks
on a banner
Customer buys
from online-shop
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
High Level Architecture
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECSApplication
Load Balancer
Amazon ECR
Kinesis
Stream
Kinesis
Stream
Lambda
function
Lambda
function
ElastiCache
cluster
Data ingestion
Core data
update
Amazon
DynamoDB
Core data updates
Data collection
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
High Level Architecture
• Amazon ECS and Docker used for the main
application
• Resiliency and Elasticity implemented by
using Auto Scaling
© 2017, 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
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
High Level Architecture
• Amazon Kinesis Streams used to decouple
components
• Asynchronously push event data to NoSQL-
store
• Update core-data in Redis
© 2017, 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
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
High Level Architecture
• Amazon DynamoDB NoSQL-store used to
persist event-data
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application Architecture
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECSApplication
Load Balancer
Amazon ECR
Kinesis
Stream
Kinesis
Stream
Lambda
function
Lambda
function
ElastiCache
cluster
Data ingestion
Core data
update
Amazon
DynamoDB
Core data updates
Data collection
You are here now!
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application Architecture
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application Architecture
Picture source: http://vertx.io/docs/guide-for-java-devs/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application Architecture
“Don’t block the event
loop!”
- Vert.x golden rule
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application Architecture
Picture source: http://vertx.io/docs/guide-for-java-devs/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application Architecture
Picture source: http://vertx.io/docs/guide-for-java-devs/
© 2017, 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 Stream
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Subscribe to EB
Send prepared data
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application Architecture
Cache
Rules
Everything
Around
Me
© 2017, 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
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECSApplication
Load Balancer
Amazon ECR
Kinesis
Stream
Kinesis
Stream
Lambda
function
Lambda
function
ElastiCache
cluster
Data ingestion
Core data
update
Amazon
DynamoDB
Core data updates
Data collection You are here now!
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application Architecture
AWS Lambda
© 2017, 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
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Kinesis event
processing
Iterate over
batch of events
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Global Rollout
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
16 Regions
44 Availability Zones
AWS Global Infrastructure
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Global Rollout
AWS CloudFormation
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Global Rollout
• Infrastructure as Code
• Create and manage resources with CloudFormation
templates
• CloudFormation template is used to deploy stacks
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Global Rollout
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Master Region
• One stream of data
• One region to process data
• Data has to be transferred
inter region
Global Rollout
Distributed Processing
• Data processing in every
region
• No unified view on data
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Summary
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Summary
• Reactive Architectures very good fit for AWS Cloud
• Microservices improve isolation
• AWS offers a lot of services for decoupled application
design
• Focus on business requirements, don’t reinvent the
wheel
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!

Reactive Architectures with Microservices

  • 1.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Sascha Möllering, Solutions Architect, @sascha242 07.11.2017 Reactive Architectures with Microservices
  • 2.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. https://secure.flickr.com/photos/mgifford/4525333972 Why are we here today?
  • 3.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Agenda • What is Reactive Architecture? • How to build Reactive Architectures in AWS? • Application Architecture • Global Rollout • Q&A
  • 4.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What is Reactive Architecture?
  • 5.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Front-end server Internal API Internal APIAPI Poll Poll Database Storage Queries Synchronous User waits for update N-Tier architecture
  • 6.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Software moves faster today
  • 7.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Traditional style of applications cannot deliver on these requirements any longer
  • 8.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Responsive Elastic Resilient Message-driven Reactive Applications
  • 9.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Reactive programming “A development model focusing on the observation of data streams, reacting on changes, and propagating them” Reactive Architecture Reactive system “An architecture style used to build responsive and robust distributed systems based on asynchronous message-passing.”
  • 10.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Reactive Architecture • Asynchronous message passing • Non-blocking • Higher throughput • Effective hardware utilization and lower costs • Loosely coupled • Location independent • Easy to extend and maintain • Push-based
  • 11.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Microservices
  • 12.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Microservices should be stateless. Keep state in external systems.
  • 13.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Avoid Host-Affinity.
  • 14.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Use lightweight protocols for communication.
  • 15.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Use mechanisms for registration.
  • 16.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How to build Reactive Architectures in AWS?
  • 17.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Example use case Banner Icon made by Freepik from www.flaticon.com Customer visits website Customer clicks on a banner Customer buys from online-shop
  • 18.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. High Level Architecture
  • 19.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECSApplication Load Balancer Amazon ECR Kinesis Stream Kinesis Stream Lambda function Lambda function ElastiCache cluster Data ingestion Core data update Amazon DynamoDB Core data updates Data collection
  • 20.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. High Level Architecture • Amazon ECS and Docker used for the main application • Resiliency and Elasticity implemented by using Auto Scaling
  • 21.
    © 2017, AmazonWeb 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
  • 22.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. High Level Architecture • Amazon Kinesis Streams used to decouple components • Asynchronously push event data to NoSQL- store • Update core-data in Redis
  • 23.
    © 2017, AmazonWeb 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
  • 24.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. High Level Architecture • Amazon DynamoDB NoSQL-store used to persist event-data
  • 25.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Application Architecture
  • 26.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECSApplication Load Balancer Amazon ECR Kinesis Stream Kinesis Stream Lambda function Lambda function ElastiCache cluster Data ingestion Core data update Amazon DynamoDB Core data updates Data collection You are here now!
  • 27.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Application Architecture
  • 28.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Application Architecture Picture source: http://vertx.io/docs/guide-for-java-devs/
  • 29.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Application Architecture “Don’t block the event loop!” - Vert.x golden rule
  • 30.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Application Architecture Picture source: http://vertx.io/docs/guide-for-java-devs/
  • 31.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Application Architecture Picture source: http://vertx.io/docs/guide-for-java-devs/
  • 32.
    © 2017, AmazonWeb 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 Stream
  • 33.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Subscribe to EB Send prepared data
  • 34.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Application Architecture Cache Rules Everything Around Me
  • 35.
    © 2017, AmazonWeb 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
  • 36.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Amazon ECSApplication Load Balancer Amazon ECR Kinesis Stream Kinesis Stream Lambda function Lambda function ElastiCache cluster Data ingestion Core data update Amazon DynamoDB Core data updates Data collection You are here now!
  • 37.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Application Architecture AWS Lambda
  • 38.
    © 2017, AmazonWeb 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
  • 39.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Kinesis event processing Iterate over batch of events
  • 40.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Global Rollout
  • 41.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. 16 Regions 44 Availability Zones AWS Global Infrastructure
  • 42.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Global Rollout AWS CloudFormation
  • 43.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Global Rollout • Infrastructure as Code • Create and manage resources with CloudFormation templates • CloudFormation template is used to deploy stacks
  • 44.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Global Rollout
  • 45.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Master Region • One stream of data • One region to process data • Data has to be transferred inter region Global Rollout Distributed Processing • Data processing in every region • No unified view on data
  • 46.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Summary
  • 47.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Summary • Reactive Architectures very good fit for AWS Cloud • Microservices improve isolation • AWS offers a lot of services for decoupled application design • Focus on business requirements, don’t reinvent the wheel
  • 48.
    © 2017, AmazonWeb Services, Inc. or its Affiliates. All rights reserved. Thank you!