Some online strategy games have real time events. For example when you send troops to attack somewhere, the attack happens at the right time in the future. Checking the database again and again to get the list of attacks happening each second would cause heavy load. Is there any technique to achieve this goal?

Another example: You want to attack a village 3 hours away, you send troops and the attack occurs 3 hours later. Should there be an script to check the database at each second to run the query at the specified time?

  • 1
    \$\begingroup\$ What is the specific problem you are trying to solve for your game? Asking only about how other games implement some feature is trivia, and generally off-topic. \$\endgroup\$
    – user1430
    Oct 28, 2013 at 15:27
  • 1
    \$\begingroup\$ Related (based off what I think you're asking): Implementing a build queue in a browser based game and How to update a game off a database And you might want to list some technologies if you want slightly more specific answers. Essentially, you should use an event scheduler. \$\endgroup\$
    – House
    Oct 28, 2013 at 15:32
  • 2
    \$\begingroup\$ The server can maintain a sorted list of upcoming events and push them to the client at the right time. \$\endgroup\$
    – Gir
    Oct 28, 2013 at 16:44
  • \$\begingroup\$ The title of the question I linked seems unrelated, but my answer to this question will be almost identical. Calculate events upon request when a user is actually interacting with the system, not silently in the background needlessly. \$\endgroup\$ Nov 1, 2013 at 0:22


Browse other questions tagged .