In a multiplayer chess game based on web where the server must validate the plays, store the current game state and provide the gameboard info to be rendered on client side, among other things related to the bussiness rules, is it possible to handle several matches in just one server or I have to instantiate one server per match? How is this kind of logic generally implemented?

My main idea is to store each game state on redis, so when an event occurs(like moving a piece), get the state related to that specific match, handle the validations, update it and send the new match state to the clients, As I never did it before I'm not sure if it can work with several matches, what do you guys think?

  • 1
    \$\begingroup\$ Yes, the usual way is to have one server handle multiple matches. Chess does not take much of server resources, a few thousand matches per server should not be a problem \$\endgroup\$
    – Zibelas
    Nov 1, 2022 at 18:35
  • \$\begingroup\$ What obstacle do you believe would prevent you from managing multiple matches on one server? When you try to implement a scheme like the one you describe, where, concretely, do you get stuck? If you don't see an obstacle, then I'm not sure there's anything to answer here. Just try the way you thought of, and ask here if something goes wrong. \$\endgroup\$
    – DMGregory
    Nov 1, 2022 at 21:02
  • \$\begingroup\$ @DMGregory, I was a little overwhelmed with the informations about multiplayer games out there and wondering if a websocket server could handle different game states/matches at same time without a weird behavior, because in single player games generally you have all the game rules and states running on client side within a loop and here I'm trying to decouple the game rules from the client and just hand over the states to be rendered, so I'm trying to make sure that it could work before spending some weeks just to know later there's a fault in the logic. \$\endgroup\$ Nov 2, 2022 at 13:01


You must log in to answer this question.

Browse other questions tagged .