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.

Reactive applications with Akka.Net - DDD East Anglia 2015

2,328 views

Published on

Application requirements have changed significantly over the past 20 years and we’re now building software which has to handle potentially millions of users and billions of devices. The reactive manifesto is a set of common traits shared by applications capable of handling these new requirements. Akka is the canonical example of a toolkit for building such applications, but thanks to a team of dedicated developers, Akka has arrived on the CLR in the form of Akka.Net. This session looks at the key principles of Akka.Net and how using these you can build applications which handle potentially massive traffic.

Published in: Technology

Reactive applications with Akka.Net - DDD East Anglia 2015

  1. 1. Reactive Applications with akka.Net Anthony Brown @bruinbrown93 me@anthonyjbrown.co.uk
  2. 2. HI, I’m Anthony Software engineer at Adbrain me@anthonyjbrown.co.uk @bruinbrown93
  3. 3. Computers have changed… A lot
  4. 4. Some of the changes Faster processors More processor cores More RAM Faster networks with more bandwidth
  5. 5. We need to make sure applications are responsive to user actions
  6. 6. Moore’s Law
  7. 7. Scale up no longer possible
  8. 8. What’s the options?
  9. 9. CPUs have more cores Networks are faster
  10. 10. Scale out is now possible
  11. 11. Scale out relies on doing lots of work simultaneously
  12. 12. To do work simultaneously, we need either parallelism or concurrency
  13. 13. Parallelism is easy for Embarrassingly parallel tasks
  14. 14. For more complex tasks, we need concurrency
  15. 15. Is there a difference?
  16. 16. Concurrency Parallelism Thread 1 Thread 2 Thread 1 Thread 2
  17. 17. Concurrency is hard
  18. 18. MULTITHREADING THEORY PRACTICE
  19. 19. CHECK OUT MY MULTITHREADED CODE
  20. 20. HOW MANY THREADS DOES IT TAKE TO CHANGE A LIGHTBULB?
  21. 21. We don’t want to write multithreaded code
  22. 22. Use concurrency abstractions instead
  23. 23. You’ve probably used one Tasks
  24. 24. There’s another - actors
  25. 25. Why are tasks bad?
  26. 26. They’re not, they solve a different problem
  27. 27. Promote isolation over co- ordination
  28. 28. Actors are independent entities
  29. 29. Why does this matter?
  30. 30. We said we need applications to be responsive
  31. 31. What does it mean for an application to be responsive?
  32. 32. For an application to be responsive, it needs to work no matter what the scenario
  33. 33. Heavy load
  34. 34. Service failure
  35. 35. If we want to manage these, we need loose coupling
  36. 36. Common language for these applications
  37. 37. Reactive reactivemanifesto.org
  38. 38. RESPONSIVE RESILIENT ELASTIC MESSAGE PASSING
  39. 39. Reactive applications React to their environment
  40. 40. using actors to write reactive applications
  41. 41. an actor is A mailbox behaviour state
  42. 42. We saw that actors are strongly isolated, they encapsulate their state
  43. 43. To modify the state, we have a behaviour which is responsible for it
  44. 44. We invoke the behaviour by sending it a message
  45. 45. Messages are processed serially but on separate threads
  46. 46. An actor can send a finite number of messages
  47. 47. An actor can spawn a finite number of actors
  48. 48. An actor can change how it responds to the next message
  49. 49. How can we write actors?
  50. 50. Using akka.Net
  51. 51. Step 1 Define an actor
  52. 52. class  GreetingActor  :  ReceiveActor   {          public  GreetingActor()          {                  Receive<string>(                          s  =>  Console.WriteLine(“Hello  ”  +  s));          }   }
  53. 53. Step 2 Create an actor system
  54. 54. var  system  =  ActorSystem.Create(“GreeterSystem”);
  55. 55. Step 3 Spawn the actor
  56. 56. var  greeterActor  =  system.ActorOf<GreeterActor>();
  57. 57. where is my actual actor? AKKA.net root actor your actors
  58. 58. Step 4 Talk to the actor
  59. 59. greeter.Tell(“DDDEA”);
  60. 60. What about F#?
  61. 61. Full F# API
  62. 62. Built upon Erlang foundations
  63. 63. let  Actor  count  =          actor  {                  let!  msg  =  mailbox.Receive  ()                  printfn  “Message  %i:  %A”  count  msg                  return!  actor  (count+1)          }
  64. 64. Resilience in distributed systems
  65. 65. Cloud brings about failure
  66. 66. your users don’t want to see THIS
  67. 67. Need to isolate failures quickly and automatically recover from them
  68. 68. How can we isolate errors?
  69. 69. Separate error channels
  70. 70. Service aService B supervisor Request Response user error error action
  71. 71. Handling increased load in a distributed system
  72. 72. Easiest way to scale is to make the servers bigger
  73. 73. Scale up has a limit, scale out doesn't
  74. 74. Scale out is easy with isolation
  75. 75. Actors give us isolation therefore scalability is easy with actors
  76. 76. Routers
  77. 77. Taking akka.Net to the next level
  78. 78. Akka.Remote
  79. 79. Connecting 2 actor systems in a client-server architecture
  80. 80. Akka.Cluster
  81. 81. Takes remoting to the next level
  82. 82. Treat multiple machines as one actor system
  83. 83. Cluster aware routers
  84. 84. Cluster sharding
  85. 85. Akka.Persistence
  86. 86. Allows for easy CQRS and Event sourcing with actors
  87. 87. Akka.DistributedData
  88. 88. Allows for sharing data between actors with strong eventual consistency
  89. 89. Where can I use akka.Net?
  90. 90. IoT applications
  91. 91. Job scheduling / cluster management
  92. 92. Gaming
  93. 93. User interfaces
  94. 94. Microservices deployments
  95. 95. akka.Net provides a solid foundation for the stronger constraints being imposed today and in the future
  96. 96. Want to learn more?
  97. 97. akka.Net bootcamp github.com/petabridge/akka-bootcamp
  98. 98. Reactive applications with akka.Net MEAP soon
  99. 99. StackOverflow stackoverflow.com/tags/akka.net
  100. 100. Want to contribute?
  101. 101. Plenty of up for grabs issues github.com/akkadotnet/akka.net
  102. 102. gitter.im/akkadotnet/akka.net
  103. 103. Q & A

×