Similar to the server architecture of QQ games at the same time

xiaoxiao2021-03-06  21

The QQ game finally broke through millions of people at the same time, moving towards a more much goal, which made other many traditional chess leisure game platforms, compared with the group, the association seems to be qq. For the opponent, because QQ has more than 300 million registrations (of course, many are repeated registration) and QQ chat software 9 million online rate, we have been able to build a future by QQ build Powerful chess and casual game empire. Then, how is the QQ game realize millions of people at the same time and keep the game high efficiency? In fact, for any single network server program, the number of connections that can withstand is a theoretical peak, and the TSOCKET is defined by C : Word, we can determine that the peak of this connection is 65535, that is, said, Your single server program can withstand up to 60,000 users simultaneously. However, in practical applications, it is very difficult to connect to 10,000 people and ensure that normal data exchange is very difficult. Usually, this value is between 2000 and 5000, and it is said that QQ's single server is also connected at the same time. It is this value. It is not difficult to implement the single server of 2000 to 5000 users. Under Windows, more mature technology is to use IOCP - complete the port. There are a lot of information related to completing ports and 9CBS forum, and interested friends can search themselves. As long as it is applied, a completed port server can be used in the line at the same time of 2K to 5K. However, 5K's numerical value is too much different from the value of millions, so it is unable to implement a single server while millions of people. To achieve millions of people simultaneously online, you must first achieve a relatively complete completion of the port server model. This model requires at least 2K to 5K, at the same line rate (of course, if you Money, you can only develop up to 100 People online server). After constructing the basic completion port server, it is designed for the architecture of the server group. The reason is that this is a server group because it is not only a server, it is more than just a type of server. Simply put, the server model that realizes millions of people at the same time: Login Server Hall Server Room Server. Of course, it can be other models, but its basic idea is the same. Below, I will introduce each of these three types of servers one by one. Login Server: Under normal circumstances, we will open a number of public landing servers to players, just when QQ login, let you choose from the QQ game server to log in, QQ login, let the players choose six server entrances actually Login server. The login server mainly completes the load balance. In detail, behind the login server, there is a servers, the login server is just to select which hall server should be connected to the current client connection, when the landing server is selected for the current client connection After a suitable lobby server, the client starts to connect to the corresponding hall based on the information provided by the login server, and the client is interrupted to connect to the login server, and the other player client is connected to the login server to make a socket resource. When designing the login server, at least there should be the following features: Each hall server of the N lobby servers should be connected to all login servers, and in real time notify each of the login servers in the same number of online people. These include: When the number of online people increases information and the number of online number when the user exits is increased.

The number of online people here is online at the same time, the login server selezes a selection of a hall to log in. For example, player A is connected to the landing server by logging in to the server, and the login server starts to choose a hall for the current player in many lobby servers, while connecting the connection IP and port of this hall. After receiving this IP and port information, the client is connected to this hall according to this information, and the client is disconnected between the connection between the landing server, this is the user's login process. Process flow. Hall Server: Hall server, is a server that is unique to players, and its connection IP and port information is the login server notification to the client. That is, in the local file of the QQ game, the specific hall server connection IP and port information are not saved. The main role of the lobby server is to send a game room list information to the player, including: Type, name, online number, connection address, and other information such as game help file URLs. From the interface, the lobby server is our entered the username and password and verify the list of game rooms that pass through. The lobby server, mainly the following functions: First, broadcast all game room online information to the current player; the second is to provide the version of the game and download address information; three is to provide the connection IP and port information of each game room server; four is to provide games URL information; 5 is to provide other game assistive functions. But in this numerous function, it is the most core, namely: provides the player to enter the specific game room channel, let the players go smoothly into the game room that they want to enter. According to the number of people in each game room, it is determined which room has entered it, then double-click a game room in the server list, players start entering the game room server. Game Room Server: Game Room Server, specifically, like "Landlord 1", "Landlord 2" like a play room. The game room server is the specific server responsible for performing game-related logic. Such game logic is divided into two categories: a class is a common game room logic, such as: enter the room, leave the room, enter the table, leave the table, talk in the room; the second class is the game desk logic, this is each The main differences of different types of games, such as the logic of the landlord or the logic of the landlord or the landlord, etc., of course, the game table logic also includes the game logic in all games, such as in the table. Talk, etc. In summary, the game room server is really responsible for executing the game specific logic. The three types of servers mentioned here are to complete the port model. The maximum number of connections per server is 5,000, however, I have a logical layer on the game room server, up to 300 people to be simultaneously online. Other two servers still allow up to 5,000 people to be online. If you are designed according to this structure, then you should be like this to achieve millions of people: first is the hall, 1000000/5000 = 200. That is to say, at least 200 sets of lobby servers, but usually, considering the processing power and load conditions of the server when practical use should be prepared at least about 250 sets of lobby servers.

转载请注明原文地址:https://www.9cbs.com/read-43599.html

New Post(0)