timotheeg / nestrischamps

A web-based OCR and restreamer system for NES Classic Tetris players
MIT License
46 stars 11 forks source link

Extract state from app #48

Open timotheeg opened 3 years ago

timotheeg commented 3 years ago

The App is currently tracking state inmemory:

This means deployment are very disruptive and kick users out, requiring a fresh login.

Ideally, while a deployment will break websockets, everything should resume transparently.

TODO: 1) Move sessions data into DB 2) Extract rooms and users state to DB (possibly to a redis DB?)

Note, with the current load, 1 server can handle all the traffic of nestrischamps. If this ever picks up and nestrischamps needs horizontal scaling, then using a redis instance will likely become a requirement, where rooms will be in redis, and game frame data will transit over redis pubsub.

alex-ong commented 3 years ago

Redid is sub millisecond, but make sure your interconnect is fast enough. I was using python/django and it was screeching to a halt (not redis, the python interface into it).

Especially if you're scaling to say 20 people rooms since you need redis(??) To send to all and receive all

timotheeg commented 3 years ago

Sessions have been extracted to DB, but not rooms. Having the sessions out was already a great improvement, because it means producers, admin and renderers can all reconnect as soon as the app restart is done.

I think this isn't urgent till I see we're approaching server limits, or nestrischamps usage picks up significantly enough that the app restarts really start to affect players and competitions.