Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Irakli Nadareishvili - O'Reilly SACon 2018, London

263 views

Published on

Asynchronoucity in Microservices - three major use-cases, presented at O'Reilly Software Architecture Conference, in London, 2018.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Irakli Nadareishvili - O'Reilly SACon 2018, London

  1. 1. Asynchronicity in Microservices Three Main Forms of Asynchronicity – Understanding the Patterns O’Reilly SACon, London, October 2018 Irakli Nadareishvili Sr. Director, Shared Technology, Capital One.
  2. 2. Irakli Nadareishvili Senior Director, SharedTech, Capital One • API & Microservices Governance • Capital One’s Developer Tooling • Co-author of “Microservice Architecture” inadarei
  3. 3. 11 “Speed and Safety at Scale and in Harmony” Need for coordination is why we constantly compromise between speed and safety. Microservices Way: inadarei
  4. 4. Microservicesclosethealignmentloop! AgileProcess: Operations: Product: DevOps & CI/CID Lean Product Dev Pattern: Thinking In Small Batches Architecture: Microservices inadarei
  5. 5. Data:Batch-sizeIsaStrongPredictorofPerformance Source: Accelerate, by Nicole Forsgren, PhD, Jez Humble, and Gene Kim
  6. 6. 6Confidential Async + #Microservices = Internet’s favorite pastime
  7. 7. 7 There is actually more than one type of asynchronicity, and the proper usage patterns are significantly different, when and if applied properly.
  8. 8. Asynchronous Flows Data Streams Event-Sourcing (and CQRS) AGENDA
  9. 9. 9 1. Asynchronous Flows
  10. 10. 1010Confidential Any type of asynchronous job execution, where caller doesn’t have to wait for a response in a blocking way, increases scalability and resiliency of the system, granted: typically at the expense of increased complexity. Common solutions: • Promises, async/await & coroutines • Publish/Subscribe Queues • Webhooks • Reactive Programming • Akka Actor Model
  11. 11. Promises (Node.js) 11Example code from: http://promises123.com.
  12. 12. Async/Await (Python) 12Example code from: http://promises123.com.
  13. 13. Goroutines (Go) 13Example code from: http://promises123.com.
  14. 14. Reactive Programming 14 Higher-level abstraction over messaging using Observables and functional programming.
  15. 15. Publish/Subscribe Queues 15 Senders generate events, receivers are workers able and interested in processing those Graphics source: https://docs.microsoft.com/en-us/previous-versions/msp-n-p/dn589781(v=pandp.10) Pub/Sub provides significantly superior level of flexibility, in that: multiple kinds of receivers, implemented with heterogenous tech stack can subscribe to the same events using a uniform approach and implementation. Example: 1. Message: loan application submitted 2. Received by fraud-check worker 3. Received by credit-check worker 4. Received by AML-check worker 5. Received by OFAC-check worker 6. …
  16. 16. Webhooks – HTTP Callbacks with Payload 16 W3C Standard: WebSub https://www.w3.org/TR/websub/ Graphics source: https://www.w3.org/TR/websub/#high-level-protocol-flow WebSub allows abstracting Pub/Sub model away from specific, non-web protocols used by concrete message broker systems and projecting the interactions onto the standard HTTP layer, with main benefit being ubiquitous familiarity with the protocol, built-in caching and internet- level scalability features.
  17. 17. Akka Actor Model 17 Actor Model-based abstraction for concurrent and distributed systems, primarily in Scala and Java Diagram source: https://doc.akka.io/docs/akka/2.5/guide/actors-intro.html “Everything is an Actor” model to concurrency by Carl Hewitt (1973). Actor is an entity that, in response to a message, can: 1. Send messages to other actors 2. Create new actors 3. Define message-processing behavior.
  18. 18. Akka Actor Model - Clustering 18 Akka provides gossip-based HA cluster impl. with advanced features like sharding & persistence. Diagram source: https://doc.akka.io/docs/akka/2.5/common/cluster.html#intro
  19. 19. 19 2. Data Streams
  20. 20. Data Analytics & Machine Learning Applications 20 Could be powered by Kafka Streams configured/optimized differently from their pub/sub usage Diagram source: https://www.confluent.io/blog/build-deploy-scalable-machine-learning-production-apache-kafka/
  21. 21. Data Lake 21 Business-relevant data streamed into a Data Lake from all data/event sources Diagram source: https://aws.amazon.com/big-data/datalakes-and-analytics/what-is-a-data-lake/
  22. 22. 22 3. Event Sourcing (and CQRS)
  23. 23. Command Query Responsibility Segregation (CQRS) 23 Separating actions (state changes) from perceptions (reads, notification) in system architecture EventStore Alexa VoiceSkill BFFAPI … Microservice 1 … … Microservice 2 … … Microservice 4 … MobileWebApp … Microservice 3 … BFFAPIBFFAPI Topic 1 Topic 2.1 Topic 2.2 Topic 4.1 Topic 4.2 Topic 4.3 Subscribe publish publish publish Subscribe Subscribe Subscribe Query Query Query Query
  24. 24. 24
  25. 25. Event-Sourcing Explained 25 “Current state”-oriented, relational model – favors data-sharing, toxic for microservices Customer Demographics Credit-Worthiness Data Deposits (10) Accounts (3) Withdrawals (10) Documents (7)
  26. 26. Event-Sourcing Explained 26 Events-Based Data Model – solves data-sharing issues in Microservices Credit Data Received Customer Created Checking Account Added Credit Card Acc. Added Mortgage Acc. Added Money Deposited Money Deposited Money Withdrawn Money Withdrawn Money Withdrawn Document Added Money Deposited Money Deposited Document Generated Money Withdrawn Document Added Money Withdrawn
  27. 27. Event “Shape” 27 Source: https://eventstore.org/docs/introduction/
  28. 28. Projections 28 Give us current state based on events, and are as simple as: function (state, event) “In Event Sourcing, current state is a left-fold of previous behaviors” – Greg Young
  29. 29. Tooling 29 Event Store: 1. EventStore https://eventstore.org/ 2. Cassandra 3. Any DB capable of storing many rows of data . Read Model: 1. ElasticSearch 2. PostgreSQL 3. Anything optimized for the kind of queries you want to run.
  30. 30. Command Query Responsibility Segregation (CQRS) 30 Separating actions (state changes) from perceptions (reads, notification) in system architecture EventStore Alexa VoiceSkill BFFAPI … Microservice 1 … … Microservice 2 … … Microservice 4 … MobileWebApp … Microservice 3 … BFFAPIBFFAPI Topic 1 Topic 2.1 Topic 2.2 Topic 4.1 Topic 4.2 Topic 4.3 Subscribe publish publish publish Subscribe Subscribe Subscribe Query Query Query Query
  31. 31. Asynchronous Flows Data Streams Event-Sourcing (and CQRS) ASYNC TYPES inadarei
  32. 32. 11 Questions? Thank you! inadarei

×