Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Legacy Systeme modernisieren mit Microservices,...

Holger Kraus
February 04, 2016

Legacy Systeme modernisieren mit Microservices, Hystrix und RxJava

präsentiert auf der OOP in München am 4. Februar 2016

Als Software-Entwickler ist man nur sehr selten in der Situation, ein völlig neues System auf der Basis neuester Technologien entwickeln zu dürfen. Oft sollen bestehende Systeme nur um viele kleinere Features erweitert werden.
Die Renovierung der grundlegenden Systemarchitektur und die Einführung neuer Programmierparadigmen sind in diesem Umfeld schwierig. Umso wichtiger ist es, dass man die Modernisierung von Altsystemen zu einem fortlaufenden Bestandteil auch des Feature-getriebenen Entwicklungsprozesses macht.
In diesem Vortrag möchten wir zeigen, wie auch größere, monolithische Altsysteme mithilfe der offenen Netflix-Bibliotheken schrittweise in Richtung einer Microservice-Achitektur weiterentwickelt werden können. Hystrix kann dabei einen wertvollen Beitrag zur Gesamtstabilität des entstehenden verteilten Systems leisten.
Der Einsatz von RxJava eröffnet eine gute Möglichkeit, den Anteil von asynchronen Prozessen innerhalb der Legacy-Architektur zu erhöhen. Der Vortrag wird anhand von Beispielen demonstrieren, wie der hier angedeutete Modernisierungsprozess umgesetzt werden kann.

Holger Kraus

February 04, 2016
Tweet

More Decks by Holger Kraus

Other Decks in Technology

