5 ms·
I may indeed do this. There is an outstanding issue I have to address that I've never quite worked up the motivation to deal with: Heroku restarts their server
by windowshopping 3y ago
I may indeed do this. There is an outstanding issue I have to address that I've never quite worked up the motivation to deal with:
Heroku restarts their servers once every 24 hours with only thirty seconds' warning. Since the games are in-memory, this of course kicks everyone out of whatever games they may be in the middle of.
I guess the solution is to have the games be on Redis instead of in-memory? I'm a bit more front-end oriented so I was bewildered to learn this was how it worked in the first place and I'm not 100% confident in my solution.
- jryb 3y agoIs using a host that doesn't do this not a possibility?
- windowshopping 3y agoIt seems they all do, though. Digital ocean was the same.
- Tijdreiziger 3y agoAny decent VPS provider (including DigitalOcean, unless they’ve changed anything) definitely doesn’t do this.
- windowshopping 3y agoMaybe you're right, I may be mistaken. Perhaps I should migrate to DO.
- Tijdreiziger 3y agoActually, I should qualify this. If you use a PaaS (platform as a service, e.g. Heroku, DO App Platform, AWS EB), they might assume your app to be stateless and do things like restart it at will. If you use a VPS (virtual private server, e.g. DO Droplet, AWS EC2), this certainly shouldn’t happen, but of course it requires some Linux skills to maintain your VPS. So it’s basically a trade-off between engineering your app to fit a PaaS or hand-managing your VMs (though the latter is usually the cheaper option).
- windowshopping 3y agoYeah, indeed. I can try using a Droplet but I'm just new to managing a VM by hand. I've always used a PaaS for my projects so ensuring uptime and whatever other responsibilities there may be is new for me.
- svnt 3y agoIf that’s the case I’d suggest you probably have a bug in your code somewhere that depends on a timer that resets at midnight. So when it spans midnight everything resets, but this isn’t the server resetting.
- loloquwowndueo 3y agoData persistence is a solved problem. “Server that never fails or reboots” is not.
- HoppyHaus 3y agoThe quickest win would to move off of Heroku. Either rent your own server that you can control (to a reasonable degree), or find an alternative that doesn't suffer that issue. Redis would work but I'd be afraid of race conditions. There probably wouldn't be any, but it's something to be aware of. If you wanted to test the waters with at least the relative public, I'd consider doing step 1 of renting a server, but then hiding it behind a Tor hidden service. Inconvenient to connect to? Yeah. (Probably) safe from the Hasbro demons? Also yeah.
- all2 3y agoLinode is super cheap. I pay 6 or 7 bucks a month for a bottom tier VM.
- windowshopping 3y agoI guess I just haven't done anything outside of a PaaS before and I'm a bit worried about unknown unknowns. I'm sure I'm probably up to the task but managing my own server is just new ground for me. I'll have to research how to ensure that the server is always up or recovers from an unexpected failure and restarts immediately.
- jakemauer 3y agoYou can also split the difference and run Dokku[0] on a vps and basically host your own instance of “Heroku”. It can even use the same build packs and procfiles. Feel free to message me and I’d be happy to help with server stuff. [0] https://dokku.com/ https://dokku.com/
- pythonaut_16 3y agoFly.io would probably work for your use case. Doesn't have the restart limit of Heroku and still has a solid enough free tier to run your app! I'd be happy to help if you need anything! Whether hosting or just backend related questions! Also depending on how hard coded your architecture is, maybe you can separate out the Magic specific data from the app itself? So the MTG specific data could just be loaded as a datapack?
- rkagerer 3y agoArchitect a redundant cluster and let a peer server take over as master?
- exikyut 3y agoI would second the recommendation to move off Heroku. They're essentially the smallest scale version of vendor lock-in out there nowadays, especially considering they're no longer free. An open-sourced codedump will survive best if people (which effectively means "average technically-minded MTG player" in this case) can run it wherever they're most comfortable - which will almost certainly be something that smells like a VPS. Mayyybe a container.
- fennecfoxy 3y agoOn restart warning, take server state (sign/encrypt if you want to) and dump it to each players' clients. If both players are still connected once the server comes up and client reconnects, both players can send state to server and if both players' global states match then the game resumes, if not then error out. If only one player reconnects cause the other couldn't wait & closed tab, then you gotta error out anyways. Then you don't need Redis or any other additional dep at least.