Author Topic: Turn Based Updates and cURL  (Read 386 times)

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Turn Based Updates and cURL
« on: December 15, 2010, 11:48:54 AM »
I was thinking today of the last game I made that used turn based updates.  Ie, at every hour, the game would assign players new resources, turns, etc.  This was several years ago, and server speeds have gotten considerably better... but back then, it would take upwards of 20 seconds to update my game (also, back then, I didn't know I had to index my DB's).  This got me into a small bit of trouble once with the server host...

Looking at my next project, I'm considering how best to implement the update file.  Specifically, I think I'd like to pull all the user's data, calculate what values need to be updated, shove it all into either a class or array, then send it to a non-blocking cURL update function.  I have absolutely no clue if this will truly be beneficial or not (which is the reason for the post), but my idea was that the non-blocking cURL call would send the DB update commands in the background while the main update.php script begins pulling and calculating the required data for the next user update.  With a multi-core server, I was hoping this technique might make use of the extra core. 

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: Turn Based Updates and cURL
« Reply #1 on: December 15, 2010, 01:02:34 PM »
Personally, my preference is to have the program designed to be lazy. No update should be performed for anything until an action that would require that update is performed.

The disadvantage to this approach is that processing would be kinda "spiky" because who knows which updates (or how many) would be performed at any given moment?

But, I like the fact that code can operate 100% assured that the data it's operating on is valid. Additionally, if you rely on some sort of processing script... it's much easier to design that system in such a way that a single missed update (maybe due to hardware failure) would require manual intervention in order to correct the data.
Idiocy - Never underestimate the power of stupid people in large groups.


 


SimplePortal 2.3.3 © 2008-2010, SimplePortal