Game Guild Loading Method and Server
By using virtual service nodes and guild identification in the game server cluster to determine the target node, the experience problems caused by the gap in the number of guilds and server downtime are solved, load balancing and dynamic migration are achieved, and the player experience and system reliability are improved.
Patent Information
- Application Number
- CN202010840501.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-19
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-08-19
AI Technical Summary
In the existing technology, when game guilds are assigned to game servers, there is a large gap in the number of guilds on different servers, which affects the normal operation of the server. When the server is down, the guild cannot be loaded, resulting in poor player experience.
A game guild loading method is adopted. By using virtual service nodes in the server cluster, the target node is determined based on the guild identification, the guild is loaded onto a server with a more balanced load, and the guild is dynamically migrated when the server is down to ensure load balancing and Player experience.
It achieves a balanced distribution of the number of guilds on different servers, improves player experience, ensures the normal operation of the server, and realizes the dynamic migration of guilds when the server goes down, improving the reliability of the system.
Smart Images

Figure CN111905362B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of game interaction technology, and in particular to a loading method and server for a game guild. Background Art
[0002] The game guild is a social platform for game players. The game guild is not attached to a specific game. It can increase the game's stickiness to players and drive players' social needs by issuing guild rewards. That is, players can complete tasks together by joining the game guild. After the task is completed, the players in the guild will receive guild rewards.
[0003] In the related art, when allocating game servers to game guilds, the game guilds are usually allocated to the game servers where the guild creators are located. Although this method is simple, it can easily lead to a large difference in the number of guilds running on different game servers, affecting the normal operation of the game servers. If a game server goes down, the guilds allocated to the game server will not be able to load, resulting in a poor player experience. Summary of the invention
[0004] The purpose of the present invention is to provide a method and server for loading a game guild, so as to reduce the difference in the number of guilds running on different game servers and improve the player experience.
[0005] In a first aspect, an embodiment of the present invention provides a method for loading a game guild, the method being applied to a game server, the game server belonging to a server cluster consisting of multiple game servers, each game server in the server cluster providing at least one virtual service node; the method comprising: in response to a game guild loading request, obtaining a guild identifier of a guild to be loaded corresponding to the game guild loading request; based on the guild identifier of the guild to be loaded, determining a target node from the virtual service nodes provided by each game server in the server cluster; and loading the guild to be loaded onto the game server corresponding to the target node.
[0006] In an optional embodiment, the above-mentioned step of determining the target node from the virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded includes: calculating the hash value of the guild identifier of the guild to be loaded; based on the hash value, determining the target node corresponding to the guild to be loaded from a preset hash space; wherein the preset hash space includes: the virtual service nodes provided by each game server in the server cluster, and the hash value of each virtual service node.
[0007] In an optional embodiment, the above step of determining the target node corresponding to the guild to be loaded from a preset hash space based on the hash value includes: determining a hash value that matches the hash value of the guild to be loaded from the preset hash space; the matching hash value includes: in a clockwise direction, a hash value that is adjacent to the hash value of the guild to be loaded and corresponds to a virtual service node; and determining the virtual service node corresponding to the matching hash value as the target node.
[0008] In an optional implementation, the number of virtual service nodes provided by each game server in the above-mentioned server cluster is the same; the number of virtual service nodes provided by the game server is determined by: obtaining multiple alternative numbers of virtual service nodes provided by the game server, and calculating the load variance of the server cluster corresponding to each alternative number; and determining the alternative number corresponding to the load variance that meets a preset condition as the number of virtual service nodes provided by the game server.
[0009] In an optional embodiment, the step of calculating the load variance of the server cluster corresponding to each alternative quantity includes: performing the following operations for each alternative quantity among multiple alternative quantities: obtaining multiple virtual service nodes in the server cluster based on the current alternative quantity; obtaining a hash space corresponding to the current alternative quantity based on the hash value of each virtual service node among the multiple virtual service nodes; calculating the occupied space of the virtual service nodes of the current alternative quantity corresponding to each game server in the hash space corresponding to the current alternative quantity; determining the load variance of the server cluster based on the occupied space of the virtual service nodes of the current alternative quantity corresponding to each game server.
[0010] In an optional implementation, the hash value of the virtual service node is calculated in the following manner: determining the MD5 value of the virtual service node based on the node identifier of the virtual service node; determining the MD5 value as the hash value of the virtual service node; wherein the node identifier of the virtual service node includes: the IP address of the game server corresponding to the virtual service node, plus the product of the quotient of the numerical value that can be accommodated by the hash space corresponding to the current number of alternatives and the total number of virtual service nodes included in the server cluster and the preset number of the virtual service node.
[0011] In an optional embodiment, the step of calculating the occupied space of the current candidate number of virtual service nodes corresponding to each game server in the hash space corresponding to the current candidate number includes: for each virtual service node corresponding to each game server, determining the space between the current virtual service node and the previous virtual service node of the current virtual service node in the hash space corresponding to the current candidate number as the occupied space of the current virtual service node; for each game server, adding the occupied space of each virtual service node corresponding to the current game server to obtain the occupied space of the virtual service node corresponding to the current game server.
[0012] In an optional embodiment, the step of determining the load variance of the server cluster based on the occupied space of the current alternative number of virtual service nodes corresponding to each game server includes: calculating the average value of the occupied space of the current alternative number of virtual service nodes corresponding to each game server; dividing the occupied space of the current alternative number of virtual service nodes corresponding to each game server by the average value to obtain multiple load factors; calculating the variance of the multiple load factors to obtain the load variance of the server cluster.
[0013] In an optional embodiment, after the above step of loading the guild to be loaded onto the game server corresponding to the target node, the method further includes: associating and saving the guild to be loaded and the game server to which the guild to be loaded is loaded into a preset cache list; monitoring the operating status of other game servers in the server cluster except the game server; if there is a stopped game server, deleting the game guild run by the stopped game server from the preset cache list, and when a loading request for the game guild run by the stopped game server is received, continuing to execute the step of responding to the game guild loading request and obtaining the guild identifier of the guild to be loaded corresponding to the game guild loading request.
[0014] In an optional embodiment, the game server includes a timer; after the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further includes: when all players in the guild to be loaded are offline, starting the timer; if the players in the guild to be loaded are not online after the timer expires, transferring the guild to be loaded from the game server to which it is loaded to a preset database.
[0015] In an optional embodiment, in response to a game guild loading request, the step of obtaining the guild identifier of the guild to be loaded corresponding to the game guild loading request includes: receiving a game guild loading request sent by a player; the game guild loading request carries the guild identifier of the game guild to which the player belongs; determining whether the game guild to which the player belongs is in a preset cache list; if not in the preset cache list, caching the loading request, determining the game guild to which the player belongs as the guild to be loaded, and obtaining the guild identifier from the game guild loading request.
[0016] In an optional implementation, the game server includes a dispatch interface; the step of receiving a game guild loading request sent by a player includes: receiving the game guild loading request sent by the player through the dispatch interface.
[0017] In an optional embodiment, after the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further includes: for the guild to be loaded, monitoring whether the time difference between the current time and the last save time is greater than a first time threshold; if so, saving the information corresponding to the guild to be loaded; monitoring whether the guild to be loaded receives a request instruction sent by a player within a second time threshold; if received, saving the request instruction.
[0018] In an optional implementation, the game server includes a designated routing interface, and the designated routing is used for: information transmission between each game server in the server cluster.
[0019] In an optional embodiment, the method further includes: saving the game guild in a preset recommendation cache pool; wherein the recommendation cache pool includes multiple game guilds; selecting a target game guild from the recommendation cache pool according to preset rules, and sending the target game guild to players who have not joined the target game guild; recording the number of times the game guilds in the recommendation cache pool are sent, and deleting the game guilds whose number of sends is greater than a preset threshold from the recommendation cache pool.
[0020] In a second aspect, an embodiment of the present invention provides a loading device for a game guild, which is arranged on a game server, and the game server belongs to a server cluster composed of multiple game servers, and each game server in the server cluster provides at least one virtual service node; the device includes: a loading request response module, which is used to respond to a game guild loading request and obtain the guild identifier of the guild to be loaded corresponding to the game guild loading request; a target node determination module, which is used to determine the target node from the virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded; and a guild loading module, which is used to load the guild to be loaded onto the game server corresponding to the target node.
[0021] In a third aspect, an embodiment of the present invention provides a server, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable method for loading the above-mentioned game guild.
[0022] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned game guild loading method.
[0023] The embodiments of the present invention bring the following beneficial effects:
[0024] The present invention provides a method and server for loading a game guild. The technology first responds to a game guild loading request, obtains the guild identifier of the guild to be loaded corresponding to the game guild loading request; then, based on the guild identifier of the guild to be loaded, determines the target node from the virtual service nodes provided by each game server in the server cluster; and then loads the guild to be loaded onto the game server corresponding to the target node. In this method, each game server in the server cluster is provided with a virtual service node, and based on the guild identifier of the guild to be loaded, determines the target node of the guild to be loaded, and then determines the server for loading the guild to be loaded. This method can balance the number of game guilds loaded on different game servers. At the same time, when the game server is down, this method can reallocate the game server for the game guild loaded on the downed game server according to the game guild loading request, thereby realizing the dynamic migration of the game guild and improving the game experience of the players.
[0025] Other features and advantages of the present invention will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present invention.
[0026] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are specifically listed below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 A flowchart of a method for loading a game guild provided by an embodiment of the present invention;
[0029] Figure 2 A flowchart of another method for loading a game guild provided by an embodiment of the present invention;
[0030] Figure 3 A schematic diagram of a preset hash space provided by an embodiment of the present invention;
[0031] Figure 4 A relationship diagram between the number of virtual service nodes and the preset hash space distribution provided in an embodiment of the present invention;
[0032] Figure 5 A schematic diagram of an influence curve of the candidate number of virtual service nodes and the load variance of a server cluster provided in an embodiment of the present invention;
[0033] Figure 6 A flowchart of another method for loading a game guild provided by an embodiment of the present invention;
[0034] Figure 7 A schematic diagram of guild information synchronization provided by an embodiment of the present invention;
[0035] Figure 8 A schematic diagram of information transmission between game servers provided by an embodiment of the present invention;
[0036] Fig. 9 A schematic diagram of the structure of a loading device for a gaming guild provided by an embodiment of the present invention;
[0037] Fig.10 A schematic diagram of the structure of a server provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0039] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] In the related art, when allocating game servers to game guilds, the game guilds are usually allocated to the game servers where the guild creators are located. This method is relatively simple. When guild players send guild requests, they can record the server code of the game server where the guild creators are located on the game server corresponding to the guild players, and directly load the game guild and process the guild requests on the game server corresponding to the number. This method of binding the game guild to the game server is simple to implement and has high reliability and security. However, when the number of game servers is reduced, a sweep process is required. When adding game servers, it is easy to cause a large difference in the number of guilds running on different game servers, affecting the normal operation of the game servers. If a game server goes down, the guilds allocated to the game server cannot be loaded, and then the guild function is paralyzed, resulting in a poor player experience.
[0041] Based on this, an embodiment of the present invention provides a loading method and server for a game guild. The technology can be used in the scenario of game guild management, especially in the scenario of server allocation of game guilds. To facilitate understanding of this embodiment, a loading method for a game guild disclosed in an embodiment of the present invention is first introduced in detail. The method is applied to a game server, which belongs to a server cluster composed of multiple game servers, and each game server in the server cluster provides at least one virtual service node.
[0042] The above-mentioned server cluster includes multiple game servers. The loading method of the game guild of the present invention can be applied to any game server in the server cluster. Each game server stores the ID (Identity) of all the game servers in the server cluster. The ID can be the IP (Internet Protocol) address of the game server. Each game server can correspond to at least one virtual service node, and the number of virtual service nodes corresponding to each game server is the same. The number of virtual service nodes corresponding to each game server can be set according to business needs, and can also be set according to R&D needs, etc. The purpose of setting a virtual service node for each game server here is to balance the load of each game server, that is, to ensure that the number of game guilds running on each game server is similar.
[0043] Based on the above description, a flowchart of a method for loading a game guild is provided in an embodiment of the present invention. Figure 1 As shown, the method comprises the following specific steps:
[0044] Step S102, in response to the game guild loading request, obtaining the guild identifier of the to-be-loaded guild corresponding to the game guild loading request.
[0045] The game guild loading request may be an RPC (Remote Procedure Call) message sent by a guild player. RPC is usually a protocol through which a program can request services from a program on another computer in the network. In RPC, the program that issues the request is the client program, and the program that provides the service is the server. In specific implementation, the RPC message may be a request related to the guild, such as applying to join a guild, spending money to upgrade the guild level, quitting a guild, kicking out guild members, going online, or guild chat messages. These requests may be collectively referred to as game guild loading requests.
[0046] In a specific implementation, a guild player can send a game guild loading request to the game server where he is located. The game guild loading request carries the guild identifier of the game guild that the player wants to visit. When the game server receives the game guild loading request, it will determine whether the game guild that the player wants to visit has been loaded. If it has been loaded, the game guild loading request can be processed by the game server where the game guild is running. For example, if the game guild loading request is to send a chat message to other guild members, the server itself will send the chat message to the game server where the game guild is running, so as to send the chat message to other member players of the game guild through the game server. If it has not been loaded, the server itself needs to determine the game guild that the player wants to visit as the guild to be loaded, and obtain the guild identifier of the guild to be loaded from the game guild loading request.
[0047] The above-mentioned guild logo is a unique logo of each game guild, and the guild logo represents the identity of the game guild; the guild logo can be a string composed of characters, numbers or special characters, for example, 12131342aaa, etc.
[0048] Step S104: Based on the guild identifier of the guild to be loaded, determine the target node from the virtual service nodes provided by each game server in the server cluster.
[0049] In specific implementation, a virtual service node can be randomly selected as the target node from the virtual service nodes corresponding to each game server in the server cluster according to the guild identifier of the guild to be loaded; or a connection between the guild identifier of the guild to be loaded and the node identifier of the virtual service node can be established in advance, and then the target node can be determined from the virtual service nodes corresponding to each game server in the server cluster according to the guild identifier.
[0050] Step S106, loading the guild to be loaded onto the game server corresponding to the target node.
[0051] Since the purpose of setting up a virtual service node is to balance the load of each game server, the game server corresponding to the target node is determined according to the target node, and the guild to be loaded is loaded onto the game server corresponding to the target node, that is, the guild to be loaded is loaded into the memory of the game server corresponding to the target node, so that the game server runs the guild to be loaded.
[0052] In the specific implementation, if the number of game servers in the server cluster does not change and the game servers are not down, each game guild will be assigned (equivalent to loading) to the same game server each time. When a new game server is added, reduced, or a game server is down in the server cluster, it is necessary to reassign the game server to the game guild according to the guild ID of the game guild, so as to ensure that the load of each game service is relatively balanced.
[0053] Specifically, a game guild that has not been loaded onto a game server for operation can be saved in a preset database, thereby reducing the memory usage of the game server; the process of loading a game guild onto a game server for operation is, that is, the process of loading the game guild from the preset database into the memory of the game server for operation; during the operation of the game guild, if it is detected that all member players of the game guild are offline and no member players are online within a specified time, the game guild needs to be serialized from the memory to the preset data, thereby also reducing the memory usage of the game server.
[0054] The present invention provides a method for loading a game guild. First, in response to a game guild loading request, the guild identifier of the guild to be loaded corresponding to the game guild loading request is obtained; then, based on the guild identifier of the guild to be loaded, a target node is determined from the virtual service nodes provided by each game server in the server cluster; and then the guild to be loaded is loaded onto the game server corresponding to the target node. In this method, each game server in the server cluster is provided with a virtual service node, and based on the guild identifier of the guild to be loaded, the target node of the guild to be loaded is determined, and then the server for loading the guild to be loaded is determined. This method can balance the number of game guilds loaded on different game servers. At the same time, when the game server is down, this method can reallocate the game server for the game guild loaded on the downed game server according to the game guild loading request, thereby realizing the dynamic migration of the game guild and improving the game experience of the players.
[0055] The embodiment of the present invention also provides another method for loading a game guild, which is implemented on the basis of the method described in the above embodiment; the method focuses on describing the specific process of determining the target node from the virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded (implemented by the following steps S204-S206), such as Figure 2 As shown, the method comprises the following steps:
[0056] Step S202, in response to the game guild loading request, obtaining the guild identifier of the to-be-loaded guild corresponding to the game guild loading request.
[0057] Step S204, calculating the hash value of the guild identifier of the guild to be loaded.
[0058] A hash value is usually a mapping of a long string into a shorter string through a certain hash algorithm. The shorter string is the hash value of the longer string. The hash value is unique, that is, different strings can correspond to different hash values. The hash algorithm can use algorithms such as MD5 (Message-Digest Algorithm) or SHA-1 (Secure Hash Algorithm 1). The MD5 algorithm is usually a widely used cryptographic hash function that can generate a 128-bit (16-byte) hash value (also called a hash value) to ensure that information transmission is complete and consistent, that is, the MD5 algorithm can obtain a 128-bit hash value based on a string of any length; the SHA-1 algorithm can generate a 160-bit (20-byte) hash value based on a string of any length, and the hash value is usually presented in the form of 40 hexadecimal numbers.
[0059] The guild identifier of the guild to be loaded may be a character string consisting of numbers. The character string is processed by the hash algorithm to obtain a hash value corresponding to the guild identifier of the guild to be loaded.
[0060] Step S206, based on the above hash value, determine the target node corresponding to the guild to be loaded from the preset hash space; wherein the preset hash space includes: the virtual service node provided by each game server in the server cluster, and the hash value of each virtual service node.
[0061] The above preset hash space is pre-set with the numerical value that it can accommodate, and the numerical value can be set according to the research and development requirements. For example, the numerical value can be 2 32 , that is, the hash value that can be contained in the preset space is 0 to 2 32 In the specific implementation, according to the hash value corresponding to the virtual service node provided by each game server in the server cluster, all virtual service nodes are mapped to the preset hash space, that is, for each virtual service node, in the preset hash space, the hash value identical to the hash value of the current virtual service node is queried, and the current virtual service node is mapped to the position corresponding to the queried identical hash value.
[0062] In the specific implementation, in the preset hash space, first search for the hash value that is the same as the hash value corresponding to the guild identifier of the guild to be loaded; then when determining the target node, if there is a virtual service node corresponding to the same hash value, the virtual service node can be determined as the target node; or any virtual service node adjacent to the same hash value can be determined as the target node. Specifically, the above step S206 can be implemented through the following steps 10-11:
[0063] Step 10: Determine a hash value that matches the hash value of the guild to be loaded from a preset hash space; the matching hash value includes: a hash value that is adjacent to the hash value of the guild to be loaded in a clockwise direction and corresponds to a virtual service node.
[0064] In a specific implementation, the above-mentioned preset hash space can be mapped to a space of 0 to 360 degrees according to the order of hash values from small to large. In the space of 0 to 360 degrees, a hash value identical to the hash value of the guild to be loaded is queried, and the hash value corresponding to the virtual service node adjacent to the identical hash value in the clockwise direction is determined as a matching hash value.
[0065] Step 11: determine the virtual service node corresponding to the above-mentioned matching hash value as the target node.
[0066] like Figure 3 The diagram shows a preset hash space. Figure 3 Each circle in the diagram represents a virtual service node, where the circle corresponding to the key pointed by the arrow is the position corresponding to the hash value of the guild to be loaded. In the clockwise direction, the virtual service node corresponding to the next circle after the circle corresponding to the key pointed by the arrow is taken as the target node.
[0067] When adding or reducing game servers in the server cluster, it is necessary to reallocate game servers to the game guilds according to their guild IDs, thereby ensuring that the loads of various game services are relatively balanced. Figure 3 It can be seen that when a game server is deleted, the dynamic allocation of game guilds is not affected. It can also be understood that the game guilds previously allocated to the deleted game service are allocated to other game servers, that is, when a game server is deleted, the game guilds on the deleted game service are taken offline (saved in the preset database). If a game guild loading request is received from the game guild, other game servers can be allocated to the game guild in real time. Therefore, it will not have much impact on the entire service cluster. The only impact is that when the game guild is loaded from the preset database, there will be a certain database load. However, since the loading strategy adopted is game guild loading request driven loading, the pressure will be dispersed.
[0068] from Figure 3 It can be seen from the figure that when adding a game server, the game guild needs to be migrated, because the game guild that needs to be assigned to the newly added game server may be assigned to its next game server. Therefore, we only need to detect all the game guilds on the next game server of the newly added game server and kick off all the game guilds that should not be on it. In other words, to ensure load balancing, the game server that carries more of it is kicked off. In this solution, for the sake of balance, the consistent hashing algorithm introduces virtual service nodes, so it is necessary to process the next virtual service node of all virtual service nodes.
[0069] The number of virtual service nodes provided by each game server in the server cluster is the same; intuitively, the more virtual service nodes there are, the more conducive it is to the load balancing of the game server. However, the increase in the number of virtual service nodes also means an increase in the consumption when querying, inserting, and deleting virtual service nodes. Therefore, it is necessary to quantify the impact of the increase in the number of virtual service nodes on load balancing. First, we can Figure 4 Intuitively feel the impact of virtual service nodes on load balancing, Figure 4 The virtual nodes in are equivalent to the above virtual service nodes. Figure 4 Each circle in the figure represents a game server in the server cluster, and each point on the circle is a virtual service node. Figure 4 The figure shows the distribution of virtual service nodes in the preset hash space when the number of virtual service nodes is 1, 10, 64 and 100 respectively. Figure 4 It can be seen that the more virtual service nodes there are, the more evenly they are distributed in the preset hash space, and the more evenly distributed they are, the more balanced the load will be.
[0070] As the number of virtual service nodes increases, a single game server will be more evenly distributed in the preset hash space. In order to select an appropriate number of virtual service nodes, the number of virtual service nodes provided by the game server can be determined through the following steps 20-21:
[0071] Step 20, obtaining multiple candidate numbers of virtual service nodes provided by the game server, and calculating the load variance of the server cluster corresponding to each candidate number.
[0072] The above-mentioned multiple candidate quantities may be each value in the numerical range set for selecting the number of virtual service nodes, for example, the candidate quantity may be each value between 0 and 120. For each of the multiple candidate quantities, the load variance of the server cluster is calculated when the number of virtual service nodes provided by the game server is the current candidate quantity. The load variance of the server cluster may be related to the occupied space of the hash space corresponding to the current candidate quantity of the virtual service node corresponding to each game server.
[0073] Step 21, determining the number of virtual service nodes provided for the game server based on the candidate number corresponding to the load variance that meets the preset conditions.
[0074] The above-mentioned preset conditions may be conditions set according to research and development requirements, for example, the number of alternatives corresponding to the minimum value of the load variance, or the number of alternatives corresponding to the preset value of the load variance, etc.
[0075] In specific implementation, when calculating the load variance of the server cluster corresponding to each candidate quantity, for each candidate quantity among the multiple candidate quantities, the following operations are performed: The above step 20 can be implemented by the following steps 30-33:
[0076] Step S30, obtaining multiple virtual service nodes in the server cluster according to the current candidate number; the above current candidate number is any candidate number among the multiple candidate numbers.
[0077] Step S31, obtaining a hash space corresponding to the current candidate quantity according to the hash value of each virtual service node in the plurality of virtual service nodes.
[0078] In a specific implementation, each of the multiple virtual service nodes corresponds to a preset number, which can be a number set for each virtual service node according to a preset numbering rule. According to the preset number of the virtual service node, the numerical value that can be accommodated in the preset hash space, and the total number of virtual service nodes contained in the server cluster, the node identification of the virtual service node can be obtained, that is, the node identification of the virtual service node includes: the IP address of the game server corresponding to the virtual service node, plus the product of the quotient of the numerical value that can be accommodated in the hash space corresponding to the current number of candidates and the total number of virtual service nodes contained in the server cluster and the preset number of the virtual service node, which can be expressed as follows:
[0079] IP address + the amount of value that can be accommodated / total number of virtual service nodes * preset number.
[0080] Based on the above description, the hash value of each virtual service node can be calculated in the following way: determine the MD5 value of the virtual service node according to the node identifier of the virtual service node; determine the MD5 value as the hash value of the virtual service node. That is, the 128-bit hash value (also called MD5 value) corresponding to the node identifier is obtained through the MD5 algorithm.
[0081] In a specific implementation, the current candidate number of virtual service nodes corresponding to the game server can be mapped in a preset hash space according to the hash value of each virtual service node to obtain a hash space corresponding to the current candidate number.
[0082] Step 32, calculate the virtual service nodes corresponding to the current candidate number of each game server, and the occupied space of the hash space corresponding to the current candidate number.
[0083] For each virtual service node, in the hash space corresponding to the current candidate number, the space between virtual service nodes adjacent to the current virtual service node in the clockwise direction, or the space between virtual service nodes adjacent to the current virtual service node in the counterclockwise direction, can be determined as the occupied space of the current virtual service node. Specifically, the above method of determining the occupied space can be adapted to the method of determining the target node. If the target node is determined in the clockwise direction, the occupied space needs to be determined in the counterclockwise direction; if the target node is determined in the counterclockwise direction, the occupied space needs to be determined in the clockwise direction. According to the sum of the occupied spaces corresponding to the virtual service nodes of the current candidate number corresponding to the game server, the occupied space of each game server in the hash space corresponding to the current candidate number can be obtained.
[0084] In a specific implementation, the above step 32 can be implemented in the following manner: for each virtual service node corresponding to each game server, the space between the current virtual service node and the previous virtual service node of the current virtual service node in the hash space corresponding to the current number of candidates is determined as the occupied space of the current virtual service node; for each game server, the occupied space of each virtual service node corresponding to the current game server is added together to obtain the occupied space of the virtual service node corresponding to the current game server.
[0085] In the specific implementation, first, for each virtual service node in the current candidate number of virtual service nodes provided by each game server in the server cluster, the occupied space of the current virtual service node is calculated, that is, the space between the current virtual service node and the previous virtual service node of the current virtual service node in the hash space corresponding to the current candidate number is calculated. After obtaining the occupied space of each virtual service node, the occupied space of the current candidate number of virtual service nodes corresponding to each game server is extracted, and for each game server, the occupied space of the virtual service nodes corresponding to the current game server is added to obtain the occupied space of the virtual service nodes corresponding to the current game server, and then the occupied space of the current candidate number of virtual service nodes corresponding to each game server is obtained.
[0086] Step 33: Determine the load variance of the server cluster according to the occupied space of the current candidate number of virtual service nodes corresponding to each game server.
[0087] In specific implementation, the above step 33 can be implemented through the following steps 40-42:
[0088] Step 40, calculate the average value of the occupied space of the current candidate number of virtual service nodes corresponding to each game server, that is, add the occupied space of the current candidate number of virtual service nodes corresponding to each game server, and then divide the sum by the number of game servers to obtain the average value.
[0089] Step 41, divide the occupied space of the current candidate number of virtual service nodes corresponding to each game server by the average value to obtain multiple load factors; that is, obtain the load factor corresponding to the occupied space of the current candidate number of virtual service nodes corresponding to each game server.
[0090] Step 42, calculating variances of multiple load factors to obtain the load variance of the server cluster.
[0091] The variance of all load factors is calculated by first adding up all load factors and then averaging them to get the load mean. Then, each load factor is subtracted from the load mean to get the load difference. After squaring each load difference and summing them up, the load variance of the server cluster can be obtained.
[0092] Through the above steps 30 to 42, the load variance of the server cluster corresponding to each candidate number of the virtual service nodes provided by the game server can be obtained. According to the relationship between the load variance of the server cluster corresponding to each candidate number and the candidate number, the influence curve of the candidate number of virtual service nodes and the load variance of the server cluster can be obtained, such as Figure 5 As shown, Figure 5This is the impact curve drawn when the number of game servers in the server cluster is 15. Figure 5 It can be seen that when the number of game servers is 15, the load variance of the server cluster gradually decreases with the increase of the number of virtual service nodes, but the change is not very significant after the number of virtual service nodes is greater than 50. At this time, we can select 50 as the number of virtual service nodes provided by the game server; in some embodiments, a binary search method is usually used to determine the target node, so the number of virtual service node services is selected as 1024 / 15, which is about 68.
[0093] Step S208, loading the guild to be loaded onto the game server corresponding to the target node.
[0094] The above-mentioned game guild loading method first responds to the game guild loading request, obtains the guild identifier of the guild to be loaded corresponding to the game guild loading request; then calculates the hash value of the guild identifier of the guild to be loaded; then based on the hash value, determines the target node corresponding to the guild to be loaded from the preset hash space; then loads the guild to be loaded onto the game server corresponding to the target node. This method can realize the allocation of different game guilds on different game servers, thereby realizing the decentralization of game guild sub-servers, balancing the load of different game servers managing game guilds, and this method can realize the dynamic migration of game servers when the game server crashes, thereby improving the player experience.
[0095] The embodiment of the present invention also provides another method for loading a game guild, which is implemented on the basis of the method described in the above embodiment; the method focuses on describing the specific process of obtaining the guild identifier of the guild to be loaded corresponding to the game guild loading request (implemented by the following steps S602-S612); Figure 6 As shown, the method comprises the following steps:
[0096] Step S602, receiving a game guild loading request sent by a player; the game guild loading request carries a guild identifier of the game guild to which the player belongs.
[0097] The game guild loading request may be a request related to the game guild, such as applying to join a guild, spending money to upgrade the guild level, quitting a guild, kicking out guild members, or guild chat information. The game guild request carries the guild identifier of the game guild to which the player sending the game guild request belongs.
[0098] In the specific implementation, due to the large number of interfaces of the game server, it will be impossible to process the game guild loading request through a unified calling function. Therefore, a dispatch interface is set for each game server in the server cluster; each game server can receive the game guild loading request sent by the player through the dispatch interface. The dispatch interface can also be called a dispatch interface. The dispatch interface numbers each function and each attribute. When the function is called, the number will be passed to the dispatch interface so that the dispatch interface calls the corresponding function.
[0099] Each game server is equipped with a guild process that processes game guild information. In the guild process, the operation of the guild process can be identified by the operation type, and distributed to the corresponding game guild in the guild process through UnionManger. All game guild loading requests of the relevant guild are received through the dispatch interface of the guild process (equivalent to the dispatch interface of the game server), so it is easy to hook all game guild loading requests. Among them, Hook usually means that all game guild loading requests will go through the same function call, and all requests can be processed uniformly in this function. For example, when a game guild loading request is received, if the game guild corresponding to the request has not been loaded yet, the game guild loading request will be cached first, and then the game guild will be loaded. After the loading is completed, the request will be processed by the game guild.
[0100] Since different game guild loading requests correspond to different operation types, it is very cumbersome to distinguish the operation types in the process of subsequent development requirements increasing and changing. Therefore, this application can default all game guild loading requests to types that may change game guild information, thereby facilitating machine processing.
[0101] Step S604, determining whether the game guild to which the player belongs is in the preset cache list; if it is in the preset cache list, executing step S606; otherwise, executing step S608.
[0102] The above-mentioned preset cache list can save the guild IDs of game guilds that are not running on this game server (this game server is the game server corresponding to the game server where the player is located) and that the player has visited on this game server, as well as information about the game server on which the game guild is running, which information can be the IP address of the game server, server ID, etc.; it can also save the guild IDs of game accounts running on this game server.
[0103] Step S606: Send the game guild loading request to the game server of the game guild to which the player belongs and stored in the preset cache list, so that the game server processes the game guild loading request.
[0104] When the game server of the game guild to which the player belongs stored in the preset cache list receives the game guild loading request, the game server will check whether the game guild corresponding to the game loading request is the game guild running on this game server. If yes, cache the game guild loading request, load the game guild, and process the cached game guild loading request after loading the game guild; if not, determine the game guild as the guild to be loaded, obtain the guild identifier from the game guild loading request, and then determine the target node from the virtual service nodes provided by each game server in the server cluster based on the guild identifier, and determine the game server corresponding to the target node as the game server loading the guild to be loaded. After the determination is made, the guild to be loaded and the loading game server corresponding to the guild to be loaded are associated and saved in the preset cache list corresponding to the game server that sent the game guild loading request.
[0105] Step S608, cache the game guild loading request, determine the game guild to which the player belongs as the guild to be loaded, and obtain the guild identifier from the game guild loading request; execute step S610.
[0106] If the game guild to which the player belongs is not in the preset cache list, the game guild loading request is cached, and the guild identifier of the guild to be loaded is obtained from the game guild loading request to prepare for subsequent allocation of game servers.
[0107] Step S610: Based on the guild identifier of the guild to be loaded, determine the target node from the virtual service nodes provided by each game server in the server cluster.
[0108] Step S612, loading the guild to be loaded onto the game server corresponding to the target node.
[0109] Step S614, the guild to be loaded and the game server to which the guild to be loaded is loaded are associated and saved in the preset cache list.
[0110] Step S616, monitoring the running status of other game servers in the server cluster except the game server.
[0111] In the specific implementation, each game server has a guild process, and each guild process has a consistent hash cluster object. Each consistent hash cluster object maintains the ID of the guild process on other game servers (the ID can be the IP address of the game server or the identifier of the guild process, etc.), that is, the consistent hash cluster object stores the ID of the guild process on other game services; the consistent hash cluster object can monitor the running status of other game servers based on the ID of the guild process on other game servers. Since the running status of a game server is related to the running status of the guild process set by it, monitoring the running status of other game servers is equivalent to monitoring the running status of the guild process. Specifically, other game servers will send heartbeat RPC (Remote Procedure Call) to this game server at fixed intervals (for example, 10s). This game server can determine the operating status of other game servers based on the received heartbeat RPC. It can also be understood that within a fixed period of time, if a heartbeat RPC of a certain game server is received, it means that the game server is running normally; if a heartbeat RPC of a certain game server is not received, it means that the game server has stopped running, which can also be called the game server is down or faulty.
[0112] In a specific implementation, the above-mentioned consistent hash cluster object can execute the above-mentioned steps S514-S516, that is, it can select a guild process for the game guild to be loaded through the hash value corresponding to the guild identifier of the guild to be loaded. The process of selecting the guild process can be understood as the process of selecting a game server to load the guild to be loaded.
[0113] Step S618: If there is a stopped game server, the game guild run by the stopped game server is deleted from the preset cache list, so that when a guild loading request of the game guild is received, a game server is allocated to the game guild.
[0114] When a loading request of a game guild running on a stopped game server is received, step S602 may be continued to allocate a game server to the game guild. This method can ensure that when a game server stops running, the game guild running on the game server can realize dynamic migration of the guild, avoid affecting the normal use of players, and improve the game experience of players.
[0115] In the specific implementation, when the game guild has not been loaded onto the game server, it will be saved in the preset database. If a game guild loading request is received, it is first determined whether the game guild has been loaded into the memory of the game server. If so, the game guild loading request is directly processed by the game server that loads the game guild. If the game guild is being loaded, the game guild loading request is cached; if the game guild has not been loaded, the game guild loading request is cached, and a loaded game server can be assigned to the game guild through a consistent hash cluster object. After the game guild is loaded, the cached game guild loading requests are processed uniformly.
[0116] Each game server in the server cluster contains a timer; when the guild to be loaded is loaded onto the game server, the game server needs to monitor the online and offline status of the players in the guild to be loaded, and when all the players in the guild to be loaded are offline, the timer is started; if after the timer expires, none of the players in the guild to be loaded are online, the guild to be loaded will be transferred from the game server to which it was loaded to the preset database. The purpose of setting the timer is to delay the time when the game guild goes offline, which is also a caching strategy, in order to avoid the game guild from frequently transferring between the game server's memory and the preset database. The timing duration of the above timer can be set according to R&D needs, for example, 1 minute or 20 minutes.
[0117] After the guild to be loaded is loaded onto the game server, the information corresponding to the guild to be loaded needs to be saved. When saving, the time difference between the current time and the last saved time can be monitored for the guild to be loaded to see if it is greater than the first time threshold; if so, the information corresponding to the guild to be loaded is saved; the guild to be loaded is monitored to see if it receives a request instruction sent by the player within the second time threshold; if received, the request instruction is saved. The request instruction can be the game guild loading request mentioned above, that is, a request related to the game guild.
[0118] The first time threshold and the second time threshold can be set as required, for example, the first time threshold can be set to 60 minutes, the second time threshold can be set to 15 minutes, etc. In specific implementation, the game server can set a 15-minute repeating timer, and start the 15-minute repeating timer after the game guild is loaded. If more than 60 minutes have passed since the last save (that is, a timestamp will be recorded when the last save was made, and the 15-minute repeating timer will check the time from the current time to the last save each time it is executed, and if the time exceeds 60 minutes), the information corresponding to the guild to be loaded needs to be saved. If any request instruction is received within 15 minutes, the request instruction needs to be saved immediately. The request instruction can be considered as a request that can modify and change the game guild information. This save strategy can effectively reduce the information save pressure of the game guild.
[0119] In some embodiments, the default is to save the game when the game guild is destroyed. The destruction of the game guild usually means that the game guild goes offline (that is, saved in a preset database), the players in the game guild go offline, etc.
[0120] In the management of game guilds, there is also the problem of information synchronization of game guilds, that is, the UnionEntity on the guild process is modified through the request instruction of the game guild, but the member players in the game guild are not notified to modify the UnionEntity on the corresponding guild process, which will cause information inconsistency problems. The same is true for the client and the server, so the problem of guild information synchronization needs to be solved. The above-mentioned UnionEntity can refer to the entity that manages the information of the game guild, so it has a copy on the UnionProxy on the client Avatar, the server Avatar and the UnionStub (that is, the entity that manages the guild process). These three places use the same UnionEntity to represent the information of the game guild. The information synchronization of the game guild can actually refer to the information synchronization between these three UnionEntities. Its specific structure is as follows Figure 7 shown.
[0121] For the synchronization of game guild information, only a simple broadcast operation is needed to complete this task. However, the broadcast operation requires defining a large number of operation processing interfaces on the players of the game guild. Each operation of adding a new game guild requires adding corresponding codes on the client, server and UnionStub, which is very complicated. Therefore, the change information of the game guild can be broadcast. The above-mentioned game guild operation actually causes the change of the game guild information. If an interface for obtaining game guild information is provided, and then the changed fields in the game guild information are broadcast, the entire guild information synchronization becomes very simple. Only a few interfaces with different granularities are needed to synchronize all game guild operations (equivalent to guild information). In this way, when adding a new game guild operation, there is no need to provide corresponding synchronization interfaces on the client and server. The above-mentioned interfaces with different granularities can refer to the interfaces for processing broadcast information in the client, server and guild process interfaces, specifically the interfaces for broadcasting field changes of game guild information, for example, the interfaces for broadcasting the addition and deletion changes of member players in the game guild, and the interfaces for broadcasting the addition and deletion changes of application.
[0122] Since there are a large number of players in a game guild (usually more than 50 people), the behavior of the game guild members needs to be synchronized to each member of the game guild. Member login, offline, game status, chat, activity changes, etc. will generate a large number of information synchronization RPCs, which will inevitably cause a large communication overhead. Therefore, a unique designated routing interface for the entire server is created on the guild process, that is, a designated routing interface is created on each game server in the game server cluster. The designated route is used for information transmission between each game server in the server cluster.
[0123] The above-mentioned designated route can be StubRouter, which is a logical entity located in the guild process and is used to merge and forward information between different game servers. The information can be a message on the game process. The game process is usually the service process where the player object is located, and it processes the object of the player's in-game logic. All requests from players about the game guild are sent from the game process, and requests sent by the client to the server are also processed in the game process. All requests about the game guild include pulling guild information, joining the guild, leaving the guild, guild chat, etc.
[0124] like Figure 8 The figure shows a schematic diagram of information transmission between game servers. Figure 8Game server 1, game server 2 and game server 3 in the game server 1, game server 2 and game server 3 respectively, and Game represents the game process. The chat information sent by the player on one game server to the player on another server is uniformly sent through the interface of StubRouter (equivalent to the above-mentioned designated routing interface), that is, the StubRouter significantly reduces the number of communications between game servers by merging player calls from different game servers through buffering. When receiving the RPC calls of the game server forwarded by the StubRouter of other game servers, the RPC calls merged into each game process are buffered, which can significantly reduce the communication pressure when the communication is frequent. The two-layer RPC buffering and merging can reduce the pressure caused by communication.
[0125] Game guild recommendation is an important part of the guild system. It is necessary to recommend established game guilds to players so that they can choose to join. For recommending game guilds, it is hoped that each game guild has a chance to be recommended to players. However, if all players randomly retrieve game guild data from the database, it will obviously cause database access pressure. Therefore, a recommendation cache pool is required. The recommendation cache pool can be managed using the LRU (Least Recently Used) strategy. Specifically, the game guild recommendation can be performed through the following steps 50-52:
[0126] Step 50, save the game guild in a preset recommendation buffer pool, wherein the buffer pool contains multiple game guilds. The recommendation buffer pool stores multiple game guilds in a bidirectional linked list, and each game guild carries a timestamp, a number of recommended times, and guild information.
[0127] Step 51, according to a preset rule, select a target game guild from the recommendation cache pool, and send the target game guild to players who have not joined the target game guild.
[0128] Step 52, recording the number of times the game guild sends (equivalent to the number of times recommended) and deleting the game guild whose number of times of sending is greater than a preset threshold from the recommendation cache pool.
[0129] In the specific implementation, the data of the game guilds saved in the above-mentioned recommendation cache pool has an expiration time. The expiration and removal of data is checked by randomly selecting a certain number (for example, 25) through the TICK method. The probability of data not being selected gradually decreases with the increase of the TICK number. The probability of being checked after 10 minutes of TICK is less than 1%. The recommended game guilds for players are directly pulled from the recommendation cache pool. In order to ensure that the game guilds in the recommendation cache pool are not frequently recommended to all players in a short period of time, the number of times a game guild is recommended to players can be limited (the number of times the target game guild is sent to players who have not joined the target game guild). This number can be customized according to the number of game guilds, or it can be set to a preset threshold according to demand. Through this recommendation method, the game guild will be recommended to all players more evenly. The recommendation of the game guild improves the randomness of the recommendation and reduces the access pressure of the recommendation on the database by introducing the maximum number of recommendations in the recommendation cache pool.
[0130] The above-mentioned game guild loading method dynamically divides the game guild into servers based on the consistent hash cluster, realizes the decentralization of the game guild server division, balances the load of different game servers, and can realize the dynamic migration of the game guild when the game server stops running. For the synchronization of game guild information between players, the RPC process buffer merge of the synchronization information is adopted by the designated routing interface, thereby significantly reducing the load of the game guild information synchronization.
[0131] Corresponding to the above method embodiment, the embodiment of the present invention further provides a loading device for a game guild, the device is arranged on a game server, the game server belongs to a server cluster composed of a plurality of game servers, each game server in the server cluster provides at least one virtual service node; Fig. 9 As shown, the device comprises:
[0132] The loading request response module 90 is used to respond to the game guild loading request and obtain the guild identifier of the to-be-loaded guild corresponding to the game guild loading request.
[0133] The target node determination module 91 is used to determine the target node from the virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded.
[0134] The guild loading module 92 is used to load the guild to be loaded onto the game server corresponding to the target node.
[0135] The loading device of the game guild first responds to the game guild loading request, obtains the guild identification of the guild to be loaded corresponding to the game guild loading request; then determines the target node from the virtual service nodes provided by each game server in the server cluster based on the guild identification of the guild to be loaded; and then loads the guild to be loaded onto the game server corresponding to the target node. In this method, each game server in the server cluster is provided with a virtual service node, and the target node of the guild to be loaded is determined based on the guild identification of the guild to be loaded, and then the server for loading the guild to be loaded is determined. This method can balance the number of game guilds loaded on different game servers. At the same time, when the game server is down, this method can reallocate the game server for the game guild loaded on the downed game server according to the game guild loading request, thereby realizing the dynamic migration of game guilds and improving the game experience of players.
[0136] Furthermore, the target node determination module 91 includes: a hash value calculation unit, used to calculate the hash value of the guild identifier of the guild to be loaded; a node determination unit, used to determine the target node corresponding to the guild to be loaded from a preset hash space based on the hash value; wherein the preset hash space includes: the virtual service nodes provided by each game server in the server cluster, and the hash value of each virtual service node.
[0137] Specifically, the node determination unit is used to: determine a hash value that matches the hash value of the guild to be loaded from a preset hash space; the matching hash value includes: a hash value that is adjacent to the hash value of the guild to be loaded in a clockwise direction and corresponds to a virtual service node; and determine the virtual service node corresponding to the matching hash value as the target node.
[0138] In a specific implementation, the number of virtual service nodes provided by each game server in the above-mentioned server cluster is the same; the above-mentioned device includes a virtual service node quantity determination module, including: a load variance calculation unit, used to obtain multiple alternative quantities of virtual service nodes provided by the game server, and calculate the load variance of the server cluster corresponding to each alternative quantity; a quantity determination unit, used to determine the alternative quantity corresponding to the load variance that meets the preset conditions as the number of virtual service nodes provided by the game server.
[0139] Specifically, the load variance calculation unit is used to: obtain multiple virtual service nodes in the server cluster based on the current number of alternatives; obtain a hash space corresponding to the current number of alternatives based on the hash value of each virtual service node in the multiple virtual service nodes; calculate the occupied space of the current number of alternatives of virtual service nodes corresponding to each game server in the hash space corresponding to the current number of alternatives; determine the load variance of the server cluster based on the occupied space of the current number of alternatives of virtual service nodes corresponding to each game server.
[0140] Furthermore, the above-mentioned device also includes a virtual service node hash value determination module, which is used to: determine the MD5 value of the virtual service node according to the node identifier of the virtual service node; determine the MD5 value as the hash value of the virtual service node; wherein the node identifier of the virtual service node includes: the IP address of the game server corresponding to the virtual service node, plus the product of the quotient of the numerical amount that can be accommodated by the hash space corresponding to the current number of alternatives and the total number of virtual service nodes included in the server cluster and the preset number of the virtual service node.
[0141] Furthermore, the load variance calculation unit is also used to: for each virtual service node corresponding to each game server, determine the space between the current virtual service node and the previous virtual service node of the current virtual service node in the hash space corresponding to the current number of candidates as the occupied space of the current virtual service node; for each game server, add the occupied space of each virtual service node corresponding to the current game server to obtain the occupied space of the virtual service node corresponding to the current game server.
[0142] Furthermore, the load variance calculation unit is also used to: calculate the average value of the occupied space of the current candidate number of virtual service nodes corresponding to each game server; divide the occupied space of the current candidate number of virtual service nodes corresponding to each game server by the average value to obtain multiple load factors; calculate the variance of multiple load factors to obtain the load variance of the server cluster.
[0143] Furthermore, the above-mentioned device also includes a status monitoring module, which is used to: associate and save the guild to be loaded and the game server to which the guild to be loaded is loaded into a preset cache list; monitor the operating status of other game servers in the server cluster except the game server; if there is a stopped game server, delete the game guild run by the stopped game server from the preset cache list, and when a loading request for the game guild run by the stopped game server is received, continue to run the above-mentioned loading request response module 90.
[0144] Specifically, the game server includes a timer; the device also includes a guild transfer module, which is used to: start the timer when all players in the guild to be loaded are offline; if the players in the guild to be loaded are not online after the timer expires, the guild to be loaded is transferred from the game server to which it is loaded to a preset database.
[0145] Furthermore, the above-mentioned loading request response module 90 is used to: receive a game guild loading request sent by a player; the game guild loading request carries the guild identifier of the game guild to which the player belongs; determine whether the game guild to which the player belongs is in a preset cache list; if it is not in the preset cache list, cache the loading request, determine the game guild to which the player belongs as the guild to be loaded, and obtain the guild identifier from the game guild loading request.
[0146] Specifically, the game server includes a dispatch interface; the loading request response module 90 is used to receive a game guild loading request sent by a player through the dispatch interface.
[0147] Furthermore, the above-mentioned device also includes a saving module, which is used to: for the guild to be loaded, monitor whether the time difference between the current time and the last saving time is greater than a first time threshold; if so, save the information corresponding to the guild to be loaded; monitor whether the guild to be loaded receives a request instruction sent by the player within a second time threshold; if received, save the request instruction.
[0148] Furthermore, the game server includes a designated routing interface, and the designated routing is used for information transmission between each game server in the server cluster.
[0149] Furthermore, the above-mentioned device also includes a guild recommendation module, which is used to: save the game guild in a preset recommendation cache pool; wherein the recommendation cache pool contains multiple game guilds; according to preset rules, select the target game guild from the recommendation cache pool, and send the target game guild to players who have not joined the target game guild; record the number of times the game guild in the recommendation cache pool is sent, and delete the game guild whose number of sends is greater than a preset threshold from the recommendation cache pool.
[0150] The loading device for the game guild provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0151] The embodiment of the present invention also provides a server, such as Fig.10 As shown, the server includes a processor and a memory, the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned game guild loading method.
[0152] Further, Fig.10 The server shown also includes a bus 102 and a communication interface 103 , and the processor 101 , the communication interface 103 and the memory 100 are connected via the bus 102 .
[0153] The memory 100 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0154] The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 101. The above processor 101 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100 and completes the steps of the method of the above embodiment in combination with its hardware.
[0155] An embodiment of the present invention also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned game guild loading method. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0156] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and / or electronic device can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0157] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for loading a game guild, characterized in that: The method is applied to a game server, the game server belongs to a server cluster consisting of multiple game servers, and each game server in the server cluster provides at least one virtual service node; The number of virtual service nodes provided by each game server is determined by obtaining multiple candidate numbers of the virtual service nodes provided by the game server and calculating the load variance of the server cluster corresponding to each candidate number; the method comprises: In response to a game guild loading request, obtaining a guild identifier of a to-be-loaded guild corresponding to the game guild loading request; Based on the guild identifier of the guild to be loaded, determining a target node from the virtual service nodes provided by each game server in the server cluster; The step of loading the guild to be loaded onto the game server corresponding to the target node; and calculating the load variance of the server cluster corresponding to each of the candidate quantities comprises: For each candidate quantity in the multiple candidate quantities, perform the following operations: According to the current candidate quantity, a plurality of virtual service nodes in the server cluster are obtained; Obtaining a hash space corresponding to the current candidate quantity according to a hash value of each of the multiple virtual service nodes; Calculate the occupied space of the hash space corresponding to the current candidate number of virtual service nodes corresponding to each of the game servers; The load variance of the server cluster is determined according to the occupied space of the current candidate number of virtual service nodes corresponding to each of the game servers.
2. The method according to claim 1, characterized in that The step of determining the target node from the virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded comprises: Calculate the hash value of the guild identifier of the guild to be loaded; Based on the hash value, a target node corresponding to the guild to be loaded is determined from a preset hash space; wherein the preset hash space includes: a virtual service node provided by each game server in the server cluster, and a hash value of each virtual service node.
3. The method according to claim 2, characterized in that The step of determining the target node corresponding to the guild to be loaded from a preset hash space based on the hash value includes: Determine a hash value that matches the hash value of the guild to be loaded from the preset hash space; the matching hash value includes: a hash value that is adjacent to the hash value of the guild to be loaded in a clockwise direction and corresponds to a virtual service node; The virtual service node corresponding to the matching hash value is determined as the target node.
4. The method according to claim 1, characterized in that: The number of virtual service nodes provided by each of the game servers in the server cluster is the same; the number of virtual service nodes provided by the game server is determined in the following manner: The number of candidates corresponding to the load variance that meets the preset conditions is used to determine the number of virtual service nodes provided for the game server.
5. The method according to claim 1, characterized in that The hash value of the virtual service node is calculated in the following way: Determine the MD5 value of the virtual service node according to the node identifier of the virtual service node; Determine the MD5 value as the hash value of the virtual service node; Among them, the node identifier of the virtual service node includes: the IP address of the game server corresponding to the virtual service node, plus the product of the quotient of the numerical value that can be accommodated by the hash space corresponding to the current alternative quantity and the total number of virtual service nodes included in the server cluster and the preset number of the virtual service node.
6. The method according to claim 1, characterized in that The step of calculating the occupied space of the hash space corresponding to the current candidate number of virtual service nodes corresponding to each of the game servers comprises: For each virtual service node corresponding to each of the game servers, determine the space between the current virtual service node and the previous virtual service node of the current virtual service node in the hash space corresponding to the current candidate number as the occupied space of the current virtual service node; For each of the game servers, the occupied space of each virtual service node corresponding to the current game server is added to obtain the occupied space of the virtual service node corresponding to the current game server.
7. The method according to claim 1, characterized in that The step of determining the load variance of the server cluster according to the occupied space of the current candidate number of virtual service nodes corresponding to each of the game servers comprises: Calculating an average value of the occupied space of the current candidate number of virtual service nodes corresponding to each of the game servers; Divide the occupied space of the current candidate number of virtual service nodes corresponding to each of the game servers by the average value to obtain multiple load factors; The variance of the multiple load factors is calculated to obtain the load variance of the server cluster.
8. The method according to claim 1, characterized in that After the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further includes: The guild to be loaded and the game server to which the guild to be loaded is loaded are associated and saved in a preset cache list; Monitoring the running status of other game servers in the server cluster except the game server; If there is a stopped game server, delete the game guild run by the stopped game server from the preset cache list, and when a loading request for the game guild run by the stopped game server is received, continue to execute the step of responding to the game guild loading request and obtaining the guild identifier of the guild to be loaded corresponding to the game guild loading request.
9. The method according to claim 1, characterized in that: The game server includes a timer; after the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further includes: When all players in the guild to be loaded are offline, starting the timer; If the players in the guild to be loaded are not online after the timer expires, the guild to be loaded is transferred from the game server to which it is loaded to a preset database.
10. The method according to claim 1, characterized in that In response to a game guild loading request, the step of obtaining a guild identifier of a guild to be loaded corresponding to the game guild loading request comprises: receiving a game guild loading request sent by a player; the game guild loading request carries a guild identifier of the game guild to which the player belongs; Determine whether the game guild to which the player belongs is in a preset cache list; If the player is not in the preset cache list, the loading request is cached, the game guild to which the player belongs is determined as the guild to be loaded, and the guild identifier is obtained from the game guild loading request.
11. The method according to claim 1, characterized in that: After the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further includes: For the guild to be loaded, monitoring whether the time difference between the current time and the last saved time is greater than a first time threshold; if so, saving the information corresponding to the guild to be loaded; Monitor whether the guild to be loaded receives a request instruction sent by a player within a second time threshold; if received, save the request instruction.
12. The method according to claim 1, characterized in that The method further comprises: The game guild is saved in a preset recommendation cache pool; wherein the recommendation cache pool contains multiple game guilds; Selecting a target game guild from the recommendation cache pool, and sending the target game guild to players who have not joined the target game guild; The sending times of the game guilds in the recommendation cache pool are recorded, and the game guilds whose sending times are greater than a preset threshold are deleted from the recommendation cache pool.
13. A server, characterized in that: It comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the game guild loading method described in any one of claims 1 to 12.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by the processor, the computer-executable instructions prompt the processor to implement the method for loading the game guild described in any one of claims 1 to 12.
