Developers explain: end travel and tour services hand side of the common architecture

Finishing knew almost, Wen / Wei Yi laugh

No difference on hand tour page tour and the end of the tour of the nature of the service end, the difference is the type of game.

Type 1: Card, Parkour and other weak interaction server

Cards Parkour class because there is no interaction between weak player and the player in real time face to face PK, beat each other offline data, calculated by the following charts, props can be traded under, so often achieved using a simple HTTP server:

QQ screenshot 20150923102806.png

Can be used to log asymmetric encryption (RSA, DH), according to the client server uid, the current timestamp as well as the server private key encryption key hash calculation obtained and sent to the client. After using both HTTP traffic, and RC4 encrypted with that key. After the client receives the key and a timestamp stored in memory for later communication, the server does not need to save the key, because every time the client can pass up uid and timestamp server and its private key is calculated. By imitating the behavior of TLS, to ensure that customers among multiple HTTP requester identity, and by the time stamp to ensure that the same person twice log in to different keys.

At the beginning of each round, about access, about the level of data requests, and submit it comes to an end, checking to see if legitimate, obtain any award, with a single database to MySQL or MongoDB, Redis as cache back-end (optional). If you want to achieve notification, then let the client what server polling timer 15 seconds, if there is a message he took it down, if not the message can gradually lengthen polling time, such as 30 seconds; if there is a message, it is time to shorten polling 10 seconds, 5 seconds, even if the two chat, the delay can be adaptively.

Three such servers used to implement a policy or class card and cool running game has more than enough, this type of game because the logic is simple, the interaction between players is not strong, then use HTTP to develop, development speed, debugging requires only a browser you can clear the debug logic.

Type 2: the first generation of game server 1978

In 1978, the famous British Finance University of Essex school student Roy Trubshaw wrote the world's first MUD program "MUD1", at the University of Essex after access ARPANET in 1980 joined a number of external players, and even abroad players. "MUD1" program's source code appeared in numerous adaptations after ARPANET share, bringing the MUD was widely popular in the world. Continuous improvement basis MUD1 produces open source MudOS (1991), the originator of many online games:

QQ screenshot 20150923102932.png

MUDOS using C language development, because there are relatively strong interaction (chat, trade, PK) between the player and the player, MUDOS single-threaded non-blocking sockets to serve all players, all players have made requests to the same thread to process, 1 second every time the main thread updates all objects (network transceiver, the state machine to update the object, the process times out, the map refresh, refresh NPC).

The game world in the form of organized room, each room has four corners can move to the next room, as Europe's first online game is a dungeon maze form, so that the basic unit of the scene known as "room." MUDOS use a scripting language called LPC to describe the whole world (including rooms topology, configuration, NPC, and various plot). Advanced players inside the game (shaman), we can continue to add room by modifying the script for the game and increase the plot. When the line early MUD1 only 17 rooms, Roy Trubshaw after graduation to his Young Richard Battle, in the hands of Richard Battle, continued to add variety to play more than one hundred rooms, MUD finally flourish.

Telnet client user or the like with a terminal connected to the MUDOS Tcp protocol using text game, each instruction is divided by a carriage return. For example, in 1995 China's first MUD game "knight-line", you type: "go east", the game will prompt you: "back garden - here are owned by Top Comfort back garden, full of flowers, a few Zhuangding but here are the flowers of the mimosa growing land where the only exit is north of here are: the flowers to be imam (a mu), there are two Zhuangding (Zhuang Ding) ", then you continue to operate in words , View of the imam: "look a mu", the system prompts: "flower to be imam (a mu) is Lu Chengfeng his disciples, ordered in custody this mimosa he looks in his thirties, it's delicate features. , upright and generous, a talented and his martial arts looks [] is not very high, very light shots seemed []. " Then you can choose to get mimosa beat him, but you eat a mimosa but may poisoning. In resource-poor early online time, this game has a strong sense of substitution.

User data is saved in a file, each user logs in from a text file to the user all the data loaded in, all the operations carried out in memory inside, do not need to brush back to disk immediately. User exits, or every 5 minutes to check changes to the data will be saved to disk. Such a system for each server that hosts a 4000 people at the game at the time, is not a particularly big problem. From MUDOS released in 1991, all around the world for his improvement, expansion, exit the new version, with enhanced graphics performance of Windows. 1997 game "UO" on the basis of MUDOS increase the role of x, y coordinates, an increase of maps for each room, and an increase of animations for each character, the formation of the first generation of graphical online games.

