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.

Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems

7,152 views

Published on

Abstract:
The demands and expectations for applications have changed dramatically in recent years. Applications today are deployed on a wide range of infrastructure; from mobile devices up to thousands of nodes running in the cloud—all powered by multi-core processors. They need to be rich and collaborative, have a real-time feel with millisecond response time and should never stop running. Additionally, modern applications are a mashup of external services that need to be consumed and composed to provide the features at hand.

We are seeing a new type of applications emerging to address these new challenges—these are being called Reactive Applications. In this talk we will discuss four key traits of Reactive; Responsive, Resilient, Elastic and Message-Driven—how they impact application design, how they interact, their supporting technologies and techniques, how to think when designing and building them—all to make it easier for you and your team to Go Reactive.

Intended Audience:
Programmers, architects, CIO/CTOs and everyone with a desire to challenge the status quo and expand their horizons on how to tackle the current and future challenges in the computing industry.

Published in: Engineering
  • Hello! High Quality And Affordable Essays For You. Starting at $4.99 per page - Check our website! https://vk.cc/82gJD2
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Go Reactive: Building Responsive, Resilient, Elastic & Message-Driven Systems

  1. 1. Go Reactive Building Responsive, Resilient, Elastic & Message-Driven Systems Jonas Bonér CTO Typesafe @jboner
  2. 2. The rules of the game have changed
  3. 3. 3 Yesterday Today
  4. 4. 3 Yesterday Today Single machines Clusters of machines
  5. 5. 3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors
  6. 6. 3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM
  7. 7. 3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk
  8. 8. 3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks
  9. 9. 3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users
  10. 10. 3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users Small data sets Large data sets
  11. 11. 3 Yesterday Today Single machines Clusters of machines Single core processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk Slow networks Fast networks Few concurrent users Lots of concurrent users Small data sets Large data sets Latency in seconds Latency in milliseconds
  12. 12. Reactive “Readily responsive to a stimulus” - Merriam Webster
  13. 13. The Principles of Reactive Systems Reactive Applications 6
  14. 14. http://reactivemanifesto.org
  15. 15. Responsive “Quick to respond or react appropriately” - Merriam Webster
  16. 16. 9 The system should always be responsive
  17. 17. 9 The system should always be responsive 1. Blue skies 2. Heavy load 3. Failures
  18. 18. Resilient “The ability of a substance or object to spring back into shape” “The capacity to recover quickly from difficulties” - Merriam Webster
  19. 19. Think Vending Machine
  20. 20. Think Vending Machine Coffee Programmer Machine
  21. 21. Think Vending Machine Coffee Inserts coins Programmer Machine
  22. 22. Think Vending Machine Coffee Inserts coins Add more coins Programmer Machine
  23. 23. Think Vending Machine Coffee Inserts coins Add more coins Programmer Machine Gets coffee
  24. 24. Think Vending Machine Coffee Programmer Machine
  25. 25. Think Vending Machine Coffee Inserts coins Programmer Machine
  26. 26. Think Vending Machine Coffee Inserts coins Out of coffee beans error Programmer Machine
  27. 27. Think Vending Machine Coffee Inserts coins Out of coffee beans error WRONG Programmer Machine
  28. 28. Think Vending Machine Coffee Inserts coins Programmer Machine
  29. 29. Think Vending Machine Coffee Inserts coins Out of coffee beans failure Programmer Machine
  30. 30. Think Vending Machine Service Guy Coffee Inserts coins Out of coffee beans failure Programmer Machine
  31. 31. Think Vending Machine Service Guy Coffee Inserts coins Out of coffee beans failure Programmer Machine Adds more beans
  32. 32. Think Vending Machine Service Guy Coffee Inserts coins Programmer Machine Gets coffee Out of coffee beans failure Adds more beans
  33. 33. The Right Way Client Service
  34. 34. The Right Way Request Client Service
  35. 35. The Right Way Request Client Service Response
  36. 36. The Right Way Request Validation Error Client Service Response
  37. 37. The Right Way Request Validation Error Client Service Response Application Failure
  38. 38. The Right Way Supervisor Request Validation Error Client Service Response Application Failure
  39. 39. The Right Way Supervisor Request Validation Error Client Service Response Application Failure Manages Failure
  40. 40. Resilience Is By Design
  41. 41. Use Bulkheads 1. Isolate the failure 2. Compartmentalize 3. Manage failure locally 4. Avoid cascading failures
  42. 42. Use Bulkheads 1. Isolate the failure 2. Compartmentalize 3. Manage failure locally 4. Avoid cascading failures
  43. 43. Enter Supervision
  44. 44. Supervisor hierarchies A Foo Bar B C B E A D C Automatic and mandatory supervision
  45. 45. Supervisor hierarchies A Foo Bar B C E A D C Automatic and mandatory supervision B
  46. 46. Supervision in Akka Every single actor has a default supervisor strategy. Which is usually sufficient. But it can be overridden. 19
  47. 47. Supervision in Akka class Supervisor extends AbstractActor { private SupervisorStrategy strategy = new OneForOneStrategy( 10, Duration.create(1, TimeUnit.MINUTES), DirectiveBuilder. match(ArithmeticException.class, e -> resume()). match(NullPointerException.class, e -> restart()). matchAny( e -> escalate()). build()); … // rest of actor omitted } } 19
  48. 48. Resilience requires a Message-Driven Architecture
  49. 49. Elastic “Capable of ready change or easy expansion or contraction” - Merriam Webster
  50. 50. UP Scale
  51. 51. UP Scale and down
  52. 52. 1. Minimize Contention 2. Maximize Locality of Reference 23 We need to
  53. 53. Common points of contention Physical Application
  54. 54. 25 GO
  55. 55. Async 25 GO
  56. 56. 26 Never
  57. 57. 26 Neevveerr
  58. 58. Block 26 Neevveerr
  59. 59. 27 NOTHING share
  60. 60. Needs to be async and non-blocking 28 all the way down…
  61. 61. Needs to be async and non-blocking 28 all the way down…
  62. 62. 29 Single Writer Principle
  63. 63. 29 Single Writer Principle Producers IO device SERIAL & CONTENDED
  64. 64. 29 Single Writer Principle Producers IO device SERIAL & CONTENDED Producers Actor or Queue IO device BATCHED & UNCONTENDED
  65. 65. The Role of Immutable State 30
  66. 66. The Role of Immutable State 30
  67. 67. The Role of Immutable State • Great to represent facts • Messages and Events • Database snapshots • Representing the succession of time 30
  68. 68. The Role of Immutable State • Great to represent facts • Messages and Events • Database snapshots • Representing the succession of time • Mutable State is ok if local and contained • Allows Single-threaded processing • Allows single writer principle • Feels more natural • Publish the results to the world as Immutable State 30
  69. 69. Divide & Conquer 31
  70. 70. 32 Pipelining
  71. 71. ON DEMAND 33 scale
  72. 72. Scale OUT
  73. 73. Scale OUT and in
  74. 74. • Mobile • Cloud Services, REST etc. • NOSQL DBs • Big Data 35 Distributed Computing is the new normal
  75. 75. What is the essence of distributed systems? 36
  76. 76. What is the essence of distributed systems? To try to overcome that 1. Information travels at the speed of light 2. Independent things fail independently 36
  77. 77. No difference Between a Slow node Dead node 37 and a
  78. 78. The network is 38
  79. 79. The network is 38 Inherently Unreliable http://aphyr.com/posts/288-the-network-is-reliable
  80. 80. 39 Graveyard of distributed systems
  81. 81. 39 Graveyard of distributed systems • Distributed Shared Mutable State EVIL N • (where N is number of nodes)
  82. 82. 39 Graveyard of distributed systems • Distributed Shared Mutable State EVIL N • (where N is number of nodes) • Serializable Distributed Transactions
  83. 83. 39 Graveyard of distributed systems • Distributed Shared Mutable State EVIL N • (where N is number of nodes) • Serializable Distributed Transactions • Synchronous RPC
  84. 84. 39 Graveyard of distributed systems • Distributed Shared Mutable State EVIL N • (where N is number of nodes) • Serializable Distributed Transactions • Synchronous RPC • Guaranteed Delivery
  85. 85. 39 Graveyard of distributed systems • Distributed Shared Mutable State EVIL N • (where N is number of nodes) • Serializable Distributed Transactions • Synchronous RPC • Guaranteed Delivery • Distributed Objects • “Sucks like an inverted hurricane” - Martin Fowler
  86. 86. Instead 40
  87. 87. Instead Embrace the Network 40 and be done with it Use Asynchronous Message Passing
  88. 88. TRANSPARENCY 41 location
  89. 89. 42
  90. 90. 42 Scaling Up and Out is essentially the same thing
  91. 91. Elasticity requires a Message-Driven Architecture
  92. 92. Asynchronous Message-Passing is the enabler
  93. 93. 45 Typesafe Reactive Platform • Purely asynchronous and non-blocking web framework • No container required, no inherent bottlenecks in session management • Actors are lightweight, isolated and and communicate via asynchronous message passing • Supervision and clustering in support of fault tolerance • Asynchronous and immutable programming constructs • Composable abstractions enabling simpler concurrency and parallelism
  94. 94. Typesafe Activator http://typesafe.com/platform/getstarted
  95. 95. 47 Finance Internet/Social Media Mfg/Hardware Government Retail
  96. 96. Go Reactive Building Responsive, Resilient, Elastic & Message-Driven Systems Jonas Bonér CTO Typesafe @jboner

×