I'm new to game server development. I'm facing this issue:

I want to develop a card game server, but I'm not sure about the solution to hold the game data while playing.

Example: In a poker game, when a player makes a move, the server will process the request and send it to all other players. But how will the game server know what the current state of the game is to do subsequent actions? Should I save all moves into database and server will look into it to know the current state?


2 Answers 2


The server has to have a copy of the game state.

If you can reasonably expect that the game server will be up and running during a particular game, and that all interaction between players in that game will always occur with that particular game server instance, you can simply hold the state in memory.

If, on the other hand, you expect a server to only be alive during a distinct request from the player, or for requests from a player to be distributed across potentially-many game server instances, you'll need to store the state elsewhere. A database is a possibility, as is another singular server, or a simple file on a disk accessible by all server instances, et cetera. It depends on your specific requirements.

As you claim to be new to this, I would strongly suggest you pursue a model where there's one server per game and it's up for the duration of a game. It's a simpler model to start with.


Most turn based multiplayer games do still keep all game state in memory and have the server living and listening to the players; if you won't be constantly listening to the players and are going to set it up with requests i.e.: host your game server and send RPC/REST requests via HTTP(S) for the player moves, then a KV store like Redis or MongoDB would be a good way to hold the data in-between requests, preferable to an RDBMS because game state will be linear and your player moves and current state can be stored as Hashes (in Redis) and your moves list can be stored as a List (in Redis) so there's no need to use something like MySQL for its more powerful query system. Running a game server for simple card games over HTTP requests and storing state via a Key Value store would make it pretty easy to scale and support many games on one server and build a universal API for Windows, Mac, Linux, Web, iOS, etc versions of the game.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .