简体   繁体   中英

A good approch to writing a heavily concurrent application

I am designing a web application (a game) and plan to use C#/.Net for implementation. I have concerns about scalability and performance given what I want to achieve. Here goes the app. There is a virtual world consisting of many kingdoms. Wars take place among these kingdoms for supremacy. As the game is played on I want to display the exact population of the world in real time, ie when people are born population increases and when they die in war (or otherwise) it decreases. Hence, my problem boils down to a number which is updated by potentially thousands of gamers and displayed on the web page. How do you manage this in real time. Storing the number in a database will probably not work as it needs to be updated so many times concurrently. What other techniques can be used? Is this a candidate for No-SQL database, memcached, Hadoop? Any suggestions?
Many thanks.

It probably isn't a good idea to 'push' updates to the client, since this will clog the network when traffic gets high. Instead, you should query the population every second or so, so this moves any bottlenecks to the server's CPU, which is generally faster than the network connection.

You probably will need some kind of database to store population data, since you need to keep track of population between queries.

This approach also prevents the client's data from becoming corrupted, as instead of increments/decrements, the data is replaced each time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM