CN111905362A - Game guild loading method and server - Google Patents

Game guild loading method and server Download PDF

Info

Publication number
CN111905362A
CN111905362A CN202010840501.6A CN202010840501A CN111905362A CN 111905362 A CN111905362 A CN 111905362A CN 202010840501 A CN202010840501 A CN 202010840501A CN 111905362 A CN111905362 A CN 111905362A
Authority
CN
China
Prior art keywords
guild
game
virtual service
server
loaded
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010840501.6A
Other languages
Chinese (zh)
Inventor
杨彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202010840501.6A priority Critical patent/CN111905362A/en
Publication of CN111905362A publication Critical patent/CN111905362A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/30Interconnection arrangements between game servers and game devices; Interconnection arrangements between game devices; Interconnection arrangements between game servers
    • A63F13/35Details of game servers
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/70Game security or game management aspects
    • A63F13/79Game security or game management aspects involving player-related data, e.g. identities, accounts, preferences or play histories

Abstract

The invention provides a loading method and a server for a game guild, wherein the method comprises the following steps: responding to the game guild loading request, and acquiring a guild identifier of a guild to be loaded corresponding to the game guild loading request; determining a target node from virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded; and loading the guild to be loaded to the game server corresponding to the target node. According to the invention, when the game server for loading the guild is allocated to the guild to be loaded, the virtual service node arranged in each game server in the server cluster is introduced, so that the number of the game guild loaded on different game servers can be balanced, and meanwhile, when the game server is down, the game server can be reallocated to the game guild loaded by the down game server according to the game guild loading request, so that the dynamic migration of the game guild is realized, and the game experience of a player can be improved.

Description

