When do I save the buffer data?
What if many people play like 10 hours or even let the game running for weeks while they are afk and then your server crashes? They wont be happy loosing all their progress.
Or someone drops an item, his buddy collects it and immediately logs out, while the first intentionally lets the game running until you are doing maintenance and stop the server? Sounds like an easy way to cheat and dupe rare items.
Before you engage in premature optimization you better do it in the simplest and safest possible way that works (save everything immediately), then measure if its really too slow and optimize as needed.
I have never done that level of coding on the web but i think it would be best to try to keep your real data storage (mysql) updated as often as possible. So if mouse eats on the server cable you have as much as possible saved. So i vote for wintertime's suggestion of saving immediately. If it does not work try to do a timed update that runs once every 30 seconds or so to save the player data.
Hmm strange, the vote arrows are gone from the posts for me .
What if many people play like 10 hours or even let the game running for weeks while they are afk and then your server crashes? They wont be happy loosing all their progress.
Or someone drops an item, his buddy collects it and immediately logs out, while the first intentionally lets the game running until you are doing maintenance and stop the server? Sounds like an easy way to cheat and dupe rare items.
Before you engage in premature optimization you better do it in the simplest and safest possible way that works (save everything immediately), then measure if its really too slow and optimize as needed.
Yeah, you bring up a great point. I have no idea why I didn't think of that.
I think when the loot is dropped from a monster, all that item data will be stored in the buffer (as it is now), but only 'WHEN', a player loots it, I will insert it into the items table serverside. Great post, thank you!
Edit: I kept thinking I should stay away from mysql because players will be picking up and dropping items like crazy, and a ton of stuff is sent across the pipes in the nodejs/ws server. But now that I think of it after your post, it has to be done. MYSQL is going to be slammed hard, but it's the only way really. Good thing I have MYSQL pooling
I have never done that level of coding on the web but i think it would be best to try to keep your real data storage (mysql) updated as often as possible. So if mouse eats on the server cable you have as much as possible saved. So i vote for wintertime's suggestion of saving immediately. If it does not work try to do a timed update that runs once every 30 seconds or so to save the player data.
Hmm strange, the vote arrows are gone from the posts for me .
Hmm strange, the vote arrows are gone from the posts for me .
Same here, was going to add to his rep!
That's because he posted it to the Lounge, where voting is disabled. A moderator will probably move it to a more fitting, technical forum, when the arrows will be re-enabled.
Psst. It's called Queue.
Send your 40 INSERT into a queue to be processed asynchronously.