O
O
Oleg_Bar2015-06-17 20:03:37
PostgreSQL
Oleg_Bar, 2015-06-17 20:03:37

Node.js scaling?

Multiplayer game.
An authorized user initiates some action and presses "Start".
There is a search for a game - several parameters are checked, if everything matches - the user goes to an already created room, where, together with the others, he waits for the start of the game.
If the search yielded nothing, then a new room is created and the user waits for the others to connect.
The database (postgresql) is used for logging actions.
The process of searching, comparing parameters, adding new users to rooms, creating / deleting rooms - happens through a variable in node.js
Now everything works fine, within a single node.js process.
But when the cluster module is added, the whole logic collapses, because even within the framework of one machine, each has its own game variable. Moreover, it is impossible to raise new servers (instances) for the same reason.
What do you advise ?
UPD
There are two states for game rooms - waiting and active game (the variable takes one of the values). Rooms for the game are created by the users themselves and are deleted automatically if there are no users in them.
Redis is good when you know what to pull from the store, but not for fetching (although I could be wrong).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Prozorov, 2015-06-17
@Staltec

Store state in Redis or assign specific rooms to specific workers in the cluster.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question