Persistent simulation help 101

Hi All,

I am very new to coding/creating this idea; so, please bear with me here, but:

How do I create a persistent always online world that clients can log into and observe?

I’ve currently gotten to the level of being easily able to create multiplayer VR worlds with babylonjs; however, I don’t understand how to keep those worlds… always on?

Do I have to use a database? Can I just tell my server never shut down?

Is there a tutorial for always on worlds? Is it a lot simpler than I thought?

Thank you for your advice/ideas.

I’m having a bit of trouble understanding what you are looking for, but this might solve your issue:

Boosting an app keeps it online 24/7

Does keeping it online 247 mean that eg I could perform a continuous calculation on the server side and log in anytime with a client and look at the results, eg?

A Pro plan gives you access to always-on boosted apps. Like all projects they do a quick restart every twelve hours to free up server resources, but they don’t need to sleep when inactive. ←

So, what Im seeing here is they sleep after 12 hours, but I want it on FOREVER. Do I have to create some kind of custom solution?

You would need a “database” of some sort in every case. It can be a relational database but it doesn’t have to be but it must store data. Both if and when something goes wrong and the world needs to be recovered or when there is so much data in memory that your world can no longer support it.

so there is the “glitch + node + squlite” template, but how do I get around this shut down and restart every 12 hours problem? do I have to tell it to continuously record into the database and then if it shuts down upload from the database… that sounds complicated?

wouldn’t the easy thing to do just be to tell it like never ever ever turn off? then wouldn’t I not even need a database?

There is no such thing as “never ever turn off”.
If you store data in memory you have a “data base”
If you never turn your PC off you are inferring that you could remove the hard drive.

Ask yourself a question. “How do systems like Glitch save my edits immediately and restore them when the system is restarted?”

You got me with the save edits immediately and restore them. OK, I’m going to take the node + sqlite example and try to make a sketch that saves the positions of 3d meshes into the database continuously, and whenever it restarts boots up from the data in the database. That’s the right way to tackle this, yeah? Thanks for your advice.

Actually that is a start. You will have a mechanism that can persist and restore and then you look for opportunities to optimize. We obviously don’t know what you need to save or the importance/tradeoffs of saving once a second, once a minute or as people log off and on.

If nobody is playing the game do you imagine things rotating and positions needing to be saved?

The other thing you should do is get confirmation from Glitch as to if (and when) they reboot servers. That it would be arbitrary or even regular seems odd to me considering tasks could be running on any number of apps that impact the owners of those tasks.

There also could be an API event that your app could subscribe to giving you notice of a shutdown about to occur. If it mattered a lot to me I would confirm these things and weigh my options.

1 Like