Loading Scripts on the Server, Lightening the load on the API

I know that players should have no more than 6 slimes active in the current setup but I am running some stress tests on the save system and I have found it overwhelming the API. If there are hundreds or thousands of slimes being saved the API wont be able to keep up. I need to lessen the amount of API calls. This is something I was kind of expecting, really. I could use multiple API instances behind a load balancer but there's a limit to what that can do as well.

I should probably have the slime save function send all of the player's active slimes in one chunk. That reduces 6 potential calls to 1.

Before I set about that I want to finish the server script loading, which is also a lot of API calls as well. I think what I might do is set up a server manager app on the API itself, then set up some post save calls to it. When something saves it should tell the game server to pull the changes or in some cases, push the changes itself.

This way on loading slime data we wont have to hit the API for every script, the game server will already know it has the latest script. I also have to write a versioning system on the slimes so that we can reduce the API calls from clients dramatically as well as save bandwidth on sprite downloads. This was the plan from the start but I wanted to finish the loaders first.

So I will finish up my loaders, then do the versioning system on the slimes. I will make a high priority issue for reducing API calls as well as setting up Gunicorn to help with the strain.

Issue Created

Back to script loading for now, while I do this I might consider where to handle the web hooks and how. I am not sure if Godot has any built in way to LISTEN for web hooks. I do know I saw some JSONRPC stuff in the Docs somewhere so that might be a place to handle this instead. We shall see. If I can just handle it with a hook, sending a payload from the API I would prefer it that way as it doesn't require any RPC or sockets being maintained.

Right. Scripts.

Script Loading Handled

Now the scripts are loading on the server, all I have to do is call their OnLoad() hook to make sure they are loaded correctly and so they can set themselves up if they have any setup to do. Which is actually a bit tricky, the script that loads the part scripts is in fact replaced by the script it loads. I suppose the way to handle this is simply in the ready function of the loaded script itself. I don't have any shaders or particle emitters to set up here on the server, after all.

Now to deal with this;

We shouldn't be fetching all the sprites EVERY SINGLE TIME we load them. Only if the slime has changed.

So to do that I need to add the versioning system to the Slime model. Off to the API code I go.

Simple enough. Just a Ctrl+C, Crtl+V job. Though I am not saving a Face, am I?

Just gotta make some migrations and run them, then implement client-side version checking for the slime on loading.

Slime Versioning is good to go.

So the first thing I need to do is set up a way of tracking slime data. I wont use a singular database for this because it would require loading a lot of data into memory. I will break it down into individual slime files. Each one a JSON file of course.

In the JSON I will only track the version of the slime... I don't think I really need any more data in there. All I really need to do is check the version when the slime loads, if the local version is less than the server version, pull the parts. I may want to track other data down the line, but for now I just need to know if the slime has changed. Whenever the slime changes it's sprites are regenerated by the compositor API.

Quick lunch-time rant; The quality of developers is going way down. Avangrid websites are absolute trash. It's like the person making this just learned the basics of how to develop a basic REST API with stateful routing frontend. I can not believe how terrible it is. Page loads taking up to 2 minutes while the front end router hops from display to display with intermittent error messages. Woooow. I couldn't even find where to pay my bill because it wasn't in the billing section, it was in the My account section. What a shit-show. I wouldn't be so angry if it wasn't like this for I believe over a year and they just updated it and MADE IT WORSE. Anyway, gonna have lunch and make some calls then get back to work.

Caching slime parts client side.

With that I can start working on building the character on the client.

Assembled. Lots of frames. Many... many frames.
Loading characters works as intended so far.
Basic movement and collision is working.

Got 2D navigation and collision set up. Need to get animation done next.

Out of time for today though.

After all that we're up to the point where you can log in with a character and have a wander.

Monday I will add some animation to the player and load the slimes into the room.