Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

A long way from Monolith to Service Isolated Architecture #MM19NL

757 vues

Publié le

Problem:
The application grows in size. Becomes harder to understand
Merchants customization grows in complexity
This pushes Magento for longer release cycles
Harder for merchants to experiment and react to market needs quickly

Solution:
Service Isolation

Publié dans : Logiciels
  • Soyez le premier à commenter

A long way from Monolith to Service Isolated Architecture #MM19NL

  1. 1. © 2018 Magento, An Adobe Company Page | 1 A long way from Monolith to Service Isolated Architecture Yesterday, Today and Tomorrow
  2. 2. © 2018 Magento, An Adobe Company Page | 2 Igor Miniailo (aka Miauw Miauw) Magento Architect, Community Engineering Team
  3. 3. © 2018 Magento, An Adobe Company Page | 3 That’s a project Magento has committed to do already, not just a dump of my personal thoughts! Spoiler 1:
  4. 4. © 2018 Magento, An Adobe Company Page | 4 No API deprecation for today!!!!!111 Spoiler 2:
  5. 5. © 2018 Magento, An Adobe Company Page | 5 • Application grows in size. Becomes harder to understand • Merchants customization grows in complexity • This pushes Magento for longer release cycles • Harder for merchants to experiment and react to market needs quickly Problem:
  6. 6. © 2018 Magento, An Adobe Company Page | 6 Service Isolation Solution:
  7. 7. © 2018 Magento, An Adobe Company Page | 7 Agenda © 2018 Magento, An Adobe Company Page | 7 • Magento 1. Big ball of Mud • SOLID and Single Responsibility • Performance vs Scalability • Coupling vs Cohesion • Bounded contexts and their Boundaries • CAP Theorem • ACID vs BASE • Sagas • Modularity as a first step towards service isolation • Service Isolation (Code and DB split) • Conway's law
  8. 8. © 2018 Magento, An Adobe Company Page | 8© 2018 Magento, An Adobe Company Page | 8 Magento 1 And all the legacy we got starting Magento 2 development
  9. 9. © 2018 Magento, An Adobe Company Page | 9 Classical N-layered architecture • Compromise in the design of Data Model • Not possible to scale separately Read out of Write operations • Tend to Anemic Data Model • Tend to Monolithic Architecture • An application has to be deployed as a whole • An application has to be scaled as a whole
  10. 10. © 2018 Magento, An Adobe Company Page | 10 Big Ball of Mud Even though a modular code structure groups related behavior, it is easy to introduce an undesired dependency between application services, because services are not deployed and tested independently.
  11. 11. © 2018 Magento, An Adobe Company Page | 11 SOLID comes to rescue
  12. 12. © 2018 Magento, An Adobe Company Page | 12© 2018 Magento, An Adobe Company Page | 12 Modularity as a first step towards micro-services
  13. 13. © 2018 Magento, An Adobe Company Page | 13 • Every sophisticated business domain consists of a bunch of Bounded Contexts • Each Bounded Context contains models and maybe other contexts • The Bounded Context is also a boundary for the meaning of a given model Bounded Context
  14. 14. © 2018 Magento, An Adobe Company Page | 14 Bounded Context
  15. 15. © 2018 Magento, An Adobe Company Page | 15 CAP Theorem States that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees: • Consistency: Every read receives the most recent write or an error • Availability: Every request receives a (non-error) response – without the guarantee that it contains the most recent write • Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes
  16. 16. © 2018 Magento, An Adobe Company Page | 16 Asynchronous processing http://www.enterpriseintegrationpatterns.com/docs/IEEE_Software_Design_2PC.pdf
  17. 17. © 2018 Magento, An Adobe Company Page | 17 Conversation pattern The interaction between two parties (customer and coffee shop) consists of: • a short synchronous interaction (ordering and paying) • and a longer, asynchronous interaction (making and receiving the drink) This type of conversation pattern is quite common in purchasing scenarios.
  18. 18. © 2018 Magento, An Adobe Company Page | 18 Error-handling strategies for loosely coupled systems (a) Write-off (b) Retry (c) Compensating action (d) Transaction coordinator (two phase commit)
  19. 19. © 2018 Magento, An Adobe Company Page | 19 Implement business transaction that spans multiple services as a saga A saga is a sequence of local transactions Each local transaction updates the database and publishes a message or event to trigger the next local transaction in the saga
  20. 20. © 2018 Magento, An Adobe Company Page | 20 You are used to Sagas in Real Life
  21. 21. © 2018 Magento, An Adobe Company Page | 21 Sagas in eCommerce When you place an order on Amazon.com: • A short synchronous interaction assigns a unique order number first. • All subsequent steps (charging your credit card and packaging and shipping the product) are performed asynchronously: • you’re notified via (asynchronous) email as additional processing steps complete. • If anything goes wrong, Amazon usually uses similar compensation strategies— refunding your credit card or retrying the action by resending the goods.
  22. 22. © 2018 Magento, An Adobe Company Page | 22 State Machine / Workflows • Azure Logic Apps • Amazon Step Functions
  23. 23. © 2018 Magento, An Adobe Company Page | 23 Distributed services orchestration by using workflow (state machine)
  24. 24. © 2018 Magento, An Adobe Company Page | 24 Event Sourcing
  25. 25. © 2018 Magento, An Adobe Company Page | 25 • The network is reliable • Latency is zero • Bandwidth is infinite • The network is secure • Topology doesn't change • There is one administrator • Transport cost is zero • The network is homogeneous https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing Fallacies of distributed computing
  26. 26. © 2018 Magento, An Adobe Company Page | 26 Network is a scary place to be
  27. 27. © 2018 Magento, An Adobe Company Page | 27 Circuit Breaker Bulkhead
  28. 28. © 2018 Magento, An Adobe Company Page | 28 Service Mesh • Business Logic that implements the business functionalities, computations and service composition/integration logic. • Network Functions that take care of the inter-service communication mechanisms (basic service invocation through a given protocol, apply resiliency and stability patterns, service discovery etc.) These network functions are built on top of the underlying OS level network stack.
  29. 29. © 2018 Magento, An Adobe Company Page | 29 The most complex challenge in realizing isolated service architecture is not building the services themselves, but the communication between services.
  30. 30. © 2018 Magento, An Adobe Company Page | 30 *The property of certain operations whereby they can be applied multiple times without changing the result beyond the initial application. Idempotence of operation and at-least-once delivery Network communication is unreliable. Retries will be required, and some messages will be delivered more than once
  31. 31. © 2018 Magento, An Adobe Company Page | 31 • All operations MUST BE idempotent. • Sagas SHOULD BE used for consistency of distributed operations • All new service contracts SHOULD expose asynchronous APIs • All new state modifying operations SHOULD expose bulk APIs • All service operations MUST BE stateless • There MUST BE NO data dependencies between services • CAS (compare and swap) technique to avoid race condition Design Principles to follow
  32. 32. © 2018 Magento, An Adobe Company Page | 32 • Every module defines its APIs (service contracts), which are PHP interfaces that can be called either from within a PHP process or remotely through REST, SOAP or AMQP APIs. • Every module can call other modules only through their service contracts. Service Layer
  33. 33. © 2018 Magento, An Adobe Company Page | 33 Service Layer. Current State Legacy undesired dependencies direct inter-module - model-to-model - presentation-to-model still exist.
  34. 34. © 2018 Magento, An Adobe Company Page | 34 Modules split
  35. 35. © 2018 Magento, An Adobe Company Page | 35 Modules Split. Inventory • API – service contracts and extension points • Implementation (private) - should not be called directly from other modules • Admin UI • Frontend UI
  36. 36. © 2018 Magento, An Adobe Company Page | 36 Headless Multi-Source Inventory UI modules are removable if merchant wants to use external ERP system as a source of truth where he will manage inventory
  37. 37. © 2018 Magento, An Adobe Company Page | 37 Desirable State
  38. 38. © 2018 Magento, An Adobe Company Page | 38 Database per Service A service must not talk to other service database directly, only through service contracts TODO: - Minimize data relations - Replace the required inter-service db- level data relations, joins, and transactions with application-level relations, joins, and transactions
  39. 39. © 2018 Magento, An Adobe Company Page | 39 Desirable state Isolated ServicesMonolith
  40. 40. © 2018 Magento, An Adobe Company Page | 40 Monoliths vs Microservices. Scalability
  41. 41. © 2018 Magento, An Adobe Company Page | 41
  42. 42. © 2018 Magento, An Adobe Company Page | 42 • Use MFTF • Run MFTF on Marketplace to validate extensions • Run MFTF on Cloud to validate changes Manual Testing is not an Option anymore
  43. 43. © 2018 Magento, An Adobe Company Page | 43 Independent components releases No Big Bang Magento releases anymore
  44. 44. © 2018 Magento, An Adobe Company Page | 44 2.3 Stage #1 Stage #2 Stage #3 Stage #4 Stage #5 Inventory (MSI) App Framework Order Management CMS Shipping Marketing Pricing Tax Reports Promotions Risk Checkout Customer Payments Wishlist Rewards Company Service decomposition
  45. 45. © 2018 Magento, An Adobe Company Page | 45 • Magento Service Isolation Design Document by Anton Kril • Distributed services orchestration by using workflow (state machine) • Magento administrative tool • Magento MSI • Salable Quantity Calculation and Mechanism of Reservations Useful Links
  46. 46. © 2018 Magento, An Adobe Company Page | 46 Let’s shape Magento Isolated services together!
  47. 47. © 2018 Magento, An Adobe Company Page | 47 Q&AFollow me on Twitter @iminyaylo
  48. 48. © 2018 Magento, An Adobe Company Page | 48 Thank You © 2018 Magento, An Adobe Company Page | 48

×