Because the basic game content can be customized by LPC script, so MUDOS also become a veritable first server engine, the engine developed a one-time, then make a different game content. Subsequent domestic "King of Kings" and other games, many of which are now "UO" as secondary development directly on MUDOS, such as adding rooms feature coordinates of a map as well as the role of the architecture has been the first country Generation MMORPG offers a solid support until 2003, as well as games based on MUDOS development.

While behind the graphical increased a lot, but the nature of these back-end MMORPG or MUDOS. With the increasing complexity of game content, architecture becomes more and more too much, and various load problems surfaced slowly, so with our second-generation game server.

Type 3: The second generation of game server 2003

After 2000, online games have been away from the original text MUD, entered the graphical's. The first to bear the fact that many small files, the user off the assembly line, frequently read user data is written, causes the load is growing. With the increasing number of online games and increase data, the server becomes anti burden. At the same time early EXT partition is relatively weak, a little power, prone to large-scale data loss. So the first step is to split the file stored in the database.

QQ screenshot 20150923103004.png

At this point the game has been out of service end MUDOS old system, each company in the case of reference MUDOS structure, beginning with a C in their own re-develop their own game server. And script is also abandoned LPC, better scalability using Python or Lua instead. Since the main logic model using a single thread, as the game content, the further structure of a conventional single-server become a bottleneck. So people began to split the game world, become the following models:

QQ screenshot 20150923103026.png

Game server stress after splitting proud ease, but two games simultaneously access a database server, a large number of repeat visits, exchange large amounts of data, making the database to become the next bottleneck. Thus forming a front-end proxy database (DB Proxy), the game server does not directly access the database but access to the proxy, then proxy to access the database, while providing a level of memory cache. Before early MySQL4 stored procedure does not provide, in general, and the front-end agent MySQL run in the same table, it advanced data conversion operation instruction is sent, the game server, instead of splitting into a specific database stored operation procedure, to a certain extent:

QQ screenshot 20150923103046.png

However, this configuration does not last too long, because players often scene switching switches connection intermediate state easily confused. And more after the game servers, data exchange between each other will become much trouble, so people split the network function, an independent service gateway Gate (some place called Session, some place called LinkSvr like the name It is different):

QQ screenshot 20150923103146.png

The network features extracted separately, allowing users to connect to a unified gateway server, and then there are the gateway server forwards the data to the back-end server game. The exchange of data between the game server is also connected to a unified network management exchange. Such types of servers basically stable for the players game service, a gateway serving 1-2 million people, followed by the game server for each service 5k-1w, depending on the type and complexity of the game is different, not a lot of hidden figures critical server, such as logging and management. This is a model currently the most widely used, and today any course many new projects will come to build such a structure.

Humans have inertia, according to previous experience, it seems that the more open the better the performance MUDOS split. So we continue to think that it can be split gateway, trading infrastructure services such as chat, you can split it, can also provide a web interface, database can split it, so with the following models:

QQ screenshot 20150923103208.png

Such a model is easy to use it? We do have success like this game uses the architecture, and played its performance advantages, such as some large-scale MMORPG. But there are two challenges: one for each additional server, the complexity of the state machine could double, leading to rising research and development costs and to find the bug; and to challenge the development team is relatively large, tight time once the project developers lack of experience, it is easy to get hung.

For example, I've seen a RPG a Shanghai game company's line up to get on this architecture, I looked at the experience of their team members, asked them on the date of the next line, and persuade them to use the front slightly simpler model. People very confident that the success of the project is done, they have to do, he wanted to achieve a set. So they hesitate to start coding, to do the project more than a year, then there is no then the.

In today's game success rate is not high, a start on a relatively complex architecture needs to consider the return on investment, such as your game on line within six months PCU will go into how much? If a APRG game, each server to 5,000 people are not, then choose a structure closer to the actual situation is more economical. Even if your project is really behind more than five thousand people ran toward the goal of 1 million people, I believe that when your project has been a big money, you count the money gradually add the class to iterate again and again breaks it, I believe my heart music is flowering.

These types are basically from the above resolution MUDOS start the MUDOS individual components in a single step by step into detached from distributed. Today, however, although any number of new projects with a certain kind of structure similar to the above, but it did split or other hot module. Because they are essentially on MUDOS of decomposition, it will summarize them for the second generation of game servers.

