This is my first foray into game-dev and I only have webapp experience professionally. I'm creating a browser game in nodejs/react. It is mostly text-based, so no intensive graphics (think chess.com without the board/pieces). There is a multiplayer element where timing by the tenths of seconds is critical.

What is the best way to implement a backend architecture that can:

  • Host multiple games at a time
  • Run a gameloop for 5 minutes per game (timer, game state, etc)
  • Accept player inputs in realtime

More details: The server needs to be ticking all the time. Elements will be revealed on the screen at specific intervals as part of the gameplay. The player is expected to respond to those elements and scored based on when they respond.

These are very simple specs, so I thought I could use Firebase and Cloud Functions to avoid maintaining a backend infra. I'm finding that the realtime performance is really great with firebase, but running a gameloop and accepting player inputs using cloud/serverless functions is very choppy. Also they don't support scheduled tasks at the interval I need, so I'm wasting a lot of resources with the gameloop (ticking) within a function. I definitely cannot do ticking on the client side because of browser throttling.

I'm looking into other services like Playfab or even DigitalOcean's App Platform. So far, I'm beginning to think I'll just have to plunker down and create a standard server. Even then, I'm not experienced to know if a single gameloop can support concurrent games and scale, but that's a different problem.

These BaaS (Firebase, Playfab) seem great so I don't have to worry about the infra stuff (websockets, database, scaling, etc). But the gameloop aspect of my game is making me second guess. Any guidance would be greatly appreciated!



You must log in to answer this question.

Browse other questions tagged .