Optimally saving user data [MySQL] -
yanir3 - 07.10.2014
Currently, I use MySQL account system (r39-2) in the traditional way. You load user data into variables when he connects, and send an UPDATE query when he disconnects.
Sometimes, the server might crash, be DDoSed or whatsoever. I don't want to lose users' data and have a rollback.
What would be the optimal way to solve this?
Saving users' stats every X amount of time?
Updating the MySQL entry whenever the variable changes?
P.S. I have an additional question. Is it okay to use mysql_pquery when OnGameModeExit is called? I'm afraid that the server will shutdown before all threaded queries are executed.
Re: Optimally saving user data [MySQL] -
Eth - 07.10.2014
Saving users' stats every X amount of time
this one
save it every let's see 1 minute or 30 seconds
and about gamemodeexit thing I think it maybe safe just try
Re: Optimally saving user data [MySQL] -
JacobEdwards - 07.10.2014
You could use y_timers or just the native timer function, then make a loop within the timer function that saves the player information the same way you would in OnPlayerDisconnect.
Re: Optimally saving user data [MySQL] -
Shaneisace - 07.10.2014
Save the users who are logged in every 5-10 minutes or so.
and then request a save when they disconnect or timeout
That way not much data is lost when the server goes down. and shouldn't cause massive stress to the server
(i do mine every 5 minutes)
Re: Optimally saving user data [MySQL] -
yanir3 - 07.10.2014
Okay, I'll probably set a ptask with y_timers so the save won't be at the same time for all players
Re: Optimally saving user data [MySQL] -
Shaneisace - 07.10.2014
Trigger the save to be global i.e not each for players that can cause stress to the database with all the open connections happening over time.
If you just trigger it once per 5-10 minutes to those logged in you should be fine as the disconnect should catch those who logout before / after the interval
Re: Optimally saving user data [MySQL] -
IceCube! - 07.10.2014
Quote:
Originally Posted by Eth
Saving users' stats every X amount of time
this one
save it every let's see 1 minute or 30 seconds
and about gamemodeexit thing I think it maybe safe just try
|
Every 1 minute or 30 seconds!?! With MySQL?!? For EVERY Users?!? I would recommend you extend this to arond every 5 - 10 minutes. It's less server load, thus less stress on the network, server, and the machine itself.
No one's going to care if they loose 5 - 10 minutes of game play.