Author: sodme article Source:
http://blog.9cbs.net/sodme
Copyright Notice: This article can be arbitrarily reprinted by the author, but when reprint, please keep the article to start the top two lines of copyright, author and information.
Tip: Before reading this article, please read this article to learn about article: http://data.gameres.com/Message.asp? Topicid = 27236 Make countless Chinese players for the "World of Warcraft", with a series The gradual deployment of early test is step by step, but the "World of Warcraft" servers have made us pinched a sweat for it. There are many reasons for a online game server, but there are two types: 1. Server online number reaches the upper limit, server handling efficiency is seriously slow, resulting in a machine; Second, abnormal data caused by external or other game cheating tools The error occurred, leading to the game server logic chaos, resulting in a machine. Here, I mainly want to talk about how the latter avoids as much as possible. To avoid the second case mentioned above, we should follow a basic principle: in the design of the online game server, for processing units with stronger logical relationships, server-side and clients should adopt "mutual trust principles" That is, even if the server is received, even if the client's packet is received, it is not necessary to think that the client has reached a function or state, and the client reaches whether a function or state is reached, but also rely on the server side. The client "previous status" is determined, that is, the logic execution of the server side is not simply performed in "current" client packet, which should also be used to refer to the context environment of the current package, logic executed To make further determination, at the same time, on the processing of a single packet, the server side should be widely considering the "front" packet required for the current client seal, if not received the "front" packet that the client should send, The current packet should not process or perform an exception handling (if you want to have high performance, you can directly ignore the package; if you want the server to stabilize, you can perform different exception processing). The reason why the "mutual distrust" principle is designed online game servers, and a very important consideration is: anti-outside. For a web server (not just a game server, it means all servers), the object it faces is both legitimate network clients belonging to its own system, and there is also an illegal client access to its own system. So, when we consider the interface open-out interface, we should consider both cases: logical tours when accessible, and logical trends in illegal client access. For a simple example: Under normal circumstances, the player login logic is first sent to the server to send the username and password, and then send a packet to a set of servers to the server; but in illegal clients (such as plug-in), then These clients are all possible to enter a set of servers in a set of servers. Of course, here is just an example, may not be appropriate, but the basic meaning I have expressed clear, ie: Your server doesn't want my client to send anything, you have to conduct a series of logic verifications, To determine whether the operation I currently execute is not legal. In this example, the server side can perform verification functions by the following logic: Only when the client's username and password passes the verification, the client will enter the list of online players. Only members of the online player list can enter each packet server under the boot of the login server.