Go Reactive: Blueprint for Future Applications

2,036 views

Published on

The game has changed: we write interactive web applications, we distribute the processing of huge data sets and our services need to be available at all times. This new breed of applications comes with its own set of requirements and forces us to establish new blueprints for designing our systems. In this talk we start out with the simple, classical question “for whose benefit?” and derive the four tenets of the Reactive Manifesto from this starting point.

See also http://summercamp.trivento.nl/

Published in: Technology

Go Reactive: Blueprint for Future Applications

  1. 1. Go Reactive Blue Print for Future Applications Dr. Roland Kuhn Akka Tech Lead @rolandkuhn f Typesafe
  2. 2. The Four Reactive Traits responsive / Q A—@w a/ htt : //reactivemanifesto. or
  3. 3. Starting Point: The User
  4. 4. The User er
  5. 5. internal service storage internal service frontend if server service .
  6. 6. Responsiveness always available interactive (near) real-time
  7. 7. Bounded Latency
  8. 8. Bounded Latency ° fan-out in parallel and aggregate
  9. 9. Bounded Latency ° tarry“ . _.
  10. 10. Bounded Latency . _. ° tarry“ ' '
  11. 11. Bounded Latency
  12. 12. Bounded Latency ° fan-out in parallel and aggregate ° use circuit breakers for graceful degradation
  13. 13. Bounded Latency ° fan—/ / ” ' ' ° use —e 0 K / f Typesafe
  14. 14. Bounded Latency ° fan-out in parallel and aggregate ° use circuit breakers for graceful degradation - use bounded queues, measure flow rates
  15. 15. Bounded Latency ° fan—/ " ° use ' USE Use Bounded Queues: Latency = QueueLength ° ProcessingTime (for reasonably stable average processing time) f Typesafe 8
  16. 16. J fan-/ ” use use Use Bounded ( ; t. ‘-3|. as: Latency = QueueLength * ProcessingTime (for mason ibl‘, staple average processing time) _‘: :: 1'1,-i= i.~r-. it=
  17. 17. Resilience Responsive in the Face of Failure
  18. 18. l-ian. +:! l.e Failt! re software will fail hardware will fail humans will fail system still needs to respond r'«esill. ien. «:. 'e . ‘-5 “. 'J: l%l~. ‘f= .ii'-i
  19. 19. 0 l .8‘ . éwem. a.. ... e.as. %n E eE»tL§. £H_L. ,§V. _-‘:3 ‘m, -i= i.ri= .it= zjil
  20. 20. Asynchronous Failure ° parallel fa n—out & distribution i---> asynchronous execution ° compartmentalization & isolation
  21. 21. Asynchronous Failure ° parallel fa n—out & distribution i---> asynchronous execution ° compartmentalization & isolation - no response? -'--> timeout events ° someone else’s exception? i---> supervision
  22. 22. Asynchronous Failure ° parallel” i---> asy ° compa - no rest - somea K Request Response Faflure
  23. 23. Asynchronous Failure ° parall i---> asy ° comp - no res ° some
  24. 24. Asynchronous Failure ° parallel fa n—out & distribution i---> asynchronous execution ° compartmentalization & isolation - no response? -'--> timeout events ° someone else’s exception? i---> supervision ° location transparency ~---> seamless resilience
  25. 25. Scalability Responsive in the Face of Changing Load
  26. 26. Handle Load
  27. 27. _ m. .W. ,%, ,. , . . i , - . .u . e£-. u. . . Jr , . . ... ..U_. ./iiwyw. xi . wew. H.. .-. ., . e_. r. aim . ... .r. ... t.- . . . .34 . . . rm. _. .$. wn. +x. . at . ,_. ..v. .. . _. . ma. ,. ..3.a&. .n. 1.. . , .. V . W» . i , ..a. .. . i.. ... ; . . . l F Mm .1 . .:. :». i wt}; , ._. ..m. ... ._. J. .. u. .. . .ias. . 1 - u. .. . 7 l’Io)hllvl. l I av. .. . .1. A . i. Kw . l._Jn. W . «.. . . . . . . t . all : i ‘ _ . . . ., .. . ,,. W. . . . . . . . . . . i . _.; . .,_ , _‘; :: 1'1,-i= i.~n. it=
  28. 28. Handle Load ° partition incoming work fordistribution ° share nothing - scale capacity up and down on demand ° supervise and adapt ° location transparency i---> seamless scalability
  29. 29. l-iariiirfil/ e l. eaad partition incoming work for distribution share nothing scale capacity up and down on demand supervise and adapt l. e«: a'f: iei.1.'F; t'a. ris; ; at ‘El. cg seamless scalability "7: ‘Waist-. *+= .ii; i
  30. 30. this has some interesting consequences!
  31. 31. Consequences distribution & scalability loss of strong consistency CAP theorem? — not as relevant as you think eventual consistency gossip, heartbeats, dissemination of change Pat He/ /and: Life beyond Distributed Transactions Peter Bailis: Probabilistical/ y Bounded Sta/ eness (http. [4Qbs. cs. berke/ ey. edu) . ‘-5 'i. 'J: I:i~. ~i= .it-.4
  32. 32. Consequences distribution & scalability loss of strong consistency CAP theorem? — not as relevant as you think eventual consistency gossip, heartbeats, dissemination of change P. Hem : L beyond Distributed Transactions Peter P :7ili: .: Pi obab. i”. t‘. i"su~. al/ y Bounded Sta/ eness (http. [4Qbs. cs. berke/ ey. edu) . ‘-5 'i. 'J: I:i~. ~i= .it-.4
  33. 33. Corollary ° Reactive needs to be applied all the way down - Polyglot deployments demand collaboration i---> for example httpziireactivestreamsorgz
  34. 34. But what about us, the developers?
  35. 35. Step 1: Take a Leap of Faith ° thread—based models have made us defensive - “don't let go ofyour thread! ” - “asynchrony is suspicious” - “better return strict value, even ifthat needs blocking”
  36. 36. Step 1: Take a Leap of Faith ° thread—based models have made us defensive - “don't let go ofyour thread! ” - “asynchrony is suspicious” - “better return strict value, even ifthat needs blocking” - it is okay to write a method that returns a Future!
  37. 37. Step 2: Rethink the Architecture ° break out ofthe synchronous blocking prison - focus on communication & protocols - asynchronous program flow i---> no step—through debugging i---> tracing and monitoring - loose coupling
  38. 38. E"-fiery: 3: Profit! clean business logic, separate from failure handling distributable units of work effortless parallelization less assumptions lower maintenance cost . ‘-5 'i. 'J: I:i~. ~i= .it-.4
  39. 39. E"-fiery: 3: Profit! clean business logic, separate from failure handling distributable units of work effortless parallelization less assumptions lower maintenance cost independent agents ‘Er, trt tie taro r ( t. iii'. 'hE . ‘-5 'i. 'J: I:i~. ~i= .it-.4
  40. 40. Summary
  41. 41. The Four Reactive Traits responsive / Q A—@w a/ htt : //reactivemanifesto. or
  42. 42. T iiypesate J ©Typesafe 2014 — All Rights Reserved

×