Transcript

  1. Current problems > Maintenance is difficult > New features need

    a lot of time > Very unstable > Outdated technology > Doesn’t scale + frustrated developers :(
  2. Current problems > Maintenance is difficult > New features need

    a lot of time > Very unstable > Outdated technology > Doesn’t scale Microservices FTW ! not yet …
  3. Stability patterns > Timeouts > Circuit Breaker > Bulkhead …

    Fail Fast, Steady State, Handshaking, Test Harness, Decoupling Middleware
  4. Search Products 2. find external products 1. search products 3.

    find internal products 4. return internal + external products
  5. Configuration > Netflix archaius used internally > Configuration at runtime

    is possible > allows a faster PDCA cycle and could prevent server restarts > overall highly configurable and well documented
  6. Command Groups > every Command has a name > you

    can combine commands to groups > groups aggregate commands for metrics, dashboards etc. > per default a group determines the thread pool
  7. Thread Pool sizing requests per second at peak when healthy

    × 99th percentile latency in seconds + some breathing room Little's law
  8. Let’s recap > Stabilize first to enable further distribution >

    Hystrix is easy to integrate in existing systems > it includes Bulkhead, Timeouts and Circuit Breakers out of the box > Application monitoring as a side benefit
  9. Current Problems > Maintenance is difficult > New features need

    a lot of time > Very unstable => enables further distribution > Outdated technology > Doesn’t scale
  10. Cut you domain „MECE“ * Riccardo Mangiaracina, The eCommerce Customer

    Journey: A Model to Assess and , Compare the User Experience of the eCommerce Websites, Journal of Internet Banking and Commerce mutually exclusive and collectively exhaustive
  11. Domains and Teams Site Landing Product Discovery Product Presentation Cart

    Management Checkout Infrastructure PO QA UI Backend Infrastructure PO QA UI Backend Infrastructure PO QA UI Backend Infrastructure PO QA UI Backend Infrastructure PO QA UI Backend
  12. Macro Architecture > Integration > Deployment > Formats > Protocols

    > Reduce Choices what’s the same for all boxes ? = API = Docker = JSON = HTTP + AMQP = Java, Go Monozon: pick your own!
  13. Merchant Product Invoice Payment … Order Monozon … … Use

    Case Search product Presentation Use Case Add To Cart Presentation Use Case Search Product Presentation Use Case Order Tracking Presentation Use Case … Presentation Use Case … Presentation Use Case XYZ Presentation Inventory How much to cut out? intertwined presentation and use case logic intertwined business entity and persistence logic
  14. Reuse Business Entities? Merchant Product Inventory Inventory Payment … Order

    Monozon … … Use Case Search product Presentation Use Case Add To Cart Presentation Use Case Search Product Presentation Use Case Order Tracking Presentation Use Case … Presentation Use Case … Presentation Use Case XYZ Presentation Persistence InventoryService CRUD API Validation
  15. Beware of multiple Clients Monozon Web Web-UI Product search Checkout

    Order Tracking … Monozon eReader eReader-UI Product search Checkout Order Tracking … Monozon iOS App iOS-UI Product search Checkout Order Tracking … Monozon Andoid App Android-UI Product search Checkout Order Tracking … InventorySerice JSON CRUD API OrderService JSON CRUD API ProductService JSON CRUD API PaymentService JSON CRUD API CustomerService JSON CRUD API isn’t that redundant?
  16. Downsides > CRUD APIs must match all needs > only

    Use Case agnostic validation is possible > every Clients must rebuild the Use Cases with by aggregating a lot of calls > redundant and not reusable logic in all Clients
  17. API Integration Merchant Product Inventory Inventory Payment … Order Monozon

    … … Use Case Search product Presentation Use Case Add To Cart Presentation Use Case Search Product Presentation Use Case Order Tracking Presentation Use Case … Presentation Use Case … Presentation Use Case XYZ Presentation Persistence Use Case REST API Business Logic Inventory Service
  18. Frontend Integration Merchant Product Inventory Inventory Payment … Order Monozon

    … … Use Case Search product Presentation Use Case Add To Cart Presentation Use Case Search Product Presentation Use Case Order Tracking Presentation Use Case … Presentation Use Case … Presentation Use Case XYZ Presentation Persistence UI Business Logic Inventory Service
  19. Frontend Integration System 1 System 2 Hyperlinks can also support

    the 
 dynamic inclusion of content that is served by another application into the web interface of a self-contained system.
  20. API Integration Review Pro: > simple „classic“ way > no

    need to restructure backend and frontend teams > could support wide variety of clients Con: > harder to extract complete business logic > no real product teams > cut between frontend and backend
  21. Frontend Integration Review Pro: > nice way to extract complete

    logic > systems are highly autonomous > real product teams possible Con: > not the stuff most devs are used to > callbacks could be ugly > reorganization of frontend and backend teams could be needed
  22. Let’s recap 1. stabilize your monolith and enable distribution 2.

    establish and communicate your macro architecture 3. use you domain architecture to extract new services 4. prefer to „strangle“ over „big bangs“ 5. always extract all business logic (even if it’s harder) 6. have a vision
  23. What has to be done? > Retrieve internal products that

    match 
 search criteria > Retrieve external products from merchants 
 that match search criteria
  24. Internal Product Search > Retrieve product ids from Search >

    Retrieve product details from Product > Retrieve number of matching products in stock from Inventory > Combine all data into one format 
 called SearchResult
  25. External Product Search > Retrieve matching products from different merchants

    in different data formats > Combine all data into one format
 called SearchResult
  26. Time for RxJava > Reactive Extensions for the JVM >

    Asynchronous streams > Elements of > Observable pattern > Iterator pattern > Functional programming
  27. The functional part > Combining: merge(), zip(), join(), … >

    Filtering: filter(), skip(), distinct(), … > Aggregating: reduce(), max(), sum(), … > Transformation: map(), flatMap(), … > Conditional: contains(), amb(), all(), …
  28. Error handling > onError works like onCompleted, just with an

    error ;) > UncheckedExceptions end up in OnError > CheckedException have to be catched and rethrown as RuntimeExceptions > Rx provides helpers to throw them
  29. Reasons for RxJava > Can be used with Java 6

    and later versions > Already part of Hystrix > Lots of operators
  30. Alternatives > ListenableFuture (Google Guava) > Reactive Streams (Akka-Streams, Reactor,

    Vert.x, etc.) > CompletableFuture (Java 8) > Flow (Java 9)
  31. Summary > Use Hystrix to stabilize your system! > Use

    RxJava to increase the amount of parallel processes in an easy way! > Introduce Microservices to get control over your system again! > Have fun :)