简体   繁体   English

编写大量并发应用程序的好方法

[英]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. 我正在设计一个Web应用程序(一个游戏),并计划使用C#/。Net进行实施。 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? 这是No-SQL数据库,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. 相反,您应该每秒查询一次填充,以便将所有瓶颈移至服务器的CPU,这通常比网络连接要快。

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. 这种方法还可以防止客户端的数据损坏,因为每次都会替换数据,而不是增加/减少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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