Levelling up in Akka
Building an MMOG server
Ajay Viswanathan, Sr. Software Engineer, Sigmoid
Intro to Akka
• The actor model
• Actor systems
• Messaging patterns
• Supervision of actors
• Handling state in Akka
• FSM in Akka
Akka Persistence
• Incoming messages plus current state abstracted as events
• Each event written to pluggable journal
• Events could be manually or auto-persisted
• Snapshot feature for faster recovery times
Akka Streams
• Generic abstraction for handling a wide variety of data I/O
• Basic stream is made up of Source -> <Flows> -> Sink
• Flows are composable
• DSL for creating complex graph flows
Akka Remote
• Allows an actor running on another JVM and ActorSystem to
communicate
• TCP/UDP communication available out of the box with Akka
Akka Cluster
• Allows actors running on multiple JVMs to form a shared actor entity
• New actors register with defined seed nodes
• Alternative is to use routers and a coordinating actor to handle loads
using a particular strategy (Round-Robin by default)
• Sharding API for granular selection of cluster actors for handling
loads
Akka HTTP
• For communicating with 3rd party services
• HTTP and WS protocol support out of the box
• Simple DSL for defining routes and integration with Streams
Akka Testkit
• Allows peeping inside actor for testing state
• Provides convenient TestProbe object for simplified testing simple
actors and FSM actors
• DSLs for testing HTTP routes and streams
Demo
• Modelling Housie (Tambola) as an FSM
• Connecting clients via websocket server
• Broadcast and reply messaging patterns
• Handling of Streams via custom protocol
• Persisting game events
• Repo link - https://github.com/ajatix/akka-housie
References
• http://chumper.github.io/2016/01/06/Akka-Game-From-Scratch.html
• http://doc.akka.io/docs/akka/current/scala/cluster-sharding.html
• http://doc.akka.io/docs/akka/current/scala/persistence.html
• https://github.com/JakubDziworski/Akka-Streams-Websocket-Game-Server
• https://speakerdeck.com/miciek/building-multiplayer-game-using-streams-v2
• https://github.com/miciek/snake-multiplayer-akka-streams/blob/master/src/main/scala/com/michalplachta/snake/Main.scala
• http://leveldb.org/
• http://nodejsconfit.levelgraph.io/#17
• https://github.com/boldradius/akka-exchange
• http://rxmarbles.com/
• https://github.com/dnvriend/akka-persistence-fsm
• https://sachabarbs.wordpress.com/2016/08/16/akka-persistent-actors/
• https://sachabarbs.wordpress.com/2016/09/06/akka-state-machines/
• https://sachabarbs.wordpress.com/2016/09/14/akka-testkit/
• http://tambola.kunals.com/content/nicknames

Levelling up in Akka

  • 1.
    Levelling up inAkka Building an MMOG server Ajay Viswanathan, Sr. Software Engineer, Sigmoid
  • 2.
    Intro to Akka •The actor model • Actor systems • Messaging patterns • Supervision of actors • Handling state in Akka • FSM in Akka
  • 3.
    Akka Persistence • Incomingmessages plus current state abstracted as events • Each event written to pluggable journal • Events could be manually or auto-persisted • Snapshot feature for faster recovery times
  • 4.
    Akka Streams • Genericabstraction for handling a wide variety of data I/O • Basic stream is made up of Source -> <Flows> -> Sink • Flows are composable • DSL for creating complex graph flows
  • 5.
    Akka Remote • Allowsan actor running on another JVM and ActorSystem to communicate • TCP/UDP communication available out of the box with Akka
  • 6.
    Akka Cluster • Allowsactors running on multiple JVMs to form a shared actor entity • New actors register with defined seed nodes • Alternative is to use routers and a coordinating actor to handle loads using a particular strategy (Round-Robin by default) • Sharding API for granular selection of cluster actors for handling loads
  • 7.
    Akka HTTP • Forcommunicating with 3rd party services • HTTP and WS protocol support out of the box • Simple DSL for defining routes and integration with Streams
  • 8.
    Akka Testkit • Allowspeeping inside actor for testing state • Provides convenient TestProbe object for simplified testing simple actors and FSM actors • DSLs for testing HTTP routes and streams
  • 9.
    Demo • Modelling Housie(Tambola) as an FSM • Connecting clients via websocket server • Broadcast and reply messaging patterns • Handling of Streams via custom protocol • Persisting game events • Repo link - https://github.com/ajatix/akka-housie
  • 10.
    References • http://chumper.github.io/2016/01/06/Akka-Game-From-Scratch.html • http://doc.akka.io/docs/akka/current/scala/cluster-sharding.html •http://doc.akka.io/docs/akka/current/scala/persistence.html • https://github.com/JakubDziworski/Akka-Streams-Websocket-Game-Server • https://speakerdeck.com/miciek/building-multiplayer-game-using-streams-v2 • https://github.com/miciek/snake-multiplayer-akka-streams/blob/master/src/main/scala/com/michalplachta/snake/Main.scala • http://leveldb.org/ • http://nodejsconfit.levelgraph.io/#17 • https://github.com/boldradius/akka-exchange • http://rxmarbles.com/ • https://github.com/dnvriend/akka-persistence-fsm • https://sachabarbs.wordpress.com/2016/08/16/akka-persistent-actors/ • https://sachabarbs.wordpress.com/2016/09/06/akka-state-machines/ • https://sachabarbs.wordpress.com/2016/09/14/akka-testkit/ • http://tambola.kunals.com/content/nicknames