Game guild loading method and server
Technical Field
The invention relates to the technical field of game interaction, in particular to a loading method and a server for a game guild.
Background
The game guild is a social platform of a game player, the game guild is not attached to a specific game, the adhesion degree of the game to the player can be improved, the social requirement of the player is driven by putting guild awards, namely, the player can jointly complete tasks by joining the game guild, and the player in the guild can obtain guild awards after the tasks are completed.
In the related art, when the game servers are allocated to the game guild, the game guild is usually allocated to the game server where the guild creator is located, although the method is simple, the gap between the number of guild running on different game servers is large, the normal running of the game servers is affected, and if a certain game server goes down, the guild allocated to the game server cannot be loaded, so that the experience of a player is poor.
Disclosure of Invention
The invention aims to provide a loading method of game guild and a server, which are used for reducing the difference of guild quantity running on different game servers and improving the experience of players.
In a first aspect, an embodiment of the present invention provides a method for loading a game guild, where the method is applied to a game server, the game server is subordinate 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 method comprises the following steps: responding to the game guild loading request, and acquiring a guild identifier of a guild to be loaded corresponding to the game guild loading request; determining a target node from virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded; and loading the guild to be loaded to the game server corresponding to the target node.
In an optional embodiment, the step of determining a target node from 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 a hash value of the guild identifier of the guild to be loaded; determining a target node corresponding to the guild to be loaded from a preset hash space based on the hash value; wherein, the preset hash space comprises: the virtual service node provided by each game server in the server cluster and the hash value of each virtual service node.
In an optional embodiment, the step of determining, based on the hash value, a target node corresponding to a guild to be loaded from a preset hash space includes: determining a hash value matched with the hash value of the guild to be loaded from a preset hash space; the matching hash value includes: in the clockwise direction, the hash value of the virtual service node is adjacent to the hash value of the guild to be loaded and corresponds to the hash value of the guild to be loaded; and determining the virtual service node corresponding to the matched hash value as a target node.
In an optional embodiment, the number of virtual service nodes provided by each game server in the server cluster is the same; the number of virtual service nodes provided by the game server is determined by: acquiring a plurality of alternative numbers of virtual service nodes provided by a game server, and calculating the load variance of a server cluster corresponding to each alternative number; and determining the number of the virtual service nodes provided for the game server according to the alternative number corresponding to the load variance meeting the preset condition.
In an optional embodiment, the step of calculating the load variance of the server cluster corresponding to each candidate number includes: for each of the plurality of alternative numbers, performing the following operations: obtaining a plurality of virtual service nodes in the server cluster according to the current alternative quantity; obtaining a hash space corresponding to the current alternative quantity according to the hash value of each virtual service node in the plurality of virtual service nodes; calculating the occupied space of the hash space corresponding to the current alternative number of the virtual service nodes corresponding to each game server; and determining the load variance of the server cluster according to the occupied space of the virtual service nodes corresponding to each game server and having the current alternative number.
In an optional embodiment, the hash value of the virtual service node is calculated by: determining an MD5 value of the virtual service node according to the node identifier of the virtual service node; determining the MD5 value as a hash value of the virtual service node; wherein the node identification of the virtual service node comprises: and adding the product of the quotient of the numerical value quantity which can be accommodated by the hash space corresponding to the current alternative quantity and the total number of the virtual service nodes contained in the server cluster and the preset number of the virtual service node to the IP address of the game server corresponding to the virtual service node.
In an optional implementation manner, the step of calculating the occupied space of the hash space corresponding to the current candidate number at the virtual service node corresponding to each game server includes: aiming at each virtual service node corresponding to each game server, determining the space between the current virtual service node and the virtual service node which is the virtual service node before the current virtual service node in the hash space corresponding to the current alternative quantity as the occupied space of the current virtual service node; and adding the occupied space of each virtual service node corresponding to the current game server aiming at each game server to obtain the occupied space of the virtual service node corresponding to the current game server.
In an optional implementation manner, the step of determining the load variance of the server cluster according to the occupied space of the virtual service nodes of the current candidate number corresponding to each game server includes: calculating the average value of the occupied space of the virtual service nodes of the current alternative number corresponding to each game server; dividing the occupation space of the virtual service nodes of the current alternative number corresponding to each game server by the average value to obtain a plurality of load factors; and calculating the variance of the plurality of load factors to obtain the load variance of the server cluster.
In an optional implementation manner, after the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further includes: storing the guild to be loaded and the game server to which the guild to be loaded is loaded in a preset cache list in a correlated manner; monitoring the running states of other game servers except the game server in the server cluster; and if the game server which stops running exists, deleting the game guild which is run by the game server which stops running in the preset cache list, and when a loading request of the game guild which stops running is received, continuing to execute a step of responding to the game guild loading request and acquiring a guild identifier of the guild to be loaded corresponding to the game guild loading request.
In an optional embodiment, the game server comprises a timer; after the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further comprises the following steps: when all players in the guild to be loaded are offline, starting a timer; and if the player in the guild to be loaded is not on-line after the timer finishes timing, transferring the guild to be loaded from the loaded game server to a preset database.
In an optional embodiment, in response to the game guild loading request, the step of obtaining a 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 a guild identifier of a game guild to which the player belongs; judging whether the game guild to which the player belongs is in a preset cache list or not; if the game guild is 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 acquiring a guild identifier from the game guild loading request.
In an alternative embodiment, the game server comprises a dispatch interface; the method for receiving the game guild loading request sent by the player comprises the following steps: and receiving a game guild loading request sent by the player through a dispatch interface.
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: monitoring whether the time difference between the current time and the last disk storage time is greater than a first time threshold value or not for the guild to be loaded; if the number of the public meetings is larger than the preset number, storing the corresponding information of the to-be-loaded public meetings; monitoring whether a to-be-loaded guild receives a request instruction sent by a player within a second time threshold; and if so, saving the request instruction.
In an alternative embodiment, the game server includes a designated route interface for: and information is transmitted between each game server in the server cluster.
In an alternative embodiment, the method further comprises: storing the game guild in a preset recommendation cache pool; wherein, the recommendation cache pool comprises a plurality of game guidances; according to a preset rule, selecting a target game guild from the recommended cache pool, and sending the target game guild to a player who does not join the target game guild; and recording the sending times of the game guilds in the recommended cache pool, and deleting the game guilds with the sending times larger than a preset threshold value from the recommended cache pool.
In a second aspect, an embodiment of the present invention provides a loading device for a game guild, where the device is disposed in a game server, the game server is affiliated to a server cluster composed of a plurality of game servers, and each game server in the server cluster provides at least one virtual service node; the device includes: the loading request response module is used for responding to the game guild loading request and acquiring a guild identifier of the guild to be loaded corresponding to the game guild loading request; the target node determining module is used for determining a target node from virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded; and the guild loading module is used for loading the guild to be loaded to the game server corresponding to the target node.
In a third aspect, an embodiment of the present invention provides a server, including a processor and a memory, where the memory stores machine-executable instructions that can be executed by the processor, and the processor executes a machine-executable loading method for the game guild.
In a fourth aspect, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the loading method of the game guild described above.
The embodiment of the invention has the following beneficial effects:
the invention provides a loading method and a server of a game guild.A technique firstly responds to a game guild loading request and acquires a guild identifier of a guild to be loaded corresponding to the game guild loading request; further, based on the guild identifier of the guild to be loaded, a target node is determined from virtual service nodes provided by each game server in the server cluster; and then loading the guild to be loaded to a game server corresponding to the target node. In the method, each game server in the server cluster is provided with a virtual service node, the target node of the guild to be loaded is determined based on the guild identifier of the guild to be loaded, and then the server for loading the guild to be loaded is determined.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention as set forth above.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a loading method of a game guild according to an embodiment of the present invention;
FIG. 2 is a flowchart of another loading method for a game guild according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a preset hash space according to an embodiment of the present invention;
fig. 4 is a diagram illustrating a relationship between the number of virtual service nodes and a preset hash space distribution according to an embodiment of the present invention;
fig. 5 is a schematic diagram illustrating an influence curve of the candidate number of virtual service nodes and the load variance of the server cluster according to the embodiment of the present invention;
FIG. 6 is a flowchart of another loading method for a game guild according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a guild information synchronization according to an embodiment of the present invention;
FIG. 8 is a diagram illustrating information transmission between game servers according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a loading device of a game guild according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a server according to an embodiment of the present invention.
Detailed Description
In order to make the objects, 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 with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the related art, when allocating game servers to game guild, game guild is usually allocated on the game server where guild creators are located, the method is simple, when a guild player sends a guild request, the game server corresponding to the guild player can record the server code of the game server where the guild creators are located, and directly perform game guild loading and guild request processing on the game server corresponding to the number, the method for binding game guild and game server is simple to implement, high in reliability and safety, however, when the game servers are reduced, the game servers need to be swiped, the gap between the number of guild running on different game servers is large, the normal running of the game servers is affected, and if one game server is down, guild distributed on the game server cannot be loaded, further, the guild will be functionally paralyzed, resulting in a poor experience for the player.
Based on this, the embodiment of the invention provides a loading method and a server for a game guild. In order to facilitate understanding of the embodiment, a detailed description is first given of a loading method of a game guild disclosed in the embodiment of the present invention, where the method is applied to a game server, the game server belongs to a server cluster composed of a plurality of game servers, and each game server in the server cluster provides at least one virtual service node.
The server cluster includes a plurality of 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 game servers in the server cluster, the ID may be an IP (Internet Protocol) address of the game server, each game server may correspond to at least one virtual service node, the number of the virtual service nodes corresponding to each game server is the same, the number of the virtual service nodes corresponding to each game server can be set according to business requirements, research and development requirements and the like, and the purpose of setting the virtual service nodes for each game server is to balance the load of each game server, namely to ensure that the number of game guilds running on each game server is not too different.
Based on the above description, the flowchart of the loading method of the game guild provided in the embodiment of the present invention is, as shown in fig. 1, the method includes the following specific steps:
step S102, responding to the game guild loading request, and acquiring a guild identifier of the guild to be loaded corresponding to the game guild loading request.
The game guild load request may be a Remote Procedure Call (RPC) message sent by a guild player, which is typically a protocol by which a program may request a service from a program on another computer in the network, in which RPC the requesting program is a client and the serving program is a server. In a specific implementation, the PRC message may be a request related to the guild, such as applying for joining the guild, spending money to raise the guild level, exiting the guild, kicking out a guild member, getting online, or chatting information of the guild, and these requests may be collectively referred to as a game guild loading request.
In specific implementation, a guild player can send a game guild loading request to a game server where the guild player is located, wherein the game guild loading request carries a guild identifier of a game guild which the player wants to access; when the game server receives the game guild loading request, whether the game guild which the player wants to access is loaded or not is judged, if the game guild is loaded, the game guild loading request can be processed through the game server in which the game guild runs, for example, the game guild loading request is to send a chat message to other guild members, the server per se sends the chat message to the game server in which the game guild runs, and the chat message is sent to other member players of the game guild through the game server; if the game guild is not loaded, the self server is required to determine the game guild which the player wants to access as the guild to be loaded, and the guild identification of the guild to be loaded is obtained from the game guild loading request.
The guild mark is a mark specific to each game guild, and represents the identity of the game guild; the guild may be a string of characters, numbers, or special characters, such as 12131342aaa, etc.
And step S104, determining a 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.
In specific implementation, according to a guild identifier of a guild to be loaded, one virtual service node is randomly selected from virtual service nodes corresponding to each game server of a server cluster as a target node; or a guild identifier of the guild to be loaded and a link between the guild identifier and the node identifier of the virtual service node may be established in advance, and then a target node may be determined from the virtual service node corresponding to each game server of the server cluster according to the guild identifier.
And step S106, loading the guild to be loaded to a game server corresponding to the target node.
The virtual service nodes are set for balancing the load of each game server, so that the game server corresponding to the target node is determined according to the target node, and the guild to be loaded is loaded to the game server corresponding to the target node, that is, the guild to be loaded is loaded to the memory of the game server corresponding to the target node, so that the game server runs the guild to be loaded.
In particular implementations, each game guild may be allocated (equivalently loaded) to the same game server each time without changing the number of game servers in the server cluster and without down-time of the game servers. When a game server is newly added in the server cluster, the game servers are reduced or the game servers are down, the game servers need to be allocated to the game guild again according to the guild identification of the game guild, so that the relative balance of the load of each game service can be ensured.
Specifically, game guild which is not loaded to the game server to run can be stored in the preset database, so that the memory occupation of the game server is reduced; loading the game guild to a game server for running, namely loading the game guild from a preset database to a memory of the game server for running; in the running process of the game guild, if all member players of the game guild are detected to be offline and no member player is online in a specified time, the game guild needs to be serialized into preset data from a memory, so that the memory occupation of a game server can be reduced.
The invention provides a loading method of a game guild, which comprises the steps of firstly responding to a game guild loading request, and acquiring a guild identifier of a guild to be loaded corresponding to the game guild loading request; further, based on the guild identifier of the guild to be loaded, a target node is determined from virtual service nodes provided by each game server in the server cluster; and then loading the guild to be loaded to a game server corresponding to the target node. In the method, each game server in the server cluster is provided with a virtual service node, the target node of the guild to be loaded is determined based on the guild identifier of the guild to be loaded, and then the server for loading the guild to be loaded is determined.
The embodiment of the invention also provides another game guild loading method, which is realized on the basis of the method in the embodiment; the method focuses on describing a specific process of determining a target node from virtual service nodes provided by each game server in a server cluster based on a guild identifier of a guild to be loaded (which is implemented by the following steps S204-S206), and as shown in fig. 2, the method includes the following steps:
step S202, in response to the game guild loading request, obtaining a guild identifier of the guild to be loaded corresponding to the game guild loading request.
Step S204, calculating a hash value of the guild identifier of the guild to be loaded.
The hash value is obtained by mapping a segment of a longer character string into a shorter and smaller character string through a certain hash algorithm, where the segment of the shorter and smaller character string is the hash value of the longer character string, and the hash value has uniqueness, that is, different character strings can correspond to different hash values. The Hash Algorithm may use MD5(Message-Digest Algorithm) or SHA-1(Secure Hash Algorithm 1) or other algorithms. The MD5 algorithm is generally a widely used cryptographic hash function, and can generate a 128-bit (16-byte) hash value (also called hash value) to ensure the information transmission is complete and consistent, that is, the MD5 algorithm can obtain a 128-bit hash value according to a character string of any length; the SHA-1 algorithm may generate a 160-bit (20-byte) hash value, typically in the form of 40 hexadecimal numbers, from a string of characters of any length.
The guild identifier of the guild to be loaded may be a character string composed of numbers, and 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.
Step S206, determining a target node corresponding to the guild to be loaded from a preset hash space based on the hash value; wherein, the preset hash space comprises: the virtual service node provided by each game server in the server cluster and the hash value of each virtual service node.
The preset hash space is preset with a value amount capable of being accommodated by the preset hash space, and the value amount can be set according to research and development requirements, for example, the value amount can be 232That is, the hash value that the predetermined space can contain is 0-232A hash value in between. In specific implementation, all the virtual service nodes are mapped into a preset hash space according to the hash value corresponding to the virtual service node provided by each game server in the server cluster, that is, for each virtual service node, a hash value identical to the hash value of the current virtual service node is inquired in the preset hash space, and the current virtual service node is mapped at a position corresponding to the inquired identical hash value.
In the specific implementation, in a preset hash space, firstly, inquiring a hash value which is the same as the hash value corresponding to the guild identifier of the guild to be loaded; then, when a target node is determined, if the same hash value corresponds to a virtual service node, the virtual service node can be determined as the target node; any one of the virtual service nodes adjacent to the same hash value may also be determined as the target node. Specifically, the step S206 can be implemented by the following steps 10-11:
step 10, determining a hash value matched with the hash value of the guild to be loaded from a preset hash space; the matching hash value includes: and in the clockwise direction, the hash value of the virtual service node is adjacent to the hash value of the guild to be loaded.
In specific implementation, the preset hash space may be mapped to a space of 0 to 360 degrees according to a sequence of hash values from small to large, a hash value identical to the hash value of the guild to be loaded is queried in the space of 0 to 360 degrees, and the hash value adjacent to the identical hash value in the clockwise direction and corresponding to the virtual service node is determined as a matched hash value.
And step 11, determining the virtual service node corresponding to the matched hash value as a target node.
As shown in fig. 3, which is a schematic diagram of a preset hash space, each circle in fig. 3 represents a virtual service node, where a circle corresponding to a key indicated by an arrow is a position corresponding to a hash value of a guild to be loaded, and a virtual service node corresponding to a circle next to the circle corresponding to the key indicated by the arrow is taken as a target node in a clockwise direction.
When a game server is newly added or reduced in the server cluster, the game server needs to be re-allocated to the game guild according to the guild identifier of the game guild, so that the relative balance of the load of each game service can be ensured. It can be seen from fig. 3 that when one game server is deleted, the dynamic allocation to the game guild is not affected, and it can also be understood that the game guild allocated to the deleted game service is allocated to another game server, that is, when one game server is deleted, the game guild allocated to the deleted game service is offline (stored in the preset database), and if a game guild loading request of the game guild is received, another game server can be allocated to the game guild in real time, so that the whole service cluster is not affected too much, and the only effect is that when the game guild is loaded from the preset database instantly, a certain database load occurs, but the loading strategy is driven by the game guild loading request, so that the pressure is dispersed.
It can be seen from fig. 3 that when one game server is added, a game guild needs to be migrated, because a game guild needing to be allocated to a newly added game server may be allocated to its next game server, so that we only need to detect all game guilds by the next game server of the newly added game server, and the game guild on their own should not all kick off, that is, to ensure that the load balance is kicked off by more game servers carried by themselves. In the scheme, in consideration of balance, the consistent hash algorithm introduces a virtual service node, so that the next virtual service node of all the virtual service nodes needs to be processed.
The number of virtual service nodes provided by each game server in the server cluster is the same; the larger the number of virtual service nodes is, the more beneficial the load balance of the game server is, but the increased number of virtual service nodes also means the increased consumption when inquiring, inserting and deleting the virtual service nodes, so it is necessary to quantify the influence of the increased number of virtual service nodes on the load balance, firstly, the influence of the virtual service nodes on the load balance can be intuitively perceived from fig. 4, the virtual nodes in fig. 4 correspond to the virtual service nodes, each circular ring in fig. 4 represents one game server in the server cluster, the point on each ring is the virtual service node, when the number of the virtual service nodes is 1, 10, 64 and 100, respectively, as shown in fig. 4, the distribution of the virtual service nodes in the preset hash space is more uniform as seen from fig. 4, and a more even distribution can make the load more balanced.
As the number of virtual service nodes increases, the number of virtual service nodes provided by the game server can be determined through the following steps 20 to 21 in order to select an appropriate number of virtual service nodes, where the individual game servers are more uniformly distributed in the preset hash space:
and 20, acquiring a plurality of alternative numbers of the virtual service nodes provided by the game server, and calculating the load variance of the server cluster corresponding to each alternative number.
The plurality of candidate numbers may be each value in a range of values set to select the number of virtual service nodes, and for example, the candidate number may be each value between 0 and 120. And calculating the load variance of the server cluster when the number of the virtual service nodes provided by the game server is the current alternative number aiming at each alternative number in the multiple alternative numbers. The load variance of the server cluster may be related to the occupied space of the hash space corresponding to the current candidate number at the virtual service node corresponding to each game server.
And step 21, determining the number of the virtual service nodes provided for the game server according to the alternative number corresponding to the load variance meeting the preset condition.
The preset condition may be a condition set according to a development requirement, for example, the number of candidates corresponding to the minimum load variance, or the number of candidates corresponding to the load variance being a preset value.
In a specific implementation, when calculating a load variance of a server cluster corresponding to each candidate quantity, for each candidate quantity of a plurality of candidate quantities, the following operations are performed: the above step 20 can be realized by the following steps 30 to 33:
step S30, obtaining a plurality of virtual service nodes in the server cluster according to the current alternative quantity; the current number of alternatives is any one of a plurality of alternative numbers.
Step S31, obtaining a hash space corresponding to the current candidate number according to the hash value of each virtual service node in the multiple virtual service nodes.
In a specific implementation, each virtual service node in the plurality of virtual service nodes corresponds to a preset number, and the preset number may be a number set for each virtual service node according to a preset number rule. According to the preset number of the virtual service node, the numerical quantity which can be contained in the preset hash space and the total number of the virtual service nodes contained in the server cluster, the node identifier of the virtual service node can be obtained, namely the node identifier of the virtual service node comprises: the IP address of the game server corresponding to the virtual service node, plus the product of the quotient of the numerical value quantity that can be accommodated by the hash space corresponding to the current alternative quantity and the total number of the virtual service nodes contained in the server cluster and the preset number of the virtual service node, can be represented as follows by a formula:
IP address + number of virtual service nodes that can be accommodated/total number of virtual service nodes preset number.
Based on the above description, the hash value of each virtual service node can be calculated by the following method: determining an MD5 value of the virtual service node according to the node identifier of the virtual service node; the MD5 value is determined as a hash value for the virtual service node. That is, a 128-bit hash value (also referred to as MD5 value) corresponding to the node identifier is obtained by the MD5 algorithm.
In specific implementation, the virtual service nodes of the current candidate number corresponding to the game server may be mapped in a preset hash space according to the hash value of each virtual service node, so as to obtain the hash space corresponding to the current candidate number.
And step 32, calculating the occupied space of the hash space corresponding to the current alternative number of the virtual service nodes corresponding to each game server.
For each virtual service node, in the hash space corresponding to the current candidate number, determining a space between virtual service nodes adjacent to the current virtual service node in a clockwise direction, or determining a space between virtual service nodes adjacent to the current virtual service node in a counterclockwise direction, as an occupied space of the current virtual service node, specifically, the manner for determining the occupied space may be adapted to the manner for determining the target node, and 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. And according to the sum of the occupied spaces corresponding to the virtual service nodes with the current alternative number corresponding to the game server, the occupied space of each game server in the hash space corresponding to the current alternative number can be obtained.
In a specific implementation, the step 32 may be implemented as follows: aiming at each virtual service node corresponding to each game server, determining the space between the current virtual service node and the virtual service node which is the virtual service node before the current virtual service node in the hash space corresponding to the current alternative quantity as the occupied space of the current virtual service node; and adding the occupied space of each virtual service node corresponding to the current game server aiming at each game server to obtain the occupied space of the virtual service node corresponding to the current game server.
In specific implementation, first, for each virtual service node in the virtual service nodes of the current candidate number provided by each game server in the server cluster, an occupied space of the current virtual service node is calculated, that is, a space between the current virtual service node and a virtual service node before the current virtual service node in a hash space corresponding to the current candidate number is calculated. And after the occupation space of each virtual service node is obtained, the occupation spaces of the virtual service nodes of the current alternative number corresponding to each game server are extracted, the occupation spaces of the virtual service nodes corresponding to the current game servers are added aiming at each game server, the occupation space of the virtual service node corresponding to the current game server is obtained, and then the occupation space of the virtual service nodes of the current alternative number corresponding to each game server is obtained.
And step 33, determining the load variance of the server cluster according to the occupied space of the virtual service nodes corresponding to each game server and having the current alternative number.
In a specific implementation, the above step 33 can be implemented by the following steps 40 to 42:
and step 40, calculating the average value of the occupied spaces of the virtual service nodes of the current alternative number corresponding to each game server. That is, the occupied spaces of the virtual service nodes corresponding to the current candidate number of each game server are added, and then the addition result is divided by the number of game servers to obtain an average value.
Step 41, dividing the occupied space of the virtual service nodes of the current alternative number corresponding to each game server by the average value to obtain a plurality of load factors; that is, the load factor corresponding to the occupied space of the virtual service nodes with the current alternative number corresponding to each game server is obtained.
And 42, calculating the variance of the load factors to obtain the load variance of the server cluster.
Calculating the variance of all the load factors, namely firstly adding all the load factors and then averaging to obtain a load mean value, then subtracting each load factor from the load mean value to obtain a load difference value, and summing after squaring each load difference value to obtain the load variance of the server cluster.
Through the above steps 30 to 42, the load variance of the server cluster corresponding to each candidate number among the plurality of candidate numbers of 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, an influence curve of the candidate number of the virtual service nodes and the load variance of the server cluster can be obtained, as shown in fig. 5, fig. 5 is an influence curve drawn when the number of game servers in the server cluster is 15, and as can be seen from fig. 5, when the number of game servers is 15, the load variance of the server cluster is gradually reduced along with the increase of the number of the virtual service nodes, but the change is not very significant when the number of the virtual service nodes is greater than 50, at this time, 50 can be selected as the number of the virtual service nodes provided by the game server; in some embodiments, a binary search is usually used to determine the target node, so that the number of virtual service node services is 1024/15, preferably about 68.
And step S208, loading the guild to be loaded to a game server corresponding to the target node.
The loading method of the game guild comprises the steps of firstly responding to a game guild loading request, and obtaining a guild identifier of a guild to be loaded corresponding to the game guild loading request; further calculating the hash value of the guild identifier of the guild to be loaded; determining a target node corresponding to the guild to be loaded from a preset hash space based on the hash value; and then loading the guild to be loaded to a game server corresponding to the target node. The mode can realize the distribution of different game guilds on different game servers, thereby realizing the decentralization of game guild service and balancing the load of different game servers for managing the game guild, and the mode can realize the dynamic migration of the game servers and improve the experience of players when the game servers are down.
The embodiment of the invention also provides another game guild loading method, which is realized on the basis of the method in the embodiment; the method mainly describes a specific process of acquiring a guild identifier of a guild to be loaded corresponding to a game guild loading request (realized by the following steps S602-S612); as shown in fig. 6, the method includes the steps of:
step S602, receiving a game guild loading request sent by a player; the game guild loading request carries a guild identifier of a game guild to which the player belongs.
The game guild loading request can be a request related to a game guild, such as applying for joining a guild, spending money to improve guild level, quitting the guild, kicking out a guild member or chatting information of the guild, and the game guild request carries a guild identifier of the game guild to which the player sending the game guild request belongs.
In specific implementation, as the game servers have more interfaces, the game guild loading request cannot be processed through a uniform calling function, so that a dispatch interface is set for each game server in the server cluster; each game server can receive a game guild loading request sent by a player through the dispatch interface. The dispatch interface can also be called a dispatch interface, the dispatch interface codes each attribute of each function, and when the function is called, the serial number is transmitted to the dispatch interface, so that the dispatch interface calls the corresponding function.
Each game server is provided with a guild process for processing game guild information, the operation of the guild process can be identified through the operation type in the guild process and distributed to the corresponding game guild in the guild process through UnionManger, and all game guild loading requests related to guild are received through a dispatch interface (equivalent to a dispatch interface of the game server) of the guild process, so that all game guild loading requests can be easily reached by Hook. The Hook generally means that all game guild loading requests are called by the same function, and the function can uniformly process all requests, for example, when a game guild loading request is received, a game guild corresponding to the request is not loaded, the game guild loading request is cached first, then the game guild is loaded, and the request is processed by the game guild after the loading is completed.
Because when different game guild loading requests correspond to different operation types, the operation types are very complicated to distinguish in the process that the subsequent development requirements are continuously increased and changed, therefore, all game guild loading requests can be defaulted to the types which can change the game guild information, and the machine processing is convenient.
Step S604, judging whether the game guild to which the player belongs is in a preset cache list; if the current cache list is in the preset cache list, executing step S606; otherwise, step S608 is executed.
The preset cache list may store a guild identifier of a game guild that a player has visited on the game server (the game server corresponds to a game suit where the player is located) that is not running on the game server, and information of the game server where the game guild runs, where the information may be an IP address of the game server, a server identifier, and the like; the guild identity of the game official running on the game server may also be saved.
Step S606, the game guild loading request is sent to the game server of the game guild to which the running player belongs, which is stored in the preset cache list, so that the game server processes the game guild loading request.
When the game server of the game guild to which the running player belongs, which is stored in the preset cache list, receives the game guild loading request, the game server determines whether the game guild corresponding to the game loading request is the game guild running on the game server. If yes, caching the game guild loading request, loading the game guild, and processing the cached game guild loading request after loading the game guild; if not, determining the game guild as a guild to be loaded, acquiring a guild identifier from the game guild loading request, further determining a target node from virtual service nodes provided by each game server in the server cluster based on the guild identifier, determining a game server corresponding to the target node as a game server for loading the guild to be loaded, and after the determination is good, storing the guild to be loaded and the loaded game server corresponding to the guild to be loaded in a preset cache list corresponding to the game server for sending the game guild loading request in an associated manner.
Step S608, caching the game guild loading request, determining the game guild to which the player belongs as a guild to be loaded, and acquiring a guild identifier from the game guild loading request; step S610 is performed.
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 identification of the guild to be loaded is obtained from the game guild loading request to prepare for subsequent game server distribution.
Step S610, determining a 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 step S612, loading the guild to be loaded to a game server corresponding to the target node.
Step S614, the guild to be loaded and the game server to which the guild to be loaded is loaded are stored in the preset cache list in an associated manner.
Step S616, the running states of other game servers except the game server in the server cluster are monitored.
In specific implementation, each game server has a guild process, each guild process has a consistent hash cluster object, and each consistent hash cluster object maintains IDs of the guild processes on other game servers (the ID may be an IP address of the game server or an identifier of the guild process, etc.), that is, IDs of the guild processes on other game services are stored in the consistent hash cluster object; the consistent Hash cluster object can monitor the running states of other game servers according to the stored IDs of the guild processes on other game servers, and the running states of the game servers are associated with the running states of the guild processes set by the game servers, so that the running states of other game servers, namely the running states of the guild processes, can be monitored. Specifically, other game servers send a heartbeat Procedure Call (RPC) to the game server every fixed time (for example, 10s), and the game server may determine the operation states of other game servers according to the received heartbeat RPC, or may understand that the game server operates normally if the heartbeat RPC of a certain game server is received within a fixed time; if a heartbeat PRC of a certain game server is not received, the game server stops running, which can also be called that the game server is down or has a fault.
In a specific implementation, the consistent hash cluster object may perform the steps S514 to S516, that is, a guild process may be selected for the guild through a hash value corresponding to the guild identifier of the guild to be loaded, where the process of selecting the guild process may be understood as a process of selecting a game server for loading the guild to be loaded.
In step S618, if there is a game server that stops running, the game guild running on the game server that stops running in the preset cache list is deleted, so that when the guild loading request of the game guild is received, the game server is allocated to the game guild.
When a loading request of a game guild running on a game server which stops running is received, the step S602 may be continuously executed to allocate a game server for the game guild. The mode can ensure that the game guild running under the game server can realize the dynamic migration of the guild when the game server stops running, thereby avoiding influencing the normal use of the player and improving the game experience of the player.
During specific implementation, when a game guild is not loaded on a game server, the game guild is stored in a preset database, if a game guild loading request is received, whether the game guild is loaded in a memory of the game server is judged firstly, if so, the game guild loading request is processed directly through the game server loading the game guild, and if the game guild is being loaded, the game guild loading request is cached; if the game guild is not loaded, the game guild loading request is cached, a loaded game server can be distributed to the game guild through the consistent Hash cluster object, and after the game guild loading is completed, the cached game guild loading request is processed in a unified mode.
Each game server in the server cluster comprises a timer; after a guild to be loaded is loaded on a game server, the game server needs to monitor the online and offline states of players in the guild to be loaded, and when the players in the guild to be loaded are all offline, a timer is started; and if the time of the timer is over, the players in the guild to be loaded are not on line, and the guild to be loaded is transferred to the preset database from the loaded game server. The purpose of setting the timer is to delay the time of the game guild going off-line, that is, a cache strategy is to prevent the game guild from frequently transferring between the memory of the game server and the preset database. The timing duration of the timer can be set according to development requirements, for example, 1 minute or 20 minutes.
When the to-be-loaded guild is loaded on the game server, the information corresponding to the to-be-loaded guild is required to be stored, and when the information is stored, whether the time difference between the current time and the last time for storing the information is greater than a first time threshold value or not can be monitored for the to-be-loaded guild; if the number of the public meetings is larger than the preset number, storing the corresponding information of the to-be-loaded public meetings; monitoring whether a to-be-loaded guild receives a request instruction sent by a player within a second time threshold; and if so, saving the request instruction. The request instruction may be the game guild load request, i.e., a request related to a game guild.
The first time threshold and the second time threshold may be set according to requirements, for example, the first time threshold may be set to 60 minutes, the second time threshold may be set to 15 minutes, and the like. In specific implementation, the game server may set a 15-minute repeat timer, the 15-minute repeat timer is started after the game guild is loaded, if the distance from the last time to the storage exceeds 60 minutes (that is, a timestamp is recorded when the last time to the storage is stored), the time from the current time to the last time to the storage is checked every time the 15-minute repeat timer is executed, and the time exceeds 60 minutes), information corresponding to the guild to be loaded is required to be stored, if any request instruction is received within 15 minutes, the request instruction needs to be immediately stored, the request instruction may be considered as a request for modifying information of the game guild, and the storage policy may effectively reduce the information storage pressure of the game guild.
In some embodiments, the default stock is used when the guild is destroyed, which is typically when the guild is offline (i.e., stored in a predetermined database), when a player in the guild is offline, etc.
In the management of the game guild, there is also a problem of information synchronization of the game guild, that is, UnionEntity on the guild process is modified through a request instruction of the game guild, but the UnionEntity is not notified to be modified on the guild process corresponding to each member player in the game guild, which causes a problem of information inconsistency. The UnionEntity may refer to an entity that manages information of the game guity, and therefore there is one copy of UnionProxy on each of the client Avatar, the server Avatar, and the UnionStub (i.e., an entity that manages a guild process), where the three unionentities are commonly used to represent information of the game guity, and the information synchronization of the game guity may actually refer to information synchronization between the three unionentities, and a specific structure thereof is shown in fig. 7.
For the information synchronization of game guild, only one simple broadcast operation is needed to complete the task, however, the broadcast operation requires a large number of interfaces for processing operations to be defined on the players of the game guild, and corresponding codes are added to the client, the server and the Unionsstub every time a new game guild is added, which is very complicated, thus, it is possible to broadcast the changing information of the game guild, the operation of which actually causes the change of the game guild information, if an interface for acquiring the game guild information is provided, then broadcasting the changed fields in the game guild information, the synchronization of the whole guild information becomes very simple, all game guild operations (equivalent to guild information) can be synchronized only by interfaces with different granularities, therefore, when a new game guild is added, corresponding synchronous interfaces do not need to be provided at the client and the server. The interfaces with different granularities may refer to interfaces for processing broadcast information in the client, the server and the guild process interfaces, and specifically, the interfaces for field change of the broadcast game guild information, for example, interfaces for adding or deleting change of member players in the broadcast game guild, interfaces for adding or deleting change of broadcast application, and the like.
Because the number of players in the game guild is large (usually more than 50), the behaviors of the game guild members need to be synchronized to each member of the game guild, and a large amount of information synchronization RPC is generated by member login, offline, game state, chat, activity change and the like, so that large communication overhead is inevitably caused. Therefore, a designated routing interface unique to the whole service is created on the guild process, namely, a designated routing interface is created on each game server in the game server cluster, and the designated routing is used for: and information is transmitted between each game server in the server cluster.
The specified route may be a stubbuter, which is a logical entity located on a guild process for merging and forwarding information between different game servers. The information may be a message on a game process, which is usually a service process in which a player object is located, and processes an object of logic in a game of the player, all requests of the player about a game guild are sent from the game process, and a request sent by the client to the server is also processed on the game process. All requests for game guild include pulling guild information, joining guild, exiting guild, guild chatting, etc.
As shown in fig. 8, which is a schematic diagram of information transmission between Game servers, Game suit 1, Game suit 2, and Game suit 3 in fig. 8 respectively represent Game server 1, Game server 2, and Game server 3, and Game represents a Game progress. Chat information sent by a player at one game server to a player at another server is uniformly sent through an interface of a stub router (equivalent to the specified routing interface), namely the stub router is merged to player calls of different game servers through buffering, so that the communication times between the game servers are remarkably reduced, and when RPC calls of the game server forwarded by the stub router of other game servers are received, the RPC calls merged to all game processes are buffered, so that the communication pressure when the communication is frequent can be remarkably reduced, and the pressure brought by the communication can be reduced by the buffering and merging of RPC at two layers.
The game guild recommendation is an important part of a guild system, and a established game guild needs to be recommended to a player so that the player can choose to join. For the recommended game guild, it is expected that each game guild will have an opportunity to recommend to the player, but it is obvious that randomly fetching game guild data from the database by all players will cause pressure on database access, so a recommendation cache pool is needed, which can be managed by LRU (Least recent Used) strategy, and specifically, game guild recommendations can be made through the following steps 50-52:
step 50, storing the game guild in a preset recommendation cache pool; wherein, the cache pool comprises a plurality of game guilds. A plurality of game guilds are stored in the recommendation buffer pool in a doubly linked list mode, and each game guild carries a time stamp, recommended times and guild information.
And step 51, selecting the target game guild from the recommended cache pool according to a preset rule, and sending the target game guild to the player who does not join the target game guild.
And step 52, recording the sending times (equivalent to the recommended times) of the game guilds, and deleting the game guilds with the sending times larger than a preset threshold value from the recommended cache pool.
In a specific implementation, the data of the game guild stored in the recommended cache pool has expiration time, the expiration clearing of the data randomly selects a certain number (for example, 25) to check in a TICK way, the probability of the data being unselected gradually decreases by 0.001 of the spot check probability along with the increase of the TICK times, and the probability of the data being unchecked after the time of TICK10 minutes is less than 1%. The game guild recommended by the player is directly pulled from the recommendation cache pool, in order to ensure that the game guild in the recommendation cache pool is not frequently recommended to all players in a short time, the frequency of recommending one game guild to the player (the frequency of sending the target game guild to the player who does not join the target game guild) can be limited, the frequency can be customized according to the number of the game guild, the preset threshold value can be set according to the requirement, and the game guild can be recommended to all players more uniformly through the recommendation mode. According to the game guild recommendation, the maximum recommendation times are introduced into the recommendation-based cache pool, the recommendation randomness is improved, and the access pressure of the recommendation on the database is reduced.
According to the loading method of the game guild, dynamic service sharing is carried out on the game guild based on the consistent Hash cluster, decentralization of game guild service sharing is achieved, loads of different game servers are balanced, and dynamic migration of the game guild can be achieved when the game servers stop running. And for the synchronization of the game guild information among the players, the RPC process of the synchronization information is buffered and merged by adopting a specified routing interface, so that the load of the game guild information synchronization is obviously reduced.
Corresponding to the method embodiment, the embodiment of the invention also provides a loading device of the game guild, the device is arranged on the game server, the game server is subordinate to a server cluster consisting of a plurality of game servers, and each game server in the server cluster provides at least one virtual service node; as shown in fig. 9, the apparatus includes:
and a loading request responding module 90, configured to respond to the game guild loading request, and obtain a guild identifier of the guild to be loaded, where the guild loading request corresponds to the to-be-loaded guild.
And the target node determining module 91 is configured to determine a 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 the guild loading module 92 is used for loading the guild to be loaded to the game server corresponding to the target node.
The loading device of the game guild responds to the game guild loading request firstly, and obtains a guild identifier of a guild to be loaded corresponding to the game guild loading request; further, based on the guild identifier of the guild to be loaded, a target node is determined from virtual service nodes provided by each game server in the server cluster; and then loading the guild to be loaded to a game server corresponding to the target node. In the method, each game server in the server cluster is provided with a virtual service node, the target node of the guild to be loaded is determined based on the guild identifier of the guild to be loaded, and then the server for loading the guild to be loaded is determined.
Further, the target node determining module 91 includes: the hash value calculation unit is used for calculating the hash value of the guild identifier of the guild to be loaded; the node determining unit is used for determining a target node corresponding to the guild to be loaded from a preset hash space based on the hash value; wherein, the preset hash space comprises: the virtual service node provided by each game server in the server cluster and the hash value of each virtual service node.
Specifically, the node determining unit is configured to: determining a hash value matched with the hash value of the guild to be loaded from a preset hash space; the matching hash value includes: in the clockwise direction, the hash value of the virtual service node is adjacent to the hash value of the guild to be loaded and corresponds to the hash value of the guild to be loaded; and determining the virtual service node corresponding to the matched hash value as a target node.
In specific implementation, the number of virtual service nodes provided by each game server in the server cluster is the same; the device comprises a virtual service node number determining module, and comprises: the load variance calculation unit is used for acquiring a plurality of alternative numbers of the virtual service nodes provided by the game server and calculating the load variance of the server cluster corresponding to each alternative number; and the quantity determining unit is used for determining the quantity of the virtual service nodes provided for the game server according to the alternative quantity corresponding to the load variance meeting the preset condition.
Specifically, the load variance calculating unit is configured to: obtaining a plurality of virtual service nodes in the server cluster according to the current alternative quantity; obtaining a hash space corresponding to the current alternative quantity according to the hash value of each virtual service node in the plurality of virtual service nodes; calculating the occupied space of the hash space corresponding to the current alternative number of the virtual service nodes corresponding to each game server; and determining the load variance of the server cluster according to the occupied space of the virtual service nodes corresponding to each game server and having the current alternative number.
Further, the apparatus further includes a virtual service node hash value determining module, configured to: determining an MD5 value of the virtual service node according to the node identifier of the virtual service node; determining the MD5 value as a hash value for the virtual service node; wherein the node identification of the virtual service node comprises: and adding the product of the quotient of the numerical value quantity which can be accommodated by the hash space corresponding to the current alternative quantity and the total number of the virtual service nodes contained in the server cluster and the preset number of the virtual service node to the IP address of the game server corresponding to the virtual service node.
Further, the load variance calculating unit is further configured to: aiming at each virtual service node corresponding to each game server, determining the space between the current virtual service node and the virtual service node which is the virtual service node before the current virtual service node in the hash space corresponding to the current alternative quantity as the occupied space of the current virtual service node; and adding the occupied space of each virtual service node corresponding to the current game server aiming at each game server to obtain the occupied space of the virtual service node corresponding to the current game server.
Further, the load variance calculating unit is further configured to: calculating the average value of the occupied space of the virtual service nodes of the current alternative number corresponding to each game server; dividing the occupation space of the virtual service nodes of the current alternative number corresponding to each game server by the average value to obtain a plurality of load factors; and calculating the variance of the plurality of load factors to obtain the load variance of the server cluster.
Further, the apparatus further includes a status monitoring module, configured to: storing the guild to be loaded and the game server to which the guild to be loaded is loaded in a preset cache list in a correlated manner; monitoring the running states of other game servers except the game server in the server cluster; if the game server which stops running exists, the game guild which stops running in the preset cache list is deleted, and when a loading request of the game guild which stops running in the game server is received, the loading request response module 90 continues to run.
Specifically, the game server comprises a timer; the device further comprises a guild transfer module for: when all players in the guild to be loaded are offline, starting a timer; and if the player in the guild to be loaded is not on-line after the timer finishes timing, transferring the guild to be loaded from the loaded game server to a preset database.
Further, the load request response module 90 is configured to: receiving a game guild loading request sent by a player; the game guild loading request carries a guild identifier of a game guild to which the player belongs; judging whether the game guild to which the player belongs is in a preset cache list or not; if the game guild is 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 acquiring a guild identifier from the game guild loading request.
Specifically, the game server includes a dispatch interface; the loading request response module 90 is configured to: and receiving a game guild loading request sent by the player through a dispatch interface.
Further, the apparatus further comprises a disk storage module, configured to: monitoring whether the time difference between the current time and the last disk storage time is greater than a first time threshold value or not for the guild to be loaded; if the number of the public meetings is larger than the preset number, storing the corresponding information of the to-be-loaded public meetings; monitoring whether a to-be-loaded guild receives a request instruction sent by a player within a second time threshold; and if so, saving the request instruction.
Further, the game server includes a designated route interface, the designated route being for: and information is transmitted between each game server in the server cluster.
Further, the device further comprises a guild recommending module, configured to: storing the game guild in a preset recommendation cache pool; wherein, the recommendation cache pool comprises a plurality of game guidances; according to a preset rule, selecting a target game guild from the recommended cache pool, and sending the target game guild to a player who does not join the target game guild; and recording the sending times of the game guilds in the recommended cache pool, and deleting the game guilds with the sending times larger than a preset threshold value from the recommended cache pool.
The implementation principle and the generated technical effects of the loading device of the game guild provided by the embodiment of the invention are the same as those of the method embodiment, and for brief description, the corresponding contents in the method embodiment can be referred to where the embodiment of the device is not mentioned.
An embodiment of the present invention further provides a server, as shown in fig. 10, where the server includes a processor and a memory, where the memory stores machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the loading method of the game guild.
Further, the server shown in fig. 10 further includes a bus 102 and a communication interface 103, and the processor 101, the communication interface 103, and the memory 100 are connected through the bus 102.
The memory 100 may include a high-speed Random Access Memory (RAM) and may further include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the network element of the system 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, a wide area network, a local network, a metropolitan area network, and the like can be used. The bus 102 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 10, but this does not indicate only one bus or one type of bus.
The processor 101 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 101. The processor 101 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. 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 foregoing embodiment in combination with the hardware thereof.
The embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement the loading method of the game guild.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the apparatus and/or the electronic device described above may refer to corresponding processes in the foregoing method embodiments, and are not described herein again.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive the technical solutions described in the foregoing embodiments or equivalent substitutes for some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (15)

