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

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

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

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.

Jonas Bonér

October 01, 2014
Tweet

More Decks by Jonas Bonér

Other Decks in Programming

Transcript

  1. 3 Yesterday Today Single machines Clusters of machines Single core

    processors Multicore processors Expensive RAM Cheap RAM
  2. 3 Yesterday Today Single machines Clusters of machines Single core

    processors Multicore processors Expensive RAM Cheap RAM Expensive disk Cheap disk
  3. 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
  4. 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
  5. 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
  6. 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
  7. 9 1. Blue skies 2. Heavy load 3. Failures The

    system should always be responsive
  8. Resilient “The ability of a substance or object to spring

    back into shape” “The capacity to recover quickly from difficulties” - Merriam Webster
  9. Coffee Machine Programmer Service Guy Inserts coins Out of coffee

    beans failure Adds more beans Think Vending Machine
  10. Coffee Machine Programmer Service Guy Inserts coins Gets coffee Out

    of coffee beans failure Adds more beans Think Vending Machine
  11. A B Bar Foo C B E A D C

    Automatic and mandatory supervision Supervisor hierarchies
  12. A B Bar Foo C E A D C Automatic

    and mandatory supervision Supervisor hierarchies B
  13. 19 Every single actor has a default supervisor strategy. Which

    is usually sufficient. But it can be overridden. Supervision in Akka
  14. 19 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 } } Supervision in Akka
  15. 29 Single Writer Principle IO device Producers SERIAL & CONTENDED

    IO device Producers Actor or Queue BATCHED & UNCONTENDED
  16. The Role of Immutable State • Great to represent facts

    • Messages and Events • Database snapshots • Representing the succession of time 30
  17. 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
  18. • Mobile • Cloud Services, REST etc. • NOSQL DBs

    • Big Data 35 Distributed Computing is the new normal
  19. 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
  20. 39 Graveyard of distributed systems • Distributed Shared Mutable State

    • EVIL (where N is number of nodes) N • Serializable Distributed Transactions
  21. 39 Graveyard of distributed systems • Distributed Shared Mutable State

    • EVIL (where N is number of nodes) N • Serializable Distributed Transactions • Synchronous RPC
  22. 39 Graveyard of distributed systems • Distributed Shared Mutable State

    • EVIL (where N is number of nodes) N • Serializable Distributed Transactions • Synchronous RPC • Guaranteed Delivery
  23. 39 Graveyard of distributed systems • Distributed Shared Mutable State

    • EVIL (where N is number of nodes) N • Serializable Distributed Transactions • Synchronous RPC • Guaranteed Delivery • Distributed Objects • “Sucks like an inverted hurricane” - Martin Fowler
  24. Embrace the Network Instead 40 and be done with it

    Use Asynchronous Message Passing
  25. 42

  26. 45 Typesafe Reactive Platform • Actors are lightweight, isolated and

    and communicate via asynchronous message passing • Supervision and clustering in support of fault tolerance • Purely asynchronous and non-blocking web framework • No container required, no inherent bottlenecks in session management • Asynchronous and immutable programming constructs • Composable abstractions enabling simpler concurrency and parallelism