Slide 1

Slide 1 text

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Microservices and Event-Driven Architecture Leonardo Piedade, Solutions Architect Luiz Yanai, Solutions Architect

Slide 2

Slide 2 text

A Brief History of Time…

Slide 3

Slide 3 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. A Brief History of Time… • Traditional App (3 tiers) • SOA Approach • Microservices

Slide 4

Slide 4 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Traditional Application UI Logic Shop UI E-commerce GUI Order DAO Checkout API E-commerce Backend Application E-commerce Single Database Search API Product DAO Customer DAO

Slide 5

Slide 5 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. SOA Application UI Logic Shop UI E-commerce GUI Orders DB Database Products DB Database Order Logic Order API Orders Application Product Logic Product API Products Application

Slide 6

Slide 6 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Microservices UI Logic Shop UI E-commerce GUI Order DAO Order API Orders Application Orders DB Product DAO Product API Products Application Products DB Custom. DAO Custom. API Customers Application Customers DB

Slide 7

Slide 7 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Wait!... And DDD?

Slide 8

Slide 8 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Microservices Communication Expectation

Slide 9

Slide 9 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Microservices Communication Reality

Slide 10

Slide 10 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Point-to-point Couplings Order Service UI Logic Shop UI E-commerce GUI Product Service Customer Service Checkout Service Some kind of problems: • Crash of service • Slow response time • Change of interface

Slide 11

Slide 11 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Sync vs Async Synchronous Asynchronous

Slide 12

Slide 12 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Reasons to Send a Message Command Query Event I want to do something I want to know something Something has happened

Slide 13

Slide 13 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Reasons to Send a Message Command Query Event I want a Pizza Is my pizza ready!? Pizza delivered

Slide 14

Slide 14 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Event-Driven Microservices Async Communication Order Service Product Service Customer Service Pub/Sub Pub/Sub Message Broker

Slide 15

Slide 15 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Event-Driven Microservices Async Communication Application Message Broker Derived Event New Events State

Slide 16

Slide 16 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. “We have an amazing API… …but please subscribe to our event streams instead.”

Slide 17

Slide 17 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Event-Driven Simple Pattern for Streaming Data Data Producer Continuously creates data Continuously writes data to a stream Can be almost anything Durably stores data Provides temporary buffer that preps data Supports very high- throughput Continuously process data Cleans, prepares, and Aggregates Transforms data to information Streaming Service Data Consumer

Slide 18

Slide 18 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Streams

Slide 19

Slide 19 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Event Sourcing vs Event Store Persists the state of a entity as a sequence of state-changing events Whenever state of entity changes, a new event is appended to the list of events Saving an event is a single operation (atomic) The application reconstructs an entity’s current state by replaying the events

Slide 20

Slide 20 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Event Sourcing - Example

Slide 21

Slide 21 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Event-Driven Microservices Async Communication Application Message Broker Derived Event New Events State

Slide 22

Slide 22 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Old Idea? Operational/Transactional Database vs Reporting/Analytical Database https://martinfowler.com/bliki/ReportingDatabase.html OLTP vs OLAP

Slide 23

Slide 23 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. CQRS – Command Query Responsibility Segregation https://martinfowler.com/bliki/CQRS.html - 2011 Command Service Write Data Store Query Service Read Data Store Command that trigger change in state Query that provide read access to the state *One alternative for CQRS implementation

Slide 24

Slide 24 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Event Sourcing & CQRS Command Service Data Store Query Service Materialized View Command Query *Another alternative for CQRS implementation Event Store Command Handler Optimize different nonfunctional requirements for read and write Write Delay Eventual Consistency Database as event publisher (optional) Data Projection and Materialized View

Slide 25

Slide 25 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Eventual Consistency Credits: https://www.flaticon.com/br/autores/icongeek26 Drink = “beer” Drink = “vodka” Drink = “vodka” Drink = “beer” Drink = “beer” Drink = ? Drink = “beer” Drink = “vodka”

Slide 26

Slide 26 text

Eventual Consistency Credits: http://pjousselin.free.fr/

Slide 27

Slide 27 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Expectation Reality Event Ordering

Slide 28

Slide 28 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. “Don't do it, if you can avoid it.” Event Ordering

Slide 29

Slide 29 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Event Ordering 0 0 100 0 Account Created Deposit: 100 Withdraw: 20 -20 0 +100 -20 +100 0 100 80 100 -20 Withdraw: 20

Slide 30

Slide 30 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Events are Immutable! Or not!?

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Governance and Event Catalog Temporal Semantics Channels and Data Security Event Versioning Clustered Event Sourcing and Assured Delivery Change Data Capture over Streams Monitoring and Fitness Functions for EDA We are here! Complex Event Processing Backpressure and Exponential Backoff Projections and Aggregates

Slide 33

Slide 33 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. Some books…

Slide 34

Slide 34 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. …and other books

Slide 35

Slide 35 text

® 2019 Amazon Web Services Inc. or its Affiliates. All rights reserved. … or just do this! bit.ly/tdcpoa-2019

Slide 36

Slide 36 text

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you! Leonardo Piedade [email protected] Luiz Yanai [email protected]