1. A loading method of a game guild is characterized in that the method is applied to a game server, the game server belongs to a server cluster consisting of a plurality of game servers, and each game server in the server cluster provides at least one virtual service node; the method comprises the following steps:
responding to a game guild loading request, and acquiring a guild identifier of a guild to be loaded corresponding to the game guild loading request;
determining a target node from virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded;
and loading the guild to be loaded to a game server corresponding to the target node.
2. The method of claim 1, wherein the step of determining a target node from virtual service nodes provided by each game server in the server cluster based on the guild identifier of the guild to be loaded comprises:
calculating the hash value of the guild identifier of the guild to be loaded;
determining a target node corresponding to the to-be-loaded guild from a preset hash space based on the hash value; wherein, the preset hash space comprises: the server cluster comprises 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, wherein the step of determining the target node corresponding to the guild to be loaded from a preset hash space based on the hash value comprises:
determining a hash value matched with the hash value of the guild to be loaded from the preset hash space; the matched hash values include: in the clockwise direction, the hash value of the virtual service node is adjacent to the hash value of the guild to be loaded and corresponds to the hash value of the guild to be loaded;
and determining the virtual service node corresponding to the matched hash value as a target node.
4. The method of claim 1, wherein each of the game servers in the server cluster provides the same number of virtual service nodes; the number of virtual service nodes provided by the game server is determined by the following method:
acquiring a plurality of alternative numbers of the 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 number of the virtual service nodes provided for the game server according to the alternative number corresponding to the load variance meeting the preset condition.
5. The method according to claim 4, wherein the step of calculating the load variance of the server cluster corresponding to each of the candidate quantities comprises:
for each of the plurality of alternative quantities, performing the following operations:
obtaining a plurality of virtual service nodes in the server cluster according to the current alternative quantity;
obtaining a hash space corresponding to the current alternative quantity according to the hash value of each virtual service node in the plurality of 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;
and determining the load variance of the server cluster according to the occupied space of the virtual service nodes corresponding to each game server and having the current alternative number.
6. The method of claim 5, wherein the hash value of the virtual service node is calculated by:
determining an MD5 value of the virtual service node according to the node identifier of the virtual service node;
determining the MD5 value as a hash value of the virtual service node;
wherein the node identification of the virtual service node comprises: and adding the product of the quotient of the numerical value quantity which can be accommodated by the hash space corresponding to the current alternative quantity and the total number of the virtual service nodes contained in the server cluster and the preset number of the virtual service node to the IP address of the game server corresponding to the virtual service node.
7. The method of claim 5, wherein the step of calculating the occupation space of the hash space corresponding to the current candidate number at the virtual service node corresponding to the current candidate number corresponding to each game server comprises:
for each virtual service node corresponding to each game server, determining a current virtual service node and a space between the current virtual service node and a virtual service node before the current virtual service node in a hash space corresponding to the current alternative number as an occupied space of the current virtual service node;
and adding the occupied space of each virtual service node corresponding to the current game server aiming at each game server to obtain the occupied space of the virtual service node corresponding to the current game server.
8. The method of claim 5, wherein 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 game server comprises:
calculating the average value of the occupied space of the virtual service nodes of the current alternative number corresponding to each game server;
dividing the occupied space of the virtual service nodes of the current alternative number corresponding to each game server by the average value to obtain a plurality of load factors;
and calculating the variance of the plurality of load factors to obtain the load variance of the server cluster.
9. The method of claim 1, wherein after the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further comprises:
storing the guild to be loaded and the game server to which the guild to be loaded are loaded in a preset cache list in an associated manner;
monitoring the running states of other game servers in the server cluster except the game server;
and if the game server which stops running exists, deleting the game guild which is run by the game server which stops running in the preset cache list, and when a loading request of the game guild which stops running is received, continuing to execute a step of responding to the game guild loading request and acquiring a guild identifier of the guild to be loaded corresponding to the game guild loading request.
10. The method of claim 1, wherein a timer is included in the game server; 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 the players in the guild to be loaded are offline, starting the timer;
and if the player in the guild to be loaded is not on-line after the timer finishes timing, transferring the guild to be loaded from the loaded game server to a preset database.
11. The method of claim 1, wherein the step of obtaining the guild identifier of the guild to be loaded corresponding to the game guild loading request in response 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 a game guild to which the player belongs;
judging whether the game guild to which the player belongs is in a preset cache list or not;
if the game guild identifier is 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 acquiring the guild identifier from the game guild loading request.
12. The method of claim 1, wherein after the step of loading the guild to be loaded onto the game server corresponding to the target node, the method further comprises:
monitoring whether the time difference between the current time and the last disk storage time is greater than a first time threshold value or not aiming at the guild to be loaded; if the number of the information is larger than the preset number, storing the information corresponding to the to-be-loaded guild;
monitoring whether the guild to be loaded receives a request instruction sent by a player within a second time threshold; and if so, saving the request instruction.
13. The method of claim 1, further comprising:
storing the game guild in a preset recommendation cache pool; the recommendation cache pool comprises a plurality of game guidances;
selecting a target game guild from the recommended cache pool, and sending the target game guild to a player who does not join the target game guild;
and recording the sending times of the game guilds in the recommended cache pool, and deleting the game guilds of which the sending times are greater than a preset threshold value from the recommended cache pool.
14. A server comprising a processor and a memory, the memory storing machine executable instructions executable by the processor, the processor executing the machine executable instructions to implement the method of loading of a game guild of any one of claims 1 to 13.
15. A computer-readable storage medium having stored thereon computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the method of loading a game guild of any one of claims 1 to 13.
CN202010840501.6A 2020-08-19 2020-08-19 Game guild loading method and server Pending CN111905362A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010840501.6A CN111905362A (en) 2020-08-19 2020-08-19 Game guild loading method and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010840501.6A CN111905362A (en) 2020-08-19 2020-08-19 Game guild loading method and server