Type 4: Third-generation game server 2007

From the beginning of World of Warcraft has gained a seamless world map, comparing the past gamers go a few steps further need to switch the scene, each switch will wait for a few tens of seconds is a very LOADING undermine the gaming experience things. So for large-scale MMORPG after 2005, the seamless map has become a standard configuration. According to compare the past to cut the map in terms of the game, there is no one seamless world map and people above deal with only one server of:

QQ screenshot 20150923103233.png

Each Node server for managing a map area to provide overall management for them by the NodeMaster (NM). A higher level of World provides management services to continental level. Several details are omitted here servers, such as the traditional database front-end, the login server, logging and monitoring, all summarized with ADMIN. In such a structure, a player from one area to another area in need of a simple handle it:

QQ screenshot 20150923103251.png

A player control node 1 entirely, completely controlled by the player 3 Node B. While the two nodes at the edge of the player 2, while the services provided by A and B. Player 2 moves from A to B in the process, the situation will also request A to the left, to the right of the case B requests. But then the player still belongs to A 2 management. Player 2 until completely left the boundaries far AB, B was completely handed over to management. Following this logic the world map into regions piece by piece, referred to different Node to manage.

For a Node area of ​​responsibility, need not geographically connected together, such as a block around the edge portion of the people and the mountains of the mainland is relatively small, it can be unified to a Node to manage, and these blocks are not geographically Contact necessity together. What a Node in the end block management, can maintain the timing of when to change NodeMaster above configuration according to the load the game in real time.

So the first problem encountered is that many Node servers and players need to communicate, you need to ask specific UID to the management server on how much the player in where Taiwan Gate, not before the scene cut by a server problem, asked once for all It can be cached, but now increase the number of types of servers, players will floated, Find by UID players too much trouble; on the other hand GATE dynamically calculated based on the coordinates and which Node communications, resulting in logic is getting thicker, so to: "user object" from the GATE responsible for cutting out the connection management imperative so with the following models:

QQ screenshot 20150923103309.png

Gateway server again returned to streamline the network forwarding function, and in accordance with user logic UID divided by OBJ server to assume, GATE is in accordance with the load of network access to distribution, and OBJ is in accordance with the number of resources (UID) to be distributed , and such a communication in accordance with user UID OBJ calculated directly send data to the server ID. The new independent of OBJ provides a more high-level services:

  • Object Mobile: Managing move between the different players in the specific area of ​​Node under the jurisdiction of, and communicate with Node needs.

  • Data broadcasting: Node plurality of TAG may be provided for each user, and then notifies Object Master broadcast according to TAG.

  • Objects news: General news push, sending data to a user, tell OBJ, and do not need to deal directly GATE.

  • Friends Chat: Chat directly go OBJ / OBJ MASTER between roles.

After the entire server is divided into three main, NODE focused scene, OBJ focused player objects, GATE focused network. This model is widely used in a seamless scenario server. But as time goes on, load problem has become increasingly evident, to be active, inactive far to become very active in the region, by adjusting the weekly maintenance is quite heavy, so with dynamic load balancing.

Dynamic load balancing in two ways, the first one is according to the load, the timing of the Master Node modify the dynamic movement of the boundary of each Node, and different player object migration from one Node to another Node according to a previous methods:

QQ screenshot 20150923103337.png

Figure 11 Dynamic Load Balancing

Such Node Master Timing find hot spots on a map, calculate the new cut scene mode, then tell other servers began to adjust, or specific treatment method and the above objects, like moving across the border.

But above achieved in this way is relatively complex, so people devised a more simple and direct a new approach:

QQ screenshot 20150923103401.png

Dynamic load balancing FIG. 12 mesh

Or the map evenly cut according to the standard size static grid, each grid is responsible for a specific Node, but depending on the load, real-time migration to other Node. The migration is divided into three phases: preparation, switching to complete. Three states responsible Node Master Maintenance. The new Node start preparatory phase synchronous data above the old Node of the grid, after the completion tell NM; at the same time inform the old and new Node complete the switch after NM confirm OK. When that is completed, if the server is still Obj and the old Node communicate, old Node it will be corrected, corrected the OBJ will correct his own state, and the new Node to communicate.

Many seamless dynamic load balancing server claims to support an unlimited number of people, but it does not mean that the maximum number of MMORPG games can really unlimited expansion, because such a system would be subject to network bandwidth and client performance. Bandwidth determines the maximum upper limit of broadcasting the same area, but in the end the client performance determines how many characters you can draw the same screen.

From the introduction of the seamless map distributed object model to start, completely out of MUDOS system has become a new server model. Also, because the introduction of dynamic load balancing, allowing seamless server unleashed, houses more than the number of times the upper limit of generation game server, and provides a better gaming experience, which we call the third generation of game server architecture. Online games to massively multiplayer role-playing as the beginning, RPG games once occupied more than 90% for a long time, so that has been vigorous development of server-based MMORPG architecture, but with the players tired of RPG and various non-MMORPG games such as sprung up in front of people, welcomed by the market.

Type 5: war gaming server

Classic Battle Network RPG game server and there are two differences: RPG is the partition of the sub-service, user area of ​​Beijing and Guangzhou area never in contact with the user. The war net, although within each game are generally eight people, but there are only a set of servers, all the players can play together while using P2P way of the player and the player is connected together to form a game:

QQ screenshot 20150923110305.png

The player through the Match Making server use: create, join, automatic matching, etc. invited to make up a game. Server will choose a person to do Host, connect to other people P2P players call the shots up. STUN is to help players build P2P traction between servers, P2P and because only about 75% of China Unicom case, it does not make sense with the player will be forwarded by the Forward.

A large number of connected gaming, athletic game uses a similar structure. P2P a mesh model (all players are connected to each other), and star model (all players connected to a main player). Complex game in the same state is difficult to form a mesh model, so star P2P model has withstood the test of history. Remove game data, voice-war net system will also send voice data of all the players on that machine to call the shots, to re-mix by re-encoding the way back to all users.

Battle Network games to athletics, sports, action and other types of game-based, slow-paced RPG (including ARPG) have fundamentally different, and intense game will inevitably bring to a more complex multi-RPG synchronization policy such synchronization mechanism often brings a lot of games the result calculated by the client directly, that everywhere in the break today, how to ensure a fair game result of it?

The main way is voting method, all clients will be calculated independently, and then passed to the server. If the result is the same record is updated, if the results are inconsistent, will take a similar ballot to determine the final result. All inputs while recording the drama of the game, in where possible, find another idle game client checking whether the game for the entire office results. And recording user often suspected of cheating, a reference for operational personnel titles.

Type 6: casual game server

Casual games with a similar battle network server, are the region's architecture, there is a different server rooms, as well as specific game server, the game is no longer subject to P2P players perform, but to the dedicated game server:

1442977435693805.png

And of the region as the battle network architecture, user data can not be like RPG partition as a one-time load into memory, and then directly modify the code in memory. Under the region's architecture, in response to a user while playing a few games, user data and basic data needs to distinguish different game data, game data and the need to distinguish between data integration, and document data. Shengping Fu classes of points can be submitted directly to incremental changes, while the more common type of documentation you need to provide read and write data token, only a token write, read token there are many pieces. The same account simultaneously play the same game on two computers, the game began to get the first write token, can operate any user data. Then start the game in addition to incremental change can be submitted Shengping Fu integration of user data in read-only way to ensure that the game can run forever, but will prompt the user, the game data lock.

Type 7: Modern Action games

Since the early days of the Korean action game, the traditional network battle action game and RPG game began to try to integration. Simple action game players tired easily, nor retained RPG so high; and simple but slow-paced RPG combat boredom, unable to meet the expectations of a lot of players fierce confrontation, so the two began to integrate a new generation: Action + towns mode. Players gathered in the town, and then open the copy in the manner of a few people go out to play action RPG game to complete a variety of tasks. RPG is essentially a copy of the server + server. Because each time a copy of the character can be controlled within 8 people, so you can get a more real-time gaming experience, allowing the player to play more readily.

He said so many types of game servers, in fact almost the rest of the type we put together what in fact is like this only. Game server has gone through so many changes in the structure, whether developed in-house model remains the same? What is continue to follow the traditional development mode? Or have more groundbreaking method? Architecture changes experienced so many times, whether there is a common logic behind? What are the difficulties in the future development will continue to exist? Game server developers how to reach the final of the other side? See the next section: the evolution of technology.

Published 49 original articles · won praise 32 · views 310 000 +

Guess you like

Origin blog.csdn.net/dianliang01/article/details/88792260