1

I have a question about scalability. Let's say I have a multiplayer game, such as Uno, where the server handles everything. (Assume this is a text-only game for simplicity). For example, to get information printed out to the user in the client, the server might send PRINT string, or CHOOSE data (to pick a card to play), etc. In this regard, the client is "dumb" and the server handles the game logic.

A quick example of how this might work on a protocol level:
Server sends: PRINT Choose a card
Server sends: CHOOSE Red 1,Blue 1 (user shown a button or something, and picks Red 1)
Client sends: Red 1

Let's say I have this architecture:
Player Class: stores the cards the user has, maybe some methods (such as tellData(String data) which would send PRINT data, sendPM() which could private message a user)

Server Class: handles authentication, allows users to create new games, shows users a list of games they can join

Game Class: handles users playing a card, handles switching to a new player for his or her turn, calls methods on player class like tellData(), pickCard(), etc

How would I scale this, to run the server on multiple computers? Right now, all of the users connect to one server, and require the Player, Server, and Game class to interact with each other. If someone could provide some suggestions, and/or point me to some good resources/books on this, it would be greatly appreciated (no, this is not a homework assignment or something for a business, this is just a personal project and curiosity of mine). In terms of scalability, I'd like to just be able to add another server, and handle the additional load of players--but the most concurrent connections would be 1000.

Also, would this become significantly more difficult of a scalability challenge if we added in more games?

Furthermore, what is the best way to store game data? In a SQL database, or serializing objects, or what? By this, I mean let's say 3 users are in a game of Uno, and want to return to it later. I don't want to store their cards and information about the game in the Player/Server/Game class (RAM) forever - I want to dump this somewhere, so when the user logs in, the info can be loaded from however this was dumped into RAM, and then the appropriate Player/Game objects.

Finally, how can I make changes to the server without having to kill it, and restart it? Assume the server was written in Java or Python.

If anyone can provide suggestions or some resources it would be greatly appreciated - this includes changing the architecture I originally stated.

Thanks for any and all help!!

EDIT: Are there any good books or talks you all would recommend on the subject?

4

1 回答 1

0

1.可扩展性: 涉及跨多个服务器实例的应用程序架构,会话被复制/共享和负载平衡。您可以选择为您的应用程序实现消息队列 ( rabbitmq ) / ESB(企业服务总线)架构。

2.易于扩展: 取决于部署和您选择的服务器。

3.Pesistance: 一个人的游戏涉及他在任何时间点的特定游戏状态。如果您可以在语义上表示状态信息,则可以将数据保存在标记保存文件中,或者将状态信息直接存储到数据库中。否则,您可能需要序列化对象并将它们存储在文件系统上/作为数据库中的 BLOB,以防状态空间巨大。

4.热部署: JVM大多总是需要重启来重新加载类文件,因此在java服务器端你总是需要重启。在 Ruby/Rails 中,应用程序的某些部分可以热部署。如果您需要 100% 的热部署性,也许 Erlang 就是答案。

为了提高并发性,您还可以使用事件服务器/应用程序架构:用于 ruby​​ 或 apache mina 的 Thin/eventmachine,用于 java 的 jboss netty。

于 2013-10-10T04:18:46.583 回答