DEV Community

samuele sala
samuele sala

Posted on

Refactoring a monolithic MPA platform - memory wiped on every deploy

Hi there,

I’m a self-taught fullstack dev. I built a multiplayer writing platform using Node.js, static HTML-EJS, PostgreSQL and railway for the deployment. Everything is bundled together in a single monolithic app (frontend, backend, game logic, etc.).

The issue: every time I push new code, the entirety of the app obviously restarts, and all the in-memory game data is lost.

Basically, the platform creates live games that exist in memory until they're finished. Once a match is over, the "story" get saved permanently to the database. But during the game, it all lives in RAM. Since it's collaborative and competitive, players write in turns, on a timer, in teams, and these sessions must stay alive. A restart breaks everything.

This was fine early on, but now I want to find a real solution.

I was thinking of splitting the platform into:

  • a static frontend
  • a backend for APIs and auth
  • a separate game engine (where live matches run)

But I’ve never done this kind of separation before. Also looked into Redis, but it feels a bit advanced for me right now.

Anyone here ever dealt with something similar? Any advice on how to approach this transition?

Top comments (0)