HTML and CSS Reference
In-Depth Information
So, why not just use MessagePack in all cases if it seems to be faster than JSON and BSON? Microbenchmarks
are usually limited in scope and cannot be predictive of all situations. Which method you should choose depends on
the conditions of your environment, such as the databases you are using. You generally cannot go wrong with either
binary format.
Intelligently Processing and Distributing Packets
Reducing the amount of data transmitted by sending it in a more efficient data exchange format is one way to increase
data processing. An equally effective alternative is simply to send less data. In the following sections, I will discuss
several ways to send fewer packets over the wire.
Send Mostly Deltas and Infrequent Worldviews
You can prevent cheating by using a “dumb” client/authoritative server model, in which the clients do minimal local
calculations and merely display what the server sends them (for more information, see the section “Dumb Clients/
Authoritative Server”). This tactic has the added benefit of allowing the server to optimize further the data that need
to be sent to clients.
The amount of “world” that the client can view is generally a subset of the full world. Sending only the parts of the
world and enemies with which the player can directly interact reduces the data that must be transmitted.
Another way to reduce the transmitted data is to have the server send less frequent worldviews and more
frequent deltas of player and enemy properties.
Autonomous Clients/Echo Server
This kind of setup, in which the clients do everything locally and report their changes to the server, is by far the easiest
client-server combination with which to start. However, it is the one that is the most prone to cheating. When you hear
about cheating in an online game, it is likely that a client was able to change something maliciously and have that
state blindly pushed by the server to all the other clients. This also increases the load on the server, because all actions
have to be received and sent to all the clients by it. Assuming that each client sends one update per second, then as
the number of clients increases, so, too, does the number of updates, and by a large margin, as seen in Table 11-2 .
Table 11-2. Number of Clients vs. Number of Updates
Number of Clients
Updates Sent to Server
Updates Sent by Server
That update rate is very close to being n^2. Combine this with the ever-present threat of cheating and variable
network latency, and chaos is sure to ensue.
Search WWH ::

Custom Search