java - Which protocol to choose for a turn-based game server -


I am writing a game server for Java based game. These are the facts:

  • The speed of the game is slow, so customers need to send data, we say every 8 seconds, and this data is just a small incremental update (A
  • The server must support a large number of players, which say that 1000, which play one of the few hundred games
  • When the player makes a turn, the other of the same game Players should be informed about this step. First of all, I excluded UDP from my options list because I need a reliable protocol because in rare cases I really need to send some data that can not fit in a packet and I want to merge packets and similar things I do not want to be disturbed, watches over the orders of outdated packages and other low-level items.

    There is a dilemma that TCP or HTTP

    TCP attempt # 1

    The connection server (and vice-president) is opened to the customer all the time. When the action takes place, the server can easily inform other players in the game which was to run. The main thing to bother me with this view is that is it advisable that it is possible that more than 1,000 connections and sockets are always opened?

    TCP attempt # 2

    One option I thought was to use a client to install a separate connection / socket on each request Is for A customer opens a connection, sends some small data to the server and closes that connection. With this approach, I can have a fixed size thread pool which says 10 and separate the client's request in each thread so that there are at most 10 connecticons / sockets that can be opened at any time.

    1. The cost of opening / closing the connection to the client
    2. The way to inform other players in the game, because the connection is most close to them, In order to update in the "voting" server one should say in other words.

    What is the cost of establishing a TCP socket / connection? Is this expensive operation or is it only done in some MS (or less)?

    HTTP

    1. Is there a lot overhead if I'll send a new GET / Post to send some bytes?
    2. Can I have 1000 HTTPT connections for clients together and then use AJX or similar things to reduce the overhead? In that case, will 1000 simultaneous connections create a significant problem about bandwidth / performance?

    I have been opened for any suggestions / advice.

Just for your information: HTTP is TCP A typical protocol using TCP is that. HTTP is based on TCP, such as TCP based on IP, etc. So really your choice is between TCP on a custom protocol on HTTP or TCP. You are right that the UDP is a bad match.

If you are writing the server itself, then many advantages of using HTTP are removed. The main advantage of HTTP is that highly customized servers are already available so that you have a simple and effective RPC system Can be used as. But if you are writing the server yourself, you are not likely to reach the capacity of Apache's choice so that you have to ask why you will not use only a simple protocol? In addition, it seems to be the wrong way of hacking around the bridge-type nature of HTTP.

With this in mind, I only use a more lightweight protocol on TCP. You gain more control over the connection and can notify customers interested in updates without the need to vote for the changes. You may also lose HTTP requests / feedback overhead which is more important than most of your needs. You can use a simple simple bespoke protocol instead, maybe based around XML or JSON, or perhaps one of the existing RPC methods is available.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -