I am trying to build a realtime multiplayer game with Node / SocketIO on Heroku and am not sure how to handle multiple dynos with regards to sharing SocketIO connection data.
For example:
- I have 2 Heroku dynos, each running Node + SocketIO
- Player A hosts a game, and dyno 1 handles that connection
- Player B attempts to joins the same game, but due to the Heroku router, dyno 2 ends up handling that connection.
- Actions in the game need to happen in real time, so when Player A performs an action Player B needs to immediately see the results of that action.
In a single-dyno environment, this would be relatively simple. When Player A performs an action, it simply gets emitted to player B. How would this work when there are multiple dynos?