Publications (1)

Publication Number Publication Date
CN111905362A true CN111905362A (en) 2020-11-10

Family

ID=73279702

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010840501.6A Pending CN111905362A (en) 2020-08-19 2020-08-19 Game guild loading method and server

Country Status (1)

Country Link
CN (1) CN111905362A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506647A (en) * 2020-11-19 2021-03-16 杭州电魂网络科技股份有限公司 Method, system, device and storage medium for load balancing of stateful servers
CN113713376A (en) * 2021-08-30 2021-11-30 腾讯科技(深圳)有限公司 Interactive information display method and device and electronic equipment

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050198335A1 (en) * 2001-02-06 2005-09-08 Microsoft Corporation Distributed load balancing for single entry-point systems
WO2007133124A1 (en) * 2006-05-12 2007-11-22 Acei Ab Gaming system with failover and takeover capability
US20080051200A1 (en) * 2006-08-24 2008-02-28 Nhn Corporation System and method for transmitting p2p message in multi-access online game
CN108499100A (en) * 2018-03-30 2018-09-07 南京工业大学 A kind of cloud game error recovery method and system based on edge calculations
WO2018215942A1 (en) * 2017-05-23 2018-11-29 Constructive Labs Server system for processing a virtual space
CN109513206A (en) * 2017-09-19 2019-03-26 北京金山云网络技术有限公司 The network architecture of online game and data forwarding method for online game
CN109621430A (en) * 2018-12-12 2019-04-16 网易(杭州)网络有限公司 Game services end system, game control method, device, medium and electronic equipment
CN110841282A (en) * 2019-10-30 2020-02-28 腾讯科技(深圳)有限公司 Data processing method and device, storage medium and electronic device
CN111338806A (en) * 2020-05-20 2020-06-26 腾讯科技(深圳)有限公司 Service control method and device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050198335A1 (en) * 2001-02-06 2005-09-08 Microsoft Corporation Distributed load balancing for single entry-point systems
WO2007133124A1 (en) * 2006-05-12 2007-11-22 Acei Ab Gaming system with failover and takeover capability
US20080051200A1 (en) * 2006-08-24 2008-02-28 Nhn Corporation System and method for transmitting p2p message in multi-access online game
WO2018215942A1 (en) * 2017-05-23 2018-11-29 Constructive Labs Server system for processing a virtual space
CN109513206A (en) * 2017-09-19 2019-03-26 北京金山云网络技术有限公司 The network architecture of online game and data forwarding method for online game
CN108499100A (en) * 2018-03-30 2018-09-07 南京工业大学 A kind of cloud game error recovery method and system based on edge calculations
CN109621430A (en) * 2018-12-12 2019-04-16 网易(杭州)网络有限公司 Game services end system, game control method, device, medium and electronic equipment
CN110841282A (en) * 2019-10-30 2020-02-28 腾讯科技(深圳)有限公司 Data processing method and device, storage medium and electronic device
CN111338806A (en) * 2020-05-20 2020-06-26 腾讯科技(深圳)有限公司 Service control method and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506647A (en) * 2020-11-19 2021-03-16 杭州电魂网络科技股份有限公司 Method, system, device and storage medium for load balancing of stateful servers
CN113713376A (en) * 2021-08-30 2021-11-30 腾讯科技(深圳)有限公司 Interactive information display method and device and electronic equipment
CN113713376B (en) * 2021-08-30 2023-07-14 腾讯科技(深圳)有限公司 Interactive information display method and device and electronic equipment

