Share
Embed
Microservices and Event-Driven Architecture
Some examples of how use Microservices approach and Event-Driven Architecture together.
Leonardo
November 28, 2019
Transcript
36 slides
-
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Microservices and Event-Driven Architecture Leonardo Piedade, Solutions Architect Luiz Yanai, Solutions Architect -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. A Brief History of Time… • Traditional App (3 tiers) • SOA Approach • Microservices -
® 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 -
® 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 -
® 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 -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Wait!... And DDD? -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Microservices Communication Expectation -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Microservices Communication Reality -
® 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 -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Sync vs Async Synchronous Asynchronous -
® 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 -
® 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 -
® 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 -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Event-Driven Microservices Async Communication Application Message Broker Derived Event New Events State -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. “We have an amazing API… …but please subscribe to our event streams instead.” -
® 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 -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Streams -
® 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 -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Event Sourcing - Example -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Event-Driven Microservices Async Communication Application Message Broker Derived Event New Events State -
® 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 -
® 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 -
® 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 <projection> Optimize different nonfunctional requirements for read and write Write Delay Eventual Consistency Database as event publisher (optional) Data Projection and Materialized View -
® 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” -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Expectation Reality Event Ordering -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. “Don't do it, if you can avoid it.” Event Ordering -
® 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 -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Events are Immutable! Or not!? -
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 -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. Some books… -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. …and other books -
® 2019 Amazon Web Services Inc. or its Affiliates. All
rights reserved. … or just do this! bit.ly/tdcpoa-2019 -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Thank you! Leonardo Piedade [email protected] Luiz Yanai [email protected]