Forum BigDB Saving Many DB Objects in GameClosed()

Discussion and help relating to the PlayerIO database solution, BigDB.

Saving Many DB Objects in GameClosed()

Postby garysimmons » September 19th, 2011, 3:23 pm

Hi All,

I have a world that I need to keep persistent between the room closing and opening again. So in GameClosed() I need to save off all the objects into BigDB.

Now..this could be as many 80 objects...so my question is...is it ok to issue 80 DatabaseObject.Save() calls from within BigDB or is there a limit to how many calls can be operating concurrently? If there is...then what is the best way to persist this many objects to the database when the game closes?

Thx
Gary
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: Saving Many DB Objects in GameClosed()

Postby Oliver » September 20th, 2011, 2:33 pm

There is a limit to how many Saves you can start up when the room closes. I think it's 10. Saves are expensive (bandwidth,cpu,time), so it makes a lot of sense to try and do fewer saves to fewer objects or spread the saves out over time when you change the objects.

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Saving Many DB Objects in GameClosed()

Postby garysimmons » September 20th, 2011, 5:45 pm

Hi Oliver,

Thanks for the reply but I am a little confused as to the best way to persist data using PlayerIO.

Let me tell you a little bit about my situation and perhaps someone here will have some ideas as to how to proceed.

I am using PlayerIO in our upcoming 3D Space Combat MMOG. Each room that is created represents a region of the world where up to 45 players can connect. Each player in the world is flying a space ship (cross X with EVE). Now... to use a very simple example....lets imagine I have 45 players who all decide to log off in fairly quick succession. There player objects need to be saved at the very latest point prior to the game closing or otherwise vital information might be lost. If I saved whenever anything happened to the player I would be hitting BigDB hard all the time with massive traffic and bandwidth. Just think of a spaceship travelling at some velocity who is at some position. I can't save that player object every time it is dirty because it is being made dirty every 50 ms. But...if I do timed saves (say one per minute to spread them out) then when the game closes I risk losing the last minute of any players activity (thus his actual position in the database will be wrong when he next connects with his ship in the game world).

Even if I did all the saves when a player leaves (userleft instead of GameClosed()) It is quite probably that more than 10 or 20 players could leave all relatively close together thus this could cause the maximum number of dbo.save() calls to be made. I need to save the entire state of the world at the point the world is about to stop existing and I am now extremely worried that perhaps PlayerIO will not let me do this. It would be a shame as this kind of persistence is definitely needed if PlayerIO is going to be useful in the MMOG arena. So I guess I am missing something here because reducing the amount of saved or spreading them out doesn't seem to be an option?

My situation is somewhat complicated further by the fact that you can see the spaceships of players that are not currently online. For example, you could park you spaceship at an asteroid and leave it mining for three hours. If other players are connected they will see this ship mining and be able to attack it even if the player is not online. SO I don't just have player objects (a max of 45 to worry about) but I also have objects of non connected players that are still be processed and thus also need to be restored and saved when the game closes/restarts.

To use a very simple...imagine we have 15 players in the room who all point there ships north at 20 mph. Imagine they all then log off. During GameClosed() I would want to save the current position, direction and speed of these ships so that when the game room is next reopened I calculated how much they have moved whilst the room was closed. But in this case, I couldn't even save this off as it would/could exceed the max of 10 dbo.save calls.

I hope you Oliver or someone else out there that has used BigDB for this type of stuff before has some suggestions on how to persist these types of scenes. I absolutely love PlayerIO and have already invested quite a bit of time in it and would be devastated to find for this one reason it wasn't suited to our title.

Oliver..whilst I understand that many saves are expensive...some times lots of things need to be saved for the game to work and there isn't much you can do about that. Plus...surely it would be much less bandwidth to do a big save once at room destruction than to constantly do polling saves whenever an object becomes dirty.
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm

Re: Saving Many DB Objects in GameClosed()

Postby Oliver » September 20th, 2011, 5:58 pm

Save player objects when the user leaves the room (UserLeft) and not in GameClosed(). The limitation is ONLY on GameClosed(). That should take care of most of your problems.

Also, it might (or not, depending on your model) make sense to have one or a few database objects represent a zone, and only load/change/save those objects inside the zone.

Best,
Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Saving Many DB Objects in GameClosed()

Postby garysimmons » September 20th, 2011, 7:08 pm

Thanks for the fast response!

The limitation is ONLY on GameClosed().


ah ha..:) That's great! that's the bit I was missing and certainly helps some of my problems.


Also, it might (or not, depending on your model) make sense to have one or a few database objects represent a zone


Ummm... I suppose there might be some way to use the scene's spatial tree to also more optimally choose when to save db objects but I am uncertain how well that would work in my case. Worth some serious thought.... thanks
garysimmons
 
Posts: 99
Joined: May 15th, 2011, 12:02 pm


Return to BigDB



cron