Similar Documents

Publication Publication Date Title
US9911148B2 (en) Querying for business service processing status information
CN109729131B (en) Application request processing method and device and router
CN112153160A (en) Access request processing method and device and electronic equipment
CN111585887B (en) Communication method and device based on multiple networks, electronic equipment and storage medium
CN111905362A (en) Game guild loading method and server
CN108933829A (en) A kind of load-balancing method and device
JP6582445B2 (en) Thin client system, connection management device, virtual machine operating device, method, and program
JPWO2018220708A1 (en) Resource allocation system, management device, method and program
CN112615784B (en) Method, device, storage medium and electronic equipment for forwarding message
CN110677492A (en) Access request processing method and device, electronic equipment and storage medium
JP2016527780A (en) Distribution of creator systems among lease agent systems
US20070265976A1 (en) License distribution in a packet data network
CN111432039A (en) Data request method, device and equipment in CDN and CDN node
US20170104683A1 (en) Dynamically segmenting traffic for a/b testing in a distributed computing environment
CN111984295B (en) Block chain software whole-network updating method, storage medium and electronic equipment
CN109347766B (en) Resource scheduling method and device
CN113383364A (en) Verifier node selection method, electronic device, system, and medium
CN109981696B (en) Load balancing method, device and equipment
CN112732765B (en) Method and device for determining experimental path and electronic equipment
WO2015196769A1 (en) Method for processing data in iptv system, and network element device
CN107203915B (en) Data storage method and device
CN111274022A (en) Server resource allocation method and system
CN117459597A (en) Request processing method and device based on hash ring, electronic equipment and storage medium
CN111193692A (en) Request response method, device, edge node and authentication system
CN109241053B (en) Identification code allocation method, device and server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination