Design Concept of seamless online gaming server architecture

Source: Internet
Author: User

In the past year, it has taken a lot of time to consider server architecture design issues. I have read a lot of articles and have studied many open-source projects, but I have broadened my horizons. However, I have not helped much in online game architecture design. Foreigners are still playing many console games, and MMO games are not as involved as widely as in China. Let's take a look at the two books massively multiplayer games development 1 & 2. the quality is very general, and the help is naturally very limited. Of course, this is also a good thing. For domestic R & D companies/teams, there is certainly a possibility of surpassing foreigners in terms of online game server technology, and there is a greater chance of technological transcendence in this aspect, of course, the premise is to accumulate and be willing to invest, and R & D personnel must be able to withstand loneliness and temptation. On average, when they receive more than three headhunting phone calls every day, they are still inactive.

The above is a bit far away. Let's talk about some ideas about the design of the seamless world server architecture.

First, let's talk about the purpose of Architecture Design-my opinion. The purpose of the server group architecture design is to determine the extension relationship between servers and the main business logic processing methods. The main problem to be solved is how to improve the load capability while meeting the game content design needs.

The simplest architecture is the basic C/S architecture. A server directly forms a cluster, and all clients directly connect to the server, which completes all logic and data processing. This architecture is actually very good. The biggest benefit is the simplicity of its architecture. The cross-process interaction within the cluster is completely ruled out, and the complexity is reduced immediately, moreover, we can achieve a seamless game world. However, even if I don't mention it, we all know what is wrong with this single server architecture. However, we may consider this server as a black box from another perspective. From the perspective of the outside of the system, what kind of system can be regarded as a whole and a black box, regardless of the extension relations inside the system and the complexity of implementation. Without considering the implementation of this system, theoretically, the cluster processing capability is determined by the number and capability of hardware, that is to say, the more servers a server cluster contains and the faster the server is, the better the processing capability of the cluster and the better the load carrying capacity. The question of load capacity is how to use these servers efficiently. It can also be understood as how to improve the concurrent processing capability of player requests.

The CPU vendor has been considering this issue a long time ago. The CPU can also be regarded as a black box. Let's look at the technologies they have used-pipeline technology, multi-CPU/multi-core technology, and derivative technologies of these technologies. After I thought about how to let the server cluster process parallelism internally for a long time and had a clear idea, I realized that the method of CPU vendor could have been used for a long time. The pipeline method is to split the processing of a command into multiple steps, so that the processing of the command can be partially overlapped (equivalent to being concurrent. We can use this method to split our server cluster. I have a name --

Services-based architecture-service-based architecture. In this architecture, we divide the tasks of each server in the group based on the correlation of processing data and logic. For example, the location service provides the object visibility information, the product service handles the logic related to all items, the social relationship Service provides the logic of the guild family, and the combat server only processes the combat-related logic. In this way, the logic processing concurrency is possible. For example, it is totally irrelevant for a to hack B with C to buy a weapon from a profiteer, and the two requests are processed on different servers, they are concurrently processed by different service servers. This is the concurrency method of services-based architecture.

Basically, it is reasonable to split the processing of game logic into one service, and split the specific processing of machine commands when designing the CPU, and then design one pipeline unit.

Cells-based architecture-cell-based architecture. Each cell runs identical application servers on different physical servers, but they are responsible for the game logic in different game scenario regions. Obviously different from services-based arch., each cell is a 'logically complete 'server. It has to deal with almost all game logic, such as item operations, character movement, and combat computing. Although this may cause some (possibly complicated) problems, it is completely feasible. For example, if Wu guoa cut B by a knife, it is obvious that he and c cut d by a thousand miles away, and they can be processed concurrently by different cells.

Basically, this is equivalent to inserting multiple CPUs or one CPU but multiple kernels on a single motherboard. Each CPU can do the same thing and work together.

For the basic analysis of the two seamless world architectures and some major problems to be solved, write them again next time.

The last time I wrote "design ideas for the seamless online gaming server architecture", this is a sequel. The main content is the analysis of the advantages and disadvantages of the two architectures.

