Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am currently building a game that has a "City" entity. These cities generate and consume resources such as food variably over a period of time. I need to be able query the server often to find exactly how much food the city at any given point. These queries can take place multiple times per minute. There could also be 400,000 cities to track at a given time.

How would you handle tracking these resources? Would you do it in real time, keeping an instance of the city in memory on the server, with some sort of a snapshot in time of the resources, then computing the growth/consumption from that snapshot time for subsequent queries? Would you work exclusively with a database, using a similar "snapshoting" scheme? Maybe a mixture of the 2, caching recently queried cities in memory for a period of time?

There is also a lot of other data that each city needs to track. A player can queue units to build in a barrack. The armies available in the city will need to be updated as units complete.

I'm interested in everyone's input on where/when/how you'd manage the real time data.

share|improve this question
I should mention that this is an mmorts – Darthg8r Jun 14 '12 at 21:26
What's the time resolution that needs to be saved - what if the player unexpectedly looses connection? What type of game - is this like the 'player cities' in Age of Empires online, or like the individual battles players engage in? – Clockwork-Muse Jun 14 '12 at 22:45
Player cities. Players build a city, build up it's resources, buildings, armies, etc. Then they can deploy those armies to lay siege on another player city. There are also barbarian cities. So, to answer your question, it's a static world, so all content needs to be saved upon disconnection. – Darthg8r Jun 15 '12 at 12:42
For these battles, what happens if they lose? Do they lose all those units? What happens if they're disconnected during a battle? – Clockwork-Muse Jun 15 '12 at 15:30
@Darthg8r then maybe it's a game like travian? – Gajoo Jun 16 '12 at 1:41

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.