1
\$\begingroup\$

I have a nginx load balancer with 4 nodejs instances behind it, and one Redis server to share certain memory.

My game is an instance game, similar to Diablo 2. Players can create "games" if you will and other players can join them.

The game data is stored locally on the players node of which who created the game (I was going to store the game data in Redis, but have the following dilemma):

When a game is made from a user that is on node instance #1; and a user that is on node instance #2 wants to join that game. This is where I get confused. I want the players to communicate to each other locally (but they cannot because they are not on the same instance). How exactly can I counter this?

These are some solutions I found:

  • Use ZeroMQ or Nanomsg to send the data locally between processes

  • Use the native nodejs IPC protocol to send the data locally between processes

Now, this worries me more. Because I have a feeling I am doing it wrong. When a player is moving around in the map, he needs to send data to all other 5 players in that game. (simple positional packet). This now has to be sent through ZeroMQ (pub subbed) -- or through local sockets (IPC). Isn't this going to be a lot of overhead? Are there other ways to scale an instanced based game with multiple node instances? Or maybe, this is the right way, and I'm underestimating how fast local sockets are (or ZeroMQ's speed)?

\$\endgroup\$
2
  • \$\begingroup\$ Would ditching nginx and implementing the load-balancing yourself be an option? Because then it would be trivially easy to just have the client reconnect to the server with the instance they want to play on. \$\endgroup\$ Commented Jun 10, 2016 at 15:33
  • \$\begingroup\$ That's a good idea and yes it is. I think the following problem might arise: When the player leaves a game on that instance and then makes a new game, this can lead to a lot of players ending up on that same node instance and possibly overload it. A way around this is to reconnect them every time they create a new game and load balance them on the least connected node. But, this will result in a ton of re-connections happening all the time. (Since players are joining and creating games 24/7) -- (What if a player is sending them a private message, etc) -- Not sure, I can try that method though. \$\endgroup\$ Commented Jun 10, 2016 at 15:52

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.