From the perspective of a group of servers, we generally have login server and persistent data server (dB and DB proxy) in our server group) connect the proxy server (Gate server, FEP server, client proxy, etc.), auto patch server, and servers used for centralized management and control, because these servers are basically used in any architecture design, we only consider servers that process game logic and rules. Analyze the advantages and disadvantages of services-based architecture and cells-based architecture on this premise.

Analysis of services-based architecture

 

Service-based architecture, as the name suggests, the implementation (Program) of this architecture will be related to the specific content (Planning) of the service, this is because the determination of various [Services] content is based on the [Requirement Analysis] of the project. The premise of [Requirement Analysis] Is that the [Planning and Design] is basically determined ], at least the project's outline design.

I think most people who have worked on game projects should have deep feelings about demand changes. Everyone says, "the one they want to do is different from the one they actually do ". Especially in the early stages of the project, different team members have quite different opinions on what the project looks like after the project is completed (it is very likely that everyone does not know each other ), it is easy to understand that no one can know exactly what the game has done from several pages, even if the demand changes are not considered. I will not talk much about the project development methods here. In short, my opinion is that although we are unlikely to design an architecture that can adapt to any game design, however, the coupling between different development tasks is obviously lower, the better, and the service-based architecture is less capable of adapting to demand changes.

About service coupling

No matter how services are divided, different services must have different degrees of coupling relationships, and different services may have mutual dependencies. However, your planning and design may complicate this relationship to a level that is hard to figure out when the program is running.

 

Hypothesis:

The combat processing and item processing in the server group are provided by two different services (servers ).

Game rules:

After a person is attacked, his or her belongings may fall to the ground.

Some items will pop up after they are dropped.

An explosion on the ground may hurt people around the world (within a radius of 10 meters ).

The degree of hatred between characters affects combat numerical calculation.

The items that are dropped when the attack is attacked are attacked, and the people who are injured after the explosion will increase the 'hattion' of the attacked person'

 

I think I can come up with a lot of "not too much looks" rules to make this thing very complicated. It is very likely that your planning is also accidental, I already have this ability, and most of their expressions when writing documents are not as clear as I have mentioned above. In addition, they will divide these rules into many different documents for writing. Well, you will definitely think, "combine these two services into one." In fact, no matter which two or more services you want to combine into one service, we should first consider why they serve different services independently?

In fact, many such "seemingly excessive" rules will lead to frequent interaction between services. Therefore, it is best to use stateless service for each service. In this case, the situation will be much better, however, this is hard for games.

Time series of request processing

The problem of service coupling can still be solved without considering the high development complexity. Is it even more difficult to solve the problem as long as you have a clear head and are willing to spend enough time? I think there are still some things. If you know enough about the problems you will face :)

 

 

The above two sequence diagrams describe that a player has performed the same operation twice consecutively but may have different results. Of course, these requests are processed asynchronously. The key to the problem is-although the commands executed by the two players are the same, the order is the same, and even the time interval is the same, the results are quite different-Because c2cs :: when the request_to_attack request is processed, the c2is: request_equip_item request has not been processed yet, but the situations shown in figure (2) are different. Because the c2is: request_equip_item operation may change the attribute of the game character, which may affect the attack result. The two images actually omit the interaction process between the combat server and the item server. But it is enough to explain the problem. the time consumed by each service to process each request cannot be determined during design!

Who like the uncertainty of such results? For example, a player may have been equipped with a "only one Warcraft killer" and then attacked Warcraft, but it is not dead! What results will this lead? Please imagine. In addition, such uncertainty can also be seen as "behavioral differences during the project development and operation stages", or "occasional strange phenomena ".

Is there a solution? Yes. In fact, you only need to serialize the processing of player requests so that the processing can be conducted in an orderly manner. But again, this will bring new complexity-in a certain range (the entire server group? A Guild? One team ?) Each player is serialized (which may be all), but it is also obvious that this reduces the concurrency of request processing to some extent, although its impact on concurrency may be limited to a small range (at least one player.

 

Analysis of cells-based architecture

 

The obvious advantage of cell-based architecture is that the division of cells has nothing to do with your planning. J. This is true. In addition, how the interaction between cells can be placed at the underlying layer of the system. Specifically, there are multiple underlying and hidden layers (in fact, they can be concealed to a level that is invisible to programmers who develop the upper-layer game logic) it depends on your implementation. If the program design of a system is completely unrelated to the game design, it is obvious that the system will be affected by the game design change (demand change) very little, it may even be completely unaffected. Of course this is an ideal situation.

Cross-border object interaction

In the cell-based server architecture, the main difficulty in achieving a seamless world is the problems that may occur when cross-border object interaction is realized, because these objects are in different cell processes, these cells generally run on different physical servers.

The unique feature of the seamless world is naturally seamless, And because seamless brings a better gaming experience to players, we obviously hope that the problem of "cross-border object interaction" will not mess up things, therefore, the Interaction performance must meet the stable and efficient requirements. Generally, latency higher than MS is a "obvious" level for player operations, when gamers cannot ride a 500 RMB virtual horse on a prairie, they are suddenly blocked by an invisible wall somewhere, because this "wall" is invisible, it will affect the game mood of "God.

The relationship between cells that make up the entire virtual world is analyzed as follows:

Cell-based scenarios do not overlap

 

(1) A continuous virtual world scenario is divided into two blocks, running on different cell servers. A, B, and C are three different game roles. In this case, there is no obstacle to the interaction between B and C, because B and C are only two different memory data blocks in the same process on the same physical server. However, the interaction between A and B/C is not so direct. Although the scenario they are in seems to be "continuous and integrated", things will not be as simple as on the surface. What will happen when a interacts with B? For example, a attacks B, A, and B, because data synchronization in this structure will cause many problems, for example, object State uncertainty and development complexity. The latency caused by network communication between two cell servers may be the smallest problem, these problems do not require complex analysis to draw conclusions.

2. Overlapping scenarios (partially) carried by cells

 

(2) A continuous virtual world scenario is divided into two blocks, running on the unused cell server. A, B, C, and D are four different game roles. In this case, the intermediate area is jointly maintained by two cells, and the objects in the intermediate area belong to the 'owner' of the two cells '. What are the benefits? Now, the interaction between any two objects, except for A and C, becomes more 'direction. It must be a good thing to become direct. What about the relationship between A and C? In fact, there is no problem between them. J. because both sides have exceeded the area of interest (AOI) of the other side, game rules can restrict their direct interaction.

The second solution mentioned above is not magic, but it must be more effective than the first one. What should we do next? Assume that B is a player. When he is standing in the middle of this area, the question "Where am I?" does not arise. The key to the question J is that for cell server, how to synchronize objects in overlapping areas. In the gaming world, objects may be in one, two, three, or four different cell servers at the same time. If your cell separation method is not limited to horizontal lines and vertical lines, or someone deliberately fails, there may be more. The object to be synchronized is not only the player itself, but also the monster, NPC, a walking tree, And the sputation of a certain player on the ground.

Because our seamless-world-based game rules do not limit the behavior of players in the game world directly, that is to say, if players can trade items with each other, they certainly want to trade anywhere, "why can it be done elsewhere, but trading in a corner will lead to loss of items?" Therefore, the more reliable method is to establish a set of underlying mechanisms for synchronization to synchronize these cross-border objects.

How to implement it? This topic is very big. I'm afraid I can't finish writing a few more blogs, but there are some things that can be used as a reference, such as: DCOM and CORBA specifications, Java RMI, Python-based Pyro, tao (the ace orb) and so on. Fortunately, distributed processing not only involves online games, but also has a lot to learn from.

Summary

Obviously, this article has some preference in the evaluation of the two architectures, but the preference is only a by-product. Another by-product is some technical analysis methods.

When considering the technology we adopt, we tend to easily ignore the impact on things outside the program. When I mentioned the implementation of the Services-based architecture above, I mentioned the challenges for the division of services and data design to the program design capability, the constraints on the planning and design, and the impact on the ability to adapt to changes in demand, not just empty talk. These problems do not occur only when the architecture is implemented.

Do not overestimate your IQ. Keep it simple and stupid should make us closer to success.

Original article address:

Http://canremember.com /? P = 8

Http://canremember.com /? P = 10

Http://dearymz.blog.163.com/blog/static/2056574200811119845551/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.