Method, device, server and storage medium for processing offline data in a game

By configuring multiple candidate offline data processing processes in the game server and assigning processing tasks through the message forwarder, the system and gameplay unresponsiveness caused by excessive load on the ImServer process is solved, and a better gaming experience is achieved.

CN115400416BActive Publication Date: 2025-05-27NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211021768.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-24
Publication Date
2025-05-27
Estimated Expiration
2042-08-24

AI Technical Summary

Technical Problem

In the prior art, the ImServer process is overloaded when processing a large amount of offline data, resulting in the inability to send status synchronization messages on time, which in turn leads to the system and gameplay being unresponsive, affecting the player's gaming experience.

Method used

Multiple candidate offline data processing processes are configured in the game server, and pending offline data is obtained through the message forwarder, the target process is determined from the candidate process, and the registration message is sent to the target process for data processing.

Benefits of technology

By dispersing the load of offline data processing processes, reducing the burden on a single process, avoiding the system and gameplay unresponsiveness caused by excessive load, and significantly improving the player's gaming experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115400416B_ABST
    Figure CN115400416B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device, server and storage medium for processing offline data in a game, including: obtaining the offline data to be processed; determining a target offline data processing process from the candidate offline data processing processes; sending a registration message corresponding to the offline data to be processed to the target offline data processing process, so as to process the offline data to be processed through the target offline data processing process. The present invention can better balance the load of the offline data processing process, effectively improve the situation that the corresponding system and gameplay become unresponsive due to the overload and unresponsiveness of the offline data processing process, and thus significantly improve the game experience of players.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular, to a method, device, server, and storage medium for processing offline data in a game. Background Art

[0002] In an online game, the server not only needs to process the online data after a player logs in to the game, but also needs to process the offline data after the player logs out of the game. Since the loading of offline data has nothing to do with the player himself / herself and is only loaded from the database when needed, the processing logic of offline data is different from that of online data. In order to distinguish the processing flows of online data and offline data, the game server separately creates a server process for the logic of processing offline data, which is called the ImServer process.

[0003] However, when the amount of calculation data of the offline data is large, the settlement behavior of the ImServer process for the offline data lasts for a long time, resulting in the ImServer process being unable to send a status synchronization message to the main control process in the game server on time. The main control process marks the ImServer process as a disconnected state and removes the ImServer process from the set of server processes. The ImServer process will be unable to continue processing the offline data, and further causes the systems and gameplay corresponding to the offline data to be unresponsive, affecting the player experience. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a method, device, server, and storage medium for processing offline data in a game, which can better balance the load of the offline data processing process, effectively improve the situation where the systems and gameplay are unresponsive due to the overloaded and unresponsive offline data processing process, and thus significantly improve the player experience.

[0005] In a first aspect, an embodiment of the present invention provides a method for processing offline data in a game. The method is applied to a message forwarder in a game server, and the game server is configured with a plurality of candidate offline data processing processes. The method includes: obtaining the offline data to be processed; determining a target offline data processing process from the candidate offline data processing processes; and sending a registration message corresponding to the offline data to be processed to the target offline data processing process, so as to perform data processing on the offline data to be processed through the target offline data processing process.

[0006] In one implementation, the step of determining a target offline data processing process from the candidate offline data processing processes includes: determining whether there is a data structure corresponding to the offline data to be processed in the first data structure already bound by the candidate offline data processing process; if so, determining the candidate offline data processing process bound to the data structure corresponding to the offline data to be processed as the target offline data processing process; if not, generating a second data structure corresponding to the offline data to be processed, and determining a target offline data processing process from the candidate offline data processing processes based on the first data structure already bound by each candidate offline data processing process.

[0007] In one implementation, the step of determining a target offline data processing process from the candidate offline data processing processes based on the first data structure already bound by each candidate offline data processing process includes: determining the current idle state of each candidate offline data processing process based on the first data structure already bound by each candidate offline data processing process; and determining a target offline data processing process from the candidate offline data processing processes according to the current idle state.

[0008] In one implementation, the step of determining the current idle state of each candidate offline data processing process based on the first data structure already bound by each candidate offline data processing process includes: determining the total amount of the structure of the first data structure already bound by each candidate offline data processing process; and determining the current idle state of each candidate offline data processing process according to the total amount of the structure corresponding to each candidate offline data processing process.

[0009] In one implementation, the step of determining the current idle state of each candidate offline data processing process based on the first data structure already bound by each candidate offline data processing process further includes: for each candidate offline data processing process, obtaining the weight parameter corresponding to each first data structure already bound by the candidate offline data processing process, and calculating the total weight corresponding to the candidate offline data processing process based on the weight parameter corresponding to each first data structure; and determining the current idle state of each candidate offline data processing process according to the total weight corresponding to each candidate offline data processing process.

[0010] In one embodiment, the step of sending a registration message corresponding to the offline data to be processed to the target offline data processing process, so as to perform data processing on the offline data to be processed through the target offline data processing process, includes: establishing a binding relationship between the data identifier in the second data structure and the target offline data processing process; based on the binding relationship, sending a registration message corresponding to the offline data to be processed to the target offline data processing process, so that the target offline data processing process pulls the offline data to be processed from the data storage address corresponding to the data identifier and data type in the second data structure, and performs data processing on the offline data to be processed.

[0011] In one embodiment, the method further includes: if a cancellation message for the offline data to be processed is received, deleting the binding relationship between the data structure corresponding to the offline data to be processed and the target offline data processing process.

[0012] In one embodiment, the method further includes: if a modification message for the offline data to be processed is received, sending the modification message to the target offline data processing process, so that the target offline data processing process performs modification processing on the offline data to be processed based on the modification message.

[0013] In one embodiment, the message forwarder is configured with a message queue, and at least one offline data to be processed is stored in the message queue; the method further includes: if a feedback message for the offline data to be processed from the target offline data processing process is received, determining the next offline data to be processed from the message queue; determining the next target offline data processing process bound to the next offline data to be processed from the candidate offline data processing processes; sending a registration message corresponding to the next offline data to be processed to the next target offline data processing process, so that the next target offline data processing process performs data processing on the next offline data to be processed.

[0014] In one embodiment, the game server is further configured with a main control process, and the method further includes: if a process removal message sent by the main control process is received, determining a to-be-removed offline data processing process corresponding to the process removal message from the candidate offline data processing processes; wherein, the process removal message is generated by the main control process when no status synchronization message of the to-be-removed offline data processing process is received within a preset duration; determining each first data structure bound to the to-be-removed offline data processing process; for each of the first data structures bound to the to-be-removed offline data processing process, determining a target migration offline data processing process corresponding to the first data structure from the candidate offline data processing processes other than the to-be-removed offline data processing process; and sending a registration message corresponding to the first data structure to the target migration offline data processing process, so as to process the offline data corresponding to the first data structure through the target migration offline data processing process.

[0015] In a second aspect, an embodiment of the present invention further provides a device for processing offline data in a game. The device is applied to a message forwarder in a game server. The game server is configured with a plurality of candidate offline data processing processes. The device includes: a data acquisition module, configured to acquire to-be-processed offline data; a process determination module, configured to determine a target offline data processing process from the candidate offline data processing processes; and a message sending module, configured to send a registration message corresponding to the to-be-processed offline data to the target offline data processing process, so as to process the to-be-processed offline data through the target offline data processing process.

[0016] In a third aspect, an embodiment of the present invention further provides a server, including a processor and a memory. The memory stores computer-executable instructions that can be executed by the processor. The processor executes the computer-executable instructions to implement any one of the methods provided in the first aspect.

[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions cause the processor to implement any one of the methods provided in the first aspect.

[0018] A method, apparatus, server, and storage medium for processing offline data in a game provided by an embodiment of the present invention are applied to a message forwarder in a game server. The game server is configured with multiple candidate offline data processing processes. First, the offline data to be processed is obtained, and a target offline data processing process is determined from the candidate offline data processing processes. Finally, a registration message corresponding to the offline data to be processed is sent to the target offline data processing process to process the offline data to be processed through the target offline data processing process. By opening multiple candidate offline data processing processes in the game server, the offline data is dispersed to each candidate offline data processing process. After the registration message corresponding to the offline data to be processed is sent to the target offline data processing process, the target offline data processing process can process the offline data to be processed. Therefore, the load of a single target offline data processing process is relatively small. The embodiment of the present invention can better balance the load of the offline data processing process, effectively improve the situation that the system and gameplay become unresponsive due to the excessive load of the offline data processing process and no response, and thus significantly improve the player's gaming experience.

[0019] Other features and advantages of the present invention will be described in the following specification, and, in part, will be obvious from the specification, or will be understood by practicing the present invention. The objectives and other advantages of the present invention are achieved and obtained by the structures specifically pointed out in the specification, claims, and drawings.

[0020] To make the above objectives, features, and advantages of the present invention more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. Brief Description of the Drawings

[0021] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the prior art. Obviously, the following drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0022] Figure 1 It is a schematic flowchart of a method for processing offline data in a game provided by an embodiment of the present invention;

[0023] Figure 2 It is a schematic diagram of an index provided by an embodiment of the present invention;

[0024] Figure 3 It is a schematic diagram of message passing provided by an embodiment of the present invention;

[0025] Figure 4 It is another schematic diagram of message passing provided by an embodiment of the present invention;

[0026] Figure 5 Schematic diagram of a message queue provided by an embodiment of the present invention;

[0027] Figure 6 Another schematic diagram of message passing provided by an embodiment of the present invention;

[0028] Figure 7 Schematic diagram of the structure of a device for processing offline data in a game provided by an embodiment of the present invention;

[0029] Figure 8 Schematic diagram of the structure of a server provided by an embodiment of the present invention. Detailed implementation manners

[0030] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the embodiments. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0031] Currently, in the existing technical solutions, the ImServer process is a single-start process. The ImServer process is not only used to process offline data related to players, but also used to process some services that are unique to the entire server. Since only one ImServer process is opened, the game logic implemented on it will ensure the orderliness and uniqueness of the services. On this basis, the existing offline data processing process is extremely prone to situations where the system and gameplay become unresponsive due to high load and no response.

[0032] For example, since the logic of offline data is implemented on the ImServer process, all operations related to guilds and guild members are handled by a single ImServer process. Suppose there are 400,000 registered players on a certain online game server, and the maximum number of players in a single guild is set to 150. In the extreme case, the number of guilds on one server is 2,600. Since guild data itself requires some regular processing, such as distributing rewards to all guild members at the whole-hour settlement, when the target time point is reached, all guilds on the ImServer process start the settlement operation simultaneously, that is, calculate the data of 2,600 guilds and 400,000 players at the same time. Due to the large amount of data to be calculated, the entire settlement behavior will last for a long time, resulting in the ImServer process being unable to send status synchronization messages (i.e., heartbeat packets) to the main control process during this period. When the main control process does not receive the status synchronization messages sent by the ImServer process, it will mark the ImServer process as a disconnected state, and the main control process will actively remove the ImServer process from the server process set and no longer listen for messages from the ImServer process.

[0033] In addition, in addition to the disconnection of the ImServer process caused by the large amount of guild and guild member data, a large number of operations on players' personal offline data at the same time point may also cause the ImServer process to disconnect. For example, players' mail data belongs to offline data. When a certain game service needs to send emails to a large number of specified players, it will also cause the ImServer process to get stuck in a single email-sending step and be unable to send status synchronization messages to the main control process, resulting in the main control process actively kicking the ImServer process out of the process set, and the game service on the ImServer process will stagnate and be unable to receive or send messages.

[0034] Based on this, the embodiments of the present invention provide a method, device, server, and storage medium for processing offline data in a game, which can better balance the load of the offline data processing process, effectively improve the situation where the system and gameplay become unresponsive due to the excessive load and non-response of the offline data processing process, and thus significantly improve the gaming experience of players.

[0035] For the convenience of understanding this embodiment, first, a method for processing offline data in a game disclosed in the embodiments of the present invention will be introduced in detail. The method is applied to a message forwarder (MessageSwitcher) in a game server. The game server is configured with multiple candidate offline data processing processes (which can also be called candidate ImServer processes). Refer to Figure 1 the flowchart of a method for processing offline data in a game shown, and this method mainly includes the following steps S102 to step S106:

[0036] Step S102, obtain the offline data to be processed. Among them, the offline data to be processed is the data generated when the player logs out of the game, such as reward settlement data (guild reward settlement or personal reward settlement, etc.), home data, social data, guild data, etc.

[0037] Exemplarily, for online games with strong sociality, in addition to maintaining the personal data of players, a new organizational structure composed of multiple players (such as a guild) will be generated. In a piece of guild data, there is not only information related to the guild itself, such as attributes like guild level and guild funds, but also information related to all members in the guild, that is, guild member data. Usually, the number of members in a guild reaches more than 100. The change of guild data is related to the operations of multiple members. When player A and player B are in the same guild, even if player A is offline, the operation of player B will modify the guild data; similarly, when the player is offline, the guild itself will also perform operations such as fund maintenance and reward distribution. Therefore, both the guild and guild member data belong to offline data.

[0038] In addition, offline data is usually related to multiple players, that is, the operation of player A will affect the data of player B. For example, player A sends a friend request to player B, but player B is offline. At this time, the information of player A needs to be added to the friend request list of player B. Here, the friend request list of player B is an offline data.

[0039] Step S104, determine the target offline data processing process (which can also be called the target ImServer process) from the candidate offline data processing processes. In one implementation, it can be determined whether the candidate offline data processing process has been registered for the offline data to be processed. If so, the registered candidate offline data processing process can be determined as the target offline data processing process; if not, the target offline data processing process can be selected according to the current idle state of each candidate offline data processing process.

[0040] Step S106, send a registration message corresponding to the offline data to be processed to the target offline data processing process, so as to process the offline data to be processed through the target offline data processing process. Among them, the registration message is used to instruct the target offline data processing process to process the offline data to be processed. The specific data processing logic is related to the data type of the offline data to be processed. In one implementation, a binding relationship can be established between the target offline data processing process and the data structure corresponding to the offline data to be processed, and then the corresponding registration message is sent to the target offline data processing process to process the offline data to be processed through the target offline data processing process.

[0041] In the method for processing offline data in a game provided by an embodiment of the present invention, a plurality of candidate offline data processing processes are opened in the game server, so as to disperse the offline data to each candidate offline data processing process. After the registration message corresponding to the offline data to be processed is sent to the target offline data processing process, the target offline data processing process can process the offline data to be processed. Therefore, the load of a single target offline data processing process is relatively small. The embodiment of the present invention can better balance the load of the offline data processing process, effectively improving the situation where the system and gameplay become unresponsive due to the overloaded and unresponsive offline data processing process, thereby significantly improving the player's gaming experience.

[0042] In practical applications, the game server is composed of a group of server processes. Among them, the main control process is called MasterServer, which is used to control and maintain the status of all processes joined to this group of servers. According to different functions, the other processes are divided into two categories. One category is the multi-instance processes, and the nodes of these processes can process the services with the same logic simultaneously to disperse the service pressure. The other category is the single-instance processes, and the nodes of these processes are mainly used to process the services unique to the whole server to ensure the orderliness and uniqueness of the services. For the process nodes other than MasterServer, a message will be sent to MasterServer every n seconds (15 <= n <= 30) to indicate that they are in a normal working state. MasterServer will check every n seconds whether it has received the messages from each process. If the status update of a certain process has not been received for n seconds, MasterServer will issue an alarm indicating that the status of this process needs to be monitored. If the status update of this process has not been received for a continuous duration of 2n, MasterServer will actively remove this process from the entire server process set. For the communication between server processes, a well-encapsulated message forwarder will be used. The message forwarder will find which process the target object is registered on according to the target object that needs to receive the message, and then forward the message to the target process. After receiving the message, the target process will perform further processing on the specified object.

[0043] In addition, the reason for removing the ImServer process from the server process set is that a single process cannot handle operations with a large amount of data. In the existing server architecture, for operations with a large amount of data and many business logics, multiple processes are often used. For example, in an online game server, multiple LogicServer processes for processing online player data are started simultaneously. When processing the operations of online players, whenever a player logs in, the unique identifier ID (Identity document) of the player, that is, PlayerId, is bound to a specified LogicServer process. Since multiple LogicServer processes are started, the data of different players will be scattered on different LogicServer processes, and the operations between them will not affect each other. When a player logs off, the PlayerId bound to the LogicServer process will be removed. When the player logs in again next time, a new LogicServer process will be found for him to bind. Although the amount of data of online players is large, since it is scattered on different LogicServer processes, the load of a single LogicServer process is not large. Another example is that the DbServer process is used to handle the operation of data storage. Although the amount of data to be stored is large, since the data to be stored has been distributed to different DbServer processes according to the unique identifier, a single DbServer can handle the storage task assigned to it.

[0044] On this basis, the embodiment of the present invention proposes that multiple candidate ImServer processes are configured in the game server. Compared with only starting one ImServer process in the prior art, the embodiment of the present invention expands to start multiple ImServer processes simultaneously and supports the dynamic addition and reduction of ImServer processes. When the ImServer process is expanded to multiple processes, the offline data service will be evenly scattered on each ImServer process, and the load of a single ImServer process will be significantly reduced. Moreover, since new ImServer processes can be dynamically added, when it is monitored that the load of an ImServer process is high, a new ImServer process can be dynamically started to balance the overall load.

[0045] For easy understanding, the embodiment of the present invention provides an implementation manner of the foregoing step S104, as shown in the following steps 1 to 3:

[0046] Step 1: Determine whether there is a data structure corresponding to the offline data to be processed in the first data structure already bound by the candidate offline data processing process. If so, execute Step 2; if not, execute Step 3. Here, the data structure is a pre-defined general data structure, abbreviated as ImObject. ImObject includes ImObjectId and ImObjectType. ImObjectId is the unique identifier ID in the real data structure, and ImObjectType is the classification identifier of the real data structure, such as guild, home, friend relationship, player personal offline data, etc. The first data structure is the data structure already bound to the candidate ImServer process, abbreviated as the first ImObject. In one implementation, when receiving a message of the offline data to be processed, it will search in the first data structure bound by each candidate ImServer process to determine whether the data structure corresponding to the offline data to be processed already exists.

[0047] Step 2: If so, determine the candidate offline data processing process bound to the data structure corresponding to the offline data to be processed as the target offline data processing process. In one implementation, if the data structure corresponding to the offline data to be processed can be found, then determine the candidate ImServer process bound to the ImObjectId in this data structure, and use this candidate ImServer process as the target ImServer process.

[0048] Step 3: If not, generate a second data structure corresponding to the offline data to be processed, and determine the target offline data processing process from the candidate offline data processing processes based on the first data structure already bound by each candidate offline data processing process. The second data structure is also defined by the general ImObject, but since no target ImServer process has been assigned to it yet, it is abbreviated as the second ImObject. After generating the second ImObject, it is necessary to find the relatively idle ImServer process among all candidate ImServer processes as the target ImServer process, and send a registration message corresponding to the offline data to be processed to this target ImServer process. When the second data structure is bound to a certain unique ImServer process, the second data structure becomes a complete ImObject, and its essence is no different from the first data structure. At this time, the quantity and weight of the second data structure can participate in the determination of the idle state of the candidate ImServer process. In addition, when determining the idle state of the candidate ImServer process, the quantity or weight parameter of the first ImObject already bound by the candidate ImServer process can reflect the current idle degree of the candidate ImServer process, so as to select the relatively idle candidate ImServer process as the target ImServer process based on this current idle degree.

[0049] For step 3 above, an embodiment of the present invention further provides an implementation manner of determining a target offline data processing process from candidate offline data processing processes based on a first data structure bound to each candidate offline data processing process. Refer to the following steps 3.1 to 3.2:

[0050] Step 3.1, based on the first data structure bound to each candidate offline data processing process, determine the current idle state of each candidate offline data processing process. Some implementation manners for determining candidate ImServer processes are provided in an embodiment of the present invention. Refer to the following manner 1 to manner 2:

[0051] Manner 1: In the early stage of game operation or when the number of game playstyles is small, the target offline data processing process can be determined based on the quantity of the first data structure. Specifically, the total quantity of the structures of the first data structure bound to each candidate offline data processing process can be determined, and then based on the total quantity of the structures corresponding to each candidate offline data processing process, the current idle state of each candidate offline data processing process can be determined. Among them, the total quantity of the structures is negatively correlated with the current idle state. The larger the total quantity of the structures, the worse the current idle state of the candidate ImServer process; conversely, the smaller the total quantity of the structures, the better the current idle state of the candidate ImServer process. Exemplarily, among all candidate ImServer processes, the candidate ImServer process with the least total quantity of the first ImObject registered can be selected as the target ImServer process.

[0052] Method 2: In the middle and late stages of game operation, since a certain amount of gameplay data has been accumulated, there is a prediction of the number of messages that various types of ImObjects may receive. When registering a new ImObject, a weight parameter, namely ImObjectWeight, can be added. A total weight is maintained on each candidate ImServer process in the MessageSwitcher. When a new ImObject is registered or unregistered, the total weight is increased or decreased accordingly, so that the target offline data processing process can be determined based on the weight parameter of the first data structure. Specifically, for each candidate offline data processing process, obtain the weight parameter ImObjectWeight corresponding to each first data structure bound to the candidate offline data processing process, and calculate the total weight corresponding to the candidate offline data processing process based on the weight parameter corresponding to each first data structure. Then, based on the total weight corresponding to each candidate offline data processing process, determine the current idle state of each candidate offline data processing process. Among them, the total weight is negatively correlated with the current idle state. The larger the total weight, the worse the current idle state of the candidate ImServer process. On the contrary, the smaller the total weight, the better the current idle state of the candidate ImServer process. Exemplarily, the candidate ImServer process with the smallest current total weight can be assigned to the new ImObject. The strategy of weight-based allocation is applicable to the case of a large number of ImObjects, such as guild objects. When a guild activity starts, more active guild objects will receive more messages. Therefore, the weights are calculated based on the activity of the guilds when the server starts, and the highly active guilds are dispersed among different ImServer processes, which helps to balance the load of each ImServer process.

[0053] Step 3.2, determine the target offline data processing process from the candidate offline data processing processes according to the current idle state. In one implementation, a relatively idle candidate ImServer process can be selected as the target ImServer process. Exemplarily, the candidate ImServer process with the smallest total structure amount can be selected as the target ImServer process, or the candidate ImServer process with the smallest total weight can be selected as the target ImServer process.

[0054] Based on the foregoing embodiments, the embodiments of the present invention provide an implementation manner of the foregoing step S106, see the following steps a to b:

[0055] Step a, establish a binding relationship between the data identifier in the second data structure and the target offline data processing process. In one implementation, an index table can be defined in the MessageSwitcher to bind each unique ImObject to a unique ImServer process, so that a unique ImServer process can be indexed through ImObject(Id,Type). For example, Figure 2 as shown in the schematic diagram of an index. Exemplarily, ImObject(key: pid, type: relationship) is bound to ImServer process 1, ImObject(key: gid, type: gulid) is bound to ImServer process 2, and ImObject(key: fid, type: friendship) is bound to ImServer process 3. In an alternative implementation, the index table supports registration and cancellation.

[0056] Step b, send a registration message corresponding to the offline data to be processed to the target offline data processing process based on the binding relationship, so that the target offline data processing process can pull the offline data to be processed from the data storage address corresponding to the data identifier and data type in the second data structure, and perform data processing on the offline data to be processed. Among them, the data storage address includes a global cache address or a database address.

[0057] Considering that the finally compiled dll of the message forwarder needs to be loaded into the process to run, and the main control process MasterServer is a single-opened server process, whose logic layer not only maintains the status information of all processes, but also retains the account information of all online players. Therefore, it is preferred to bind the MessageSwitcher to the MasterServer. In specific implementation, the MasterServer and the MessageSwitcher can be regarded as a whole. Messages between processes are first forwarded to the MasterServer and then to the target ImServer process. For the MasterServer, its upper layer is the logic layer for processing game services, and the dll file of the MessageSwitcher bound at the bottom layer is responsible for processing message forwarding. It should be noted that theoretically, the MessageSwitcher can be bound to any single-opened process.

[0058] When the MessageSwitcher cannot find the ImObject corresponding to the offline data to be processed in the index table, it indicates new offline data to be processed. A new ImObject needs to be created for the offline data to be processed, and a target ImServer process needs to be allocated. Creating an ImObject in the network layer is only to record the one-to-one correspondence between the offline data to be processed and the target ImServer process. The specific game business logic is still implemented on the target ImServer process. Therefore, after selecting the target ImServer process, the target ImServer process needs to be notified of the registration of a new ImObject so that the target ImServer process can perform initialization operations. The specific initialization method can be determined by the target ImServer process according to the data type of the ImObject.

[0059] When the target ImServer process receives the message that an ImObject needs to be registered, it determines the business data to which the ImObject belongs according to the data type of the ImObject, and then judges whether to load the offline data to be processed from the global cache or pull the offline data to be processed from the database according to the business data to which it belongs. Exemplarily, the way of loading data is jointly determined by the ImObjectId and the ImObjectType: for data with a high reading frequency, such as guild data, all guild members may read and modify it. If there are many active players in the guild, the read and write frequency is higher. Then this type of data will be loaded from the database when the server starts and stored in the global cache; for data with a low reading frequency, such as the friend relationship data of players, which only represents the relationship between player A and player B, and can only be read and modified when A or B is online. This type of data will be pulled from the database when player A or B logs in. In practical applications, the ImObjectType is used to determine which loading method, and the ImObjectId is used to find the specified data in the specific data table or global cache.

[0060] In addition, when the target ImServer process processes the offline data to be processed, the specific business logic for operating the offline data is not placed in the MessageSwitcher, but is implemented in the game logic layer. Different game server architectures may adopt different implementation methods for the game logic layer. For example, scripting languages such as lua or python are used for implementation. The reason for separating the MessageSwitcher and the game logic layer is as follows: the former needs to forward a large number of messages and requires higher speed; the latter needs to update functions online and requires convenient hot update. For a single process in the game logic layer, when it receives a message forwarded by the MessageSwitcher, it will determine whether the message corresponds to an ImObject, and then, according to the type of the ImObject, perform different processing, such as adding an id to the friend list, saving the entire friend data to disk, and so on.

[0061] In practical applications, after the ImObject is marked and registered on the target ImServer process, all writes related to the ImObject are only executed on the target ImServer process. Other ImServer processes can pull the relevant offline data from the global cache for display. However, if it involves the modification and writing of the ImObject, it needs to be forwarded to the target ImServer process where the ImObject is registered for operation. Based on this, the embodiment of the present invention further provides an implementation manner for modifying the offline data to be processed. Specifically: if a modification message for the offline data to be processed is received, the modification message is sent to the target offline data processing process, so that the target offline data processing process modifies the offline data to be processed based on the modification message. Refer to Figure 3 As shown in a schematic diagram of message passing, ImServer process 1 sends a message requesting to modify ImObject2 to the MasterServer. The MasterServer forwards the message to ImObject2. The MessageSwitcher obtains that ImObject2 is bound to ImServer process 2. The MasterServer forwards the message to ImServer process 2. ImServer process 2 modifies ImObject2 and notifies ImServer process 1 to update the data. Figure 3 It also shows that ImServer process 1 can request ImObject1 data from the global data cache Redis only for display. The global data cache Redis feeds back ImObject1 to ImServer process 1.

[0062] In another implementation, when the MessageSwitcher receives a message that needs to be forwarded, it first looks for the ImObjectId in the existing index table. If found, it directly reads the corresponding target ImServer process and forwards the message. If not, it means that the current ImObject needs to be newly registered, so it automatically looks for the relatively idle candidate ImServer process among all candidate ImServer processes and binds the relatively idle candidate ImServer process to this ImObject. After the binding, it actively notifies the ImServer process that there is a new ImObject to be registered. After notifying the registration message, it then forwards the originally needed-to-be-forwarded message. In practical applications, a large part of the messages that need to be forwarded refer to the situation where ImServer process 1 wants to modify ImObject2 bound to ImServer process 2. Forwarding such messages is to ensure that only a single ImServer process can modify a certain ImObject, so as to avoid data inconsistency caused by multiple ImServer processes modifying simultaneously. In addition, when a large amount of cached data needs to be read at one time, the ImServer process registered by the ImObject can also be used to operate, so as to reduce the reading of global cached data. For example, the data of a certain guild and its guild members is registered on ImServer process 1. When ImServer process 2 needs to read the data of 100 members of this guild, if it reads from the global cache, it needs to read 100 times. However, if the reading operation is forwarded to ImServer process 1 to execute, since the data of the guild and its guild members is already registered on ImServer process 1, it can be directly obtained from the memory of ImServer process 1, and at this time, there is no need to read the global cache 100 times.

[0063] Exemplarily, refer to Figure 4 Another message passing schematic diagram as shown. ImServer process 1 forwards the ImObject message. The MasterServer notifies the MessageSwitcher to find the ImServer process corresponding to the ImObject. When the ImServer process corresponding to the ImObject is not found, registration is required first. At this time, the MasterServer notifies ImServer process 2 that there is an ImObject to be registered. After the registration is completed, the ImObject message is then forwarded to ImServer process 2.

[0064] In one embodiment, the embodiment of the present invention further provides an embodiment for canceling the offline data to be processed. Specifically, if a cancellation message for the offline data to be processed is received, the binding relationship between the data structure corresponding to the offline data to be processed and the target offline data processing process is deleted. When a message for canceling a certain ImObject is received, the binding relationship between the ImObject and the target ImServer process is deleted. When the same ImObject comes to register again next time, a new target ImServer process is allocated. In practical applications, when it is necessary to cancel a certain ImObject, first delete the record of this ImObject on the ImServer process, and then destroy the ImObject itself. After the cancellation operation is executed, an existing ImObject cannot be found through the Id of the ImObject. It should be noted that when registering a new ImObject, it is necessary to first send a message indicating that the ImObject needs to be registered to the target ImServer process, and then forward the original message. If the order is reversed, after receiving the message, the target ImServer process determines that there is no such ImObject on the current process and discards the original message.

[0065] In one embodiment, the message forwarder is configured with a message queue, and at least one offline data to be processed is stored in the message queue. On this basis, if a feedback message for the offline data to be processed is received from the target offline data processing process, the next offline data to be processed is determined from the message queue. At this time, the next target offline data processing process bound to the next offline data to be processed can be determined from the candidate offline data processing processes, and a registration message corresponding to the next offline data to be processed is sent to the next target offline data processing process, so as to perform data processing on the next offline data to be processed through the next target offline data processing process. See Figure 5 As shown in the schematic diagram of a message queue, for each ImObject, a message queue needs to be created in the MessageSwitcher. When multiple messages need to be forwarded to a certain ImObject, these messages will be stored in the specified message queue in sequence. Only one message is sent to the ImServer process each time. When the ImServer process finishes processing the previous message, it will send a feedback to the MessageSwitcher. After receiving the feedback, the MessageSwitcher will forward the next message. This can ensure that the messages of different ImObjects do not affect each other and ensure the orderly forwarding of the messages of the same object.

[0066] In another embodiment, the embodiment of the present invention further provides an embodiment for removing the ImServer process. Specifically, see the following (1) to (4):

[0067] (1) If a process removal message sent by the main control process is received, determine the offline data processing process to be removed corresponding to the process removal message from the candidate offline data processing processes. Among them, the process removal message is generated by the main control process when it does not receive the status synchronization message of the offline data processing process to be removed within a preset duration. In practical applications, if an ImServer process becomes unresponsive, that is, the MasterServer cannot detect the heartbeat packet of the ImServer process, the ImServer process is the offline data processing process to be removed. The MasterServer will kick the ImServer out of the server process set and notify the MessageSwitcher. Exemplarily, refer to Figure 6 Another message passing schematic diagram shown in Figure. The MasterServer detects the heartbeat packet of the ImServer process 1 every 15 seconds. If the ImServer process 1 does not respond for more than 30 seconds, it is determined that the ImServer process 1 is offline and unresponsive. The MasterServer notifies the MessageSwitcher to deregister the ImServer process 1.

[0068] (2) Determine each first data structure bound to the offline data processing process to be removed. Please continue to refer to Figure 6 , after receiving the message that the ImServer has been removed, the MessageSwitcher will first find all the first ImObjects registered on the ImServer process. As shown in the figure, there are two ImObjects registered and bound to the ImServer process 1, namely ImObject (key: pid, type: Relationship) and ImObject (key: gid, type: Guild).

[0069] (3) For each first data structure bound to the offline data processing process to be removed, determine the target migration offline data processing process corresponding to the first data structure from the candidate offline data processing processes other than the offline data processing process to be removed. In one implementation, the MessageSwitcher will sequentially find a new ImServer process for each first ImObject, and the new ImServer process is the target migration offline data processing process. Please continue to refer to Figure 6 , the MessageSwitcher finds the normally running ImServer process 2 as the target migration process for ImObject (key: pid, type: Relationship); and finds the normally running ImServer process 3 as the target migration process for ImObject (key: gid, type: Guild).

[0070] (4) Send a registration message corresponding to the first data structure to the target migration offline data processing process, so as to process the offline data corresponding to the first data structure through the target migration offline data processing process. Please continue to refer to Figure 6 , MasterServer requests to register ImObject (key: pid, type: Relationship) with ImServer process 2 to migrate and bind it to ImServer process 2. Similarly, MasterServer requests to register ImObject (key: gid, type: Guild) with ImServer process 3 to migrate and bind it to ImServer process 3. In specific implementation, reference can be made to the foregoing embodiments, and the embodiments of the present invention will not be elaborated herein.

[0071] In summary, the core idea of the embodiments of the present invention lies in the following three points:

[0072] First, abstract various types of offline data into a unified ImObject object. In other game server architectures, if different types of offline data objects need to be processed, different dedicated processes will be opened. For example, a dedicated MessageServer process is started to process chat information between players; a dedicated PlayServer process is started to process a specific gameplay; a dedicated GuildServer process is opened to process all guild data. Instead of opening different processes according to the type of offline data structure, the present invention uniformly opens multiple ImServer processes, and various types of offline data structures can be processed on any one ImServer.

[0073] Second, encapsulate the registration and forwarding of ImObject. For the game business logic layer, to process an offline data object, it is necessary to first register the object on the ImServer and then process it. After the ImServer becomes a multi-process, it is necessary to first find out which ImServer the ImObject exists on, and then forward the message to the specified ImServer for processing. The present invention encapsulates the registration and forwarding of ImObject into the message forwarder (hereinafter referred to as: MessageSwitcher) in the network layer. For MessageSwitcher, it does not need to care about what type the ImObject is, nor does it care about its specific implementation method. Whenever a new ImObject message arrives, it first checks whether a corresponding ImServer has been assigned to this ImObject. If not, it looks for a relatively idle ImServer and notifies the ImServer that an ImObject is about to be registered. After notifying the registration, it then forwards the ImObject message that originally needed to be forwarded. If there is already a registration record of this ImObject in MessageSwitcher, it directly reads its corresponding ImServer and forwards this message to this ImServer.

[0074] Third, expand the ImServer process from having only one to having multiple, and support the automatic migration of ImObject. The server architecture described in the present invention pre-sets the number of ImServer processes to be opened when the server cluster starts; during the operation of the server, if it is found that the currently opened ImServer processes are too few to support the game business, new ImServer can be dynamically added to the existing server cluster; if the load of a certain ImServer is too high, or if it is kicked out of the server cluster due to certain reasons, the ImObject previously registered on it will automatically migrate to other ImServers that are still running normally.

[0075] The method for processing offline data in the game provided by the embodiments of the present invention is a general multi-process framework for offline data, which solves the problem that the original server architecture cannot process a large amount of offline data. Since various types of offline data structures can be loaded on the same ImServer, the utilization efficiency of a single ImServer is increased; since the server supports dynamically adding ImServer processes, the operation and maintenance personnel can monitor the running status of each server process in real time and adjust the number of ImServer processes in a timely manner; since the server supports the automatic migration of ImObject, even if a certain ImServer process is overloaded and unresponsive, the ImObject registered on it can continue to process the game logic after a short automatic migration is completed, without causing the player's operation of the offline system and gameplay to be unresponsive and affecting the game experience.

[0076] For game business logic developers, after encapsulating the registration and forwarding of ImObject into MessageSwitcher, developers no longer need to pay attention to when and where the ImObject is registered, but can directly forward the message that needs to operate on a certain ImObject. Since MessageSwitcher restricts that only the ImServer that has registered the object can receive the message, only one ImServer can process this ImObject, ensuring the uniqueness of the data.

[0077] In addition, for the global gameplay that exists in most online games, the original architecture either registers all global gameplay on a certain fixed server process (some architectures directly write it on the MasterServer); or opens a separate process for some particularly important global gameplay. Now, since ImServer can process all offline data objects, there is no need to separately maintain certain specific gameplay processes. As long as each global single-point system and gameplay are scattered and registered on each ImServer when starting the server. For a single ImServer, it can act as both the central control layer of the global system and gameplay and the business logic layer that receives messages from the central control layer. Compared with other practices of writing all global systems and gameplay on the MasterServer or opening a separate process, this framework reduces the pressure on the MasterServer and the corresponding separate process and enhances the portability of the system.

[0078] For the method for processing offline data in the game provided in the foregoing embodiments, the embodiments of the present invention provide a device for processing offline data in the game. The device is applied to a message forwarder in a game server, and the game server is configured with multiple candidate offline data processing processes. See Figure 7Schematic structural diagram of a device for processing offline data in a game. The device mainly includes the following parts:

[0079] A data acquisition module 702, configured to acquire offline data to be processed;

[0080] A process determination module 704, configured to determine a target offline data processing process from candidate offline data processing processes;

[0081] A message sending module 706, configured to send a registration message corresponding to the offline data to be processed to the target offline data processing process, so as to process the offline data to be processed through the target offline data processing process.

[0082] The device for processing offline data in a game provided by the embodiments of the present invention opens multiple candidate offline data processing processes in the game server, so as to disperse the offline data to each candidate offline data processing process. After the registration message corresponding to the offline data to be processed is sent to the target offline data processing process, the offline data to be processed can be processed through the target offline data processing process. Therefore, the load of a single target offline data processing process is relatively small. The embodiments of the present invention can better balance the load of the offline data processing process, effectively improve the situation that the gameplay and the system become unresponsive due to the overloaded and unresponsive offline data processing process, and thus significantly improve the game experience of players.

[0083] In one implementation manner, the process determination module 704 is further configured to: determine whether there is a data structure corresponding to the offline data to be processed in the first data structure already bound by the candidate offline data processing process; if so, determine the candidate offline data processing process bound to the data structure corresponding to the offline data to be processed as the target offline data processing process; if not, generate a second data structure corresponding to the offline data to be processed, and determine the target offline data processing process from the candidate offline data processing processes based on the first data structure already bound by each candidate offline data processing process.

[0084] In one implementation manner, the process determination module 704 is further configured to: determine the current idle state of each candidate offline data processing process based on the first data structure already bound by each candidate offline data processing process; and determine the target offline data processing process from the candidate offline data processing processes according to the current idle state.

[0085] In one implementation manner, the process determination module 704 is further configured to: determine the total amount of the structure of the first data structure already bound by each candidate offline data processing process; and determine the current idle state of each candidate offline data processing process according to the total amount of the structure corresponding to each candidate offline data processing process.

[0086] In one embodiment, the process determination module 704 is further configured to: for each candidate offline data processing process, obtain the weight parameter corresponding to each first data structure bound to the candidate offline data processing process, and calculate the total weight corresponding to the candidate offline data processing process based on the weight parameter corresponding to each first data structure; determine the current idle state of each candidate offline data processing process according to the total weight corresponding to each candidate offline data processing process.

[0087] In one embodiment, the message sending module 706 is further configured to: establish a binding relationship between the data identifier in the second data structure and the target offline data processing process; send a registration message corresponding to the offline data to be processed to the target offline data processing process based on the binding relationship, so that the target offline data processing process pulls the offline data to be processed from the data storage address corresponding to the data identifier and type in the second data structure, and processes the offline data to be processed.

[0088] In one embodiment, the above device further includes a data cancellation module, configured to: if a cancellation message for the offline data to be processed is received, delete the binding relationship between the data structure corresponding to the offline data to be processed and the target offline data processing process.

[0089] In one embodiment, the above device further includes a modification module, configured to: if a modification message for the offline data to be processed is received, send the modification message to the target offline data processing process, so that the target offline data processing process modifies the offline data to be processed based on the modification message.

[0090] In one embodiment, the message forwarder is configured with a message queue, and at least one offline data to be processed is stored in the message queue; the above device further includes a message processing module, configured to: if a feedback message for the offline data to be processed from the target offline data processing process is received, determine the next offline data to be processed from the message queue; determine the next target offline data processing process bound to the next offline data to be processed from the candidate offline data processing processes; send a registration message corresponding to the next offline data to be processed to the next target offline data processing process, so that the next target offline data processing process processes the next offline data to be processed.

[0091] In one embodiment, the game server is further configured with a main control process, and the apparatus further includes a process removal module, configured to: if receiving a process removal message sent by the main control process, determine a to-be-removed offline data processing process corresponding to the process removal message from candidate offline data processing processes; wherein, the process removal message is generated by the main control process when it does not receive a status synchronization message of the to-be-removed offline data processing process within a preset duration; determine each first data structure bound to the to-be-removed offline data processing process; for each first data structure bound to the to-be-removed offline data processing process, determine a target migrated offline data processing process corresponding to the first data structure from candidate offline data processing processes other than the to-be-removed offline data processing process; and send a registration message corresponding to the first data structure to the target migrated offline data processing process, so as to process the offline data corresponding to the first data structure through the target migrated offline data processing process.

[0092] The apparatus provided by the embodiments of the present invention has the same implementation principle and the same technical effects as those of the foregoing method embodiments. For the sake of brief description, for parts not mentioned in the apparatus embodiments, reference may be made to the corresponding contents in the foregoing method embodiments.

[0093] Embodiments of the present invention provide a server. Specifically, the server includes a processor and a storage device; a computer program is stored on the storage device, and when the computer program is run by the processor, it executes:

[0094] A method for processing offline data in a game, the method is applied to a message forwarder in a game server, the game server is configured with multiple candidate offline data processing processes, and the method includes: obtaining to-be-processed offline data; determining a target offline data processing process from candidate offline data processing processes; and sending a registration message corresponding to the to-be-processed offline data to the target offline data processing process, so as to process the to-be-processed offline data through the target offline data processing process.

[0095] In one embodiment, the step of determining a target offline data processing process from candidate offline data processing processes includes: judging whether there is a data structure corresponding to the to-be-processed offline data in the first data structures already bound by the candidate offline data processing processes; if so, determining the candidate offline data processing process bound to the data structure corresponding to the to-be-processed offline data as the target offline data processing process; if not, generating a second data structure corresponding to the to-be-processed offline data, and determining a target offline data processing process from candidate offline data processing processes based on the first data structures already bound by each candidate offline data processing process.

[0096] In one embodiment, the step of determining a target offline data processing process from candidate offline data processing processes based on the first data structure bound to each candidate offline data processing process includes: determining the current idle state of each candidate offline data processing process based on the first data structure bound to each candidate offline data processing process; and determining the target offline data processing process from the candidate offline data processing processes according to the current idle state.

[0097] In one embodiment, the step of determining the current idle state of each candidate offline data processing process based on the first data structure bound to each candidate offline data processing process includes: determining the total amount of the structure of the first data structure bound to each candidate offline data processing process; and determining the current idle state of each candidate offline data processing process according to the total amount of the structure corresponding to each candidate offline data processing process.

[0098] In one embodiment, the step of determining the current idle state of each candidate offline data processing process based on the first data structure bound to each candidate offline data processing process further includes: for each candidate offline data processing process, obtaining the weight parameter corresponding to each first data structure bound to the candidate offline data processing process, and calculating the total weight corresponding to the candidate offline data processing process based on the weight parameter corresponding to each first data structure; and determining the current idle state of each candidate offline data processing process according to the total weight corresponding to each candidate offline data processing process.

[0099] In one embodiment, the step of sending a registration message corresponding to the offline data to be processed to the target offline data processing process to perform data processing on the offline data to be processed by the target offline data processing process includes: establishing a binding relationship between the data identifier in the second data structure and the target offline data processing process; and sending a registration message corresponding to the offline data to be processed to the target offline data processing process based on the binding relationship, so that the target offline data processing process pulls the offline data to be processed from the data storage address corresponding to the data identifier and data type in the second data structure and performs data processing on the offline data to be processed.

[0100] In one embodiment, the method further includes: if a cancellation message for the offline data to be processed is received, deleting the binding relationship between the data structure corresponding to the offline data to be processed and the target offline data processing process.

[0101] In one embodiment, the method further includes: if a modification message for the offline data to be processed is received, sending the modification message to the target offline data processing process to perform modification processing on the offline data to be processed by the target offline data processing process based on the modification message.

[0102] In one embodiment, the message forwarder is configured with a message queue, and at least one piece of offline data to be processed is stored in the message queue. The method further includes: if a feedback message for the offline data to be processed is received from a target offline data processing process, determining the next piece of offline data to be processed from the message queue; determining, from candidate offline data processing processes, the next target offline data processing process bound to the next piece of offline data to be processed; and sending a registration message corresponding to the next piece of offline data to be processed to the next target offline data processing process, so as to process the offline data corresponding to the next piece of offline data to be processed through the next target offline data processing process.

[0103] In one embodiment, the game server is further configured with a main control process. The method further includes: if a process removal message sent by the main control process is received, determining the offline data processing process to be removed corresponding to the process removal message from candidate offline data processing processes; wherein the process removal message is generated by the main control process when no status synchronization message of the offline data processing process to be removed is received within a preset time period; determining each first data structure bound to the offline data processing process to be removed; for each first data structure bound to the offline data processing process to be removed, determining the target migrated offline data processing process corresponding to the first data structure from candidate offline data processing processes other than the offline data processing process to be removed; and sending a registration message corresponding to the first data structure to the target migrated offline data processing process, so as to process the offline data corresponding to the first data structure through the target migrated offline data processing process.

[0104] The server provided by the embodiment of the present invention opens multiple candidate offline data processing processes in the game server, so as to disperse the offline data to each candidate offline data processing process. After the registration message corresponding to the offline data to be processed is sent to the target offline data processing process, the target offline data processing process can process the offline data to be processed. Therefore, the load of a single target offline data processing process is relatively small. The embodiment of the present invention can better balance the load of the offline data processing process, effectively improve the situation that the system and the gameplay become unresponsive due to the over-high load of the offline data processing process and no response, and thus significantly improve the gaming experience of players.

[0105] Figure 8 FIG. 10 is a schematic structural diagram of a server provided by an embodiment of the present invention. The server 100 includes: a processor 80, a memory 81, a bus 82, and a communication interface 83. The processor 80, the communication interface 83, and the memory 81 are connected through the bus 82. The processor 80 is configured to execute an executable module stored in the memory 81, such as a computer program.

[0106] Among them, the memory 81 may include high-speed random access memory (RAM), and may also include non-volatile memory, such as at least one disk memory. The communication connection between this system network element and at least one other network element is realized through at least one communication interface 83 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used.

[0107] The bus 82 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 8 only a bidirectional arrow is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0108] Among them, the memory 81 is used to store programs. After receiving an execution instruction, the processor 80 executes the program. The methods executed by the devices defined by the flow processes disclosed in any of the foregoing embodiments of the present invention can be applied to or implemented by the processor 80.

[0109] The processor 80 may be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the above method can be completed by the integrated logic circuit in the hardware of the processor 80 or the instructions in the form of software. The above-mentioned processor 80 can be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it can also be a digital signal processor (DSP for short), an application specific integrated circuit (ASIC for short), a field-programmable gate array (FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register, etc. This storage medium is located in the memory 81, and the processor 80 reads the information in the memory 81 and combines its hardware to complete the steps of the above method.

[0110] The computer program product of the readable storage medium provided by the embodiment of the present invention includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute:

[0111] A method for processing offline data in a game. The method is applied to a message forwarder in a game server, and the game server is configured with multiple candidate offline data processing processes. The method includes: obtaining the offline data to be processed; determining a target offline data processing process from the candidate offline data processing processes; and sending a registration message corresponding to the offline data to be processed to the target offline data processing process, so as to process the offline data to be processed through the target offline data processing process.

[0112] In an implementation manner, the step of determining a target offline data processing process from the candidate offline data processing processes includes: determining whether there is a data structure corresponding to the offline data to be processed in the first data structure already bound by the candidate offline data processing process; if so, determining the candidate offline data processing process bound to the data structure corresponding to the offline data to be processed as the target offline data processing process; if not, generating a second data structure corresponding to the offline data to be processed, and determining a target offline data processing process from the candidate offline data processing processes based on the first data structure already bound by each candidate offline data processing process.

[0113] In an implementation manner, the step of determining a target offline data processing process from the candidate offline data processing processes based on the first data structure already bound by each candidate offline data processing process includes: determining the current idle state of each candidate offline data processing process based on the first data structure already bound by each candidate offline data processing process; and determining a target offline data processing process from the candidate offline data processing processes according to the current idle state.

[0114] In an implementation manner, the step of determining the current idle state of each candidate offline data processing process based on the first data structure already bound by each candidate offline data processing process includes: determining the total amount of the structure of the first data structure already bound by each candidate offline data processing process; and determining the current idle state of each candidate offline data processing process according to the total amount of the structure corresponding to each candidate offline data processing process.

[0115] In one implementation, the step of determining the current idle state of each candidate offline data processing process based on the first data structure bound to each candidate offline data processing process further includes: for each candidate offline data processing process, obtaining the weight parameter corresponding to each first data structure bound to the candidate offline data processing process, and calculating the total weight corresponding to the candidate offline data processing process based on the weight parameter corresponding to each first data structure; determining the current idle state of each candidate offline data processing process according to the total weight corresponding to each candidate offline data processing process.

[0116] In one implementation, the step of sending a registration message corresponding to the offline data to be processed to the target offline data processing process for the target offline data processing process to process the offline data to be processed includes: establishing a binding relationship between the data identifier in the second data structure and the target offline data processing process; sending a registration message corresponding to the offline data to be processed to the target offline data processing process based on the binding relationship, so that the target offline data processing process pulls the offline data to be processed from the data storage address corresponding to the data identifier and data type in the second data structure, and processes the offline data to be processed.

[0117] In one implementation, the method further includes: if a cancellation message for the offline data to be processed is received, deleting the binding relationship between the data structure corresponding to the offline data to be processed and the target offline data processing process.

[0118] In one implementation, the method further includes: if a modification message for the offline data to be processed is received, sending the modification message to the target offline data processing process for the target offline data processing process to perform a modification process on the offline data to be processed based on the modification message.

[0119] In one implementation, the message forwarder is configured with a message queue in which at least one offline data to be processed is stored; the method further includes: if a feedback message for the offline data to be processed from the target offline data processing process is received, determining the next offline data to be processed from the message queue; determining the next target offline data processing process bound to the next offline data to be processed from the candidate offline data processing processes; sending a registration message corresponding to the next offline data to be processed to the next target offline data processing process for the next target offline data processing process to process the next offline data to be processed.

[0120] In one embodiment, the game server is further configured with a main control process, and the method further includes: if a process removal message sent by the main control process is received, determining a to-be-removed offline data processing process corresponding to the process removal message from the candidate offline data processing processes; wherein, the process removal message is generated by the main control process when it does not receive a status synchronization message of the to-be-removed offline data processing process within a preset time period; determining each first data structure bound to the to-be-removed offline data processing process; for each first data structure bound to the to-be-removed offline data processing process, determining a target migration offline data processing process corresponding to the first data structure from the candidate offline data processing processes other than the to-be-removed offline data processing process; and sending a registration message corresponding to the first data structure to the target migration offline data processing process, so as to perform data processing on the offline data corresponding to the first data structure through the target migration offline data processing process.

[0121] The readable storage medium provided by the embodiments of the present invention opens multiple candidate offline data processing processes in the game server, so as to disperse the offline data to each candidate offline data processing process. After the registration message corresponding to the to-be-processed offline data is sent to the target offline data processing process, the to-be-processed offline data can be processed by the target offline data processing process. Therefore, the load of a single target offline data processing process is relatively small. The embodiments of the present invention can better balance the load of the offline data processing processes, effectively improving the situation where the system and gameplay become unresponsive due to the excessive load of the offline data processing process and no response, thereby significantly improving the player's gaming experience.

[0122] If the said function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0123] Finally, it should be noted that the above-described embodiments are only specific embodiments of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit it. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that any technician familiar with the technical field of the present invention can still modify the technical solutions described in the foregoing embodiments, or can easily think of changes, or make equivalent replacements for some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A method for processing offline data in a game, characterized in that, the method is applied to a message forwarder in a game server, the game server is configured with multiple candidate offline data processing processes, and the method includes: obtaining the offline data to be processed; judging whether there is a data structure corresponding to the offline data to be processed in the first data structure already bound by the candidate offline data processing process; if so, determining the candidate offline data processing process bound to the data structure corresponding to the offline data to be processed as the target offline data processing process; if not, generating a second data structure corresponding to the offline data to be processed, and for each candidate offline data processing process, obtaining the weight parameter corresponding to each first data structure already bound by the candidate offline data processing process, and calculating the total weight corresponding to the candidate offline data processing process based on the weight parameter corresponding to each first data structure; determining the current idle state of each candidate offline data processing process according to the total weight corresponding to each candidate offline data processing process; determining a target offline data processing process from the candidate offline data processing processes according to the current idle state; sending a registration message corresponding to the offline data to be processed to the target offline data processing process, so as to perform data processing on the offline data to be processed through the target offline data processing process.

2. The method according to claim 1, characterized in that, the step of determining the current idle state of each candidate offline data processing process based on each first data structure already bound by the candidate offline data processing process includes: determining the total amount of structures of each first data structure already bound by each candidate offline data processing process; determining the current idle state of each candidate offline data processing process according to the total amount of structures corresponding to each candidate offline data processing process.

3. The method according to claim 1, characterized in that, the step of sending a registration message corresponding to the offline data to be processed to the target offline data processing process, so as to perform data processing on the offline data to be processed through the target offline data processing process includes: establishing a binding relationship between the data identifier in the second data structure and the target offline data processing process; sending a registration message corresponding to the offline data to be processed to the target offline data processing process based on the binding relationship, so that the target offline data processing process pulls the offline data to be processed from the data storage address corresponding to the data identifier and data type in the second data structure, and performs data processing on the offline data to be processed.

4. The method according to any one of claims 1-3, characterized in that, the method further includes: if a cancellation message for the offline data to be processed is received, deleting the binding relationship between the data structure corresponding to the offline data to be processed and the target offline data processing process.

5. The method according to any one of claims 1-3, characterized in that, the method further includes: If a modification message for the to-be-processed offline data is received, send the modification message to the target offline data processing process, so that the target offline data processing process modifies the to-be-processed offline data based on the modification message.

6. The method according to any one of claims 1-3, wherein, the message forwarder is configured with a message queue, and at least one to-be-processed offline data is stored in the message queue; the method further includes: If a feedback message for the to-be-processed offline data from the target offline data processing process is received, determine the next to-be-processed offline data from the message queue; Determine the next target offline data processing process bound to the next to-be-processed offline data from the candidate offline data processing processes; Send a registration message corresponding to the next to-be-processed offline data to the next target offline data processing process, so that the next target offline data processing process processes the next to-be-processed offline data.

7. The method according to any one of claims 1-3, wherein, the game server is further configured with a main control process, and the method further includes: If a process removal message sent by the main control process is received, determine the to-be-removed offline data processing process corresponding to the process removal message from the candidate offline data processing processes; wherein, the process removal message is generated by the main control process when no status synchronization message of the to-be-removed offline data processing process is received within a preset time period; Determine each first data structure bound to the to-be-removed offline data processing process; For each of the first data structures bound to the to-be-removed offline data processing process, determine the target migration offline data processing process corresponding to the first data structure from the candidate offline data processing processes other than the to-be-removed offline data processing process; Send a registration message corresponding to the first data structure to the target migration offline data processing process, so that the target migration offline data processing process processes the offline data corresponding to the first data structure.

8. A device for processing offline data in a game, wherein, the device is applied to a message forwarder in a game server, the game server is configured with a plurality of candidate offline data processing processes, and the device includes: A data acquisition module, configured to acquire to-be-processed offline data; A process determination module, configured to determine a target offline data processing process from the candidate offline data processing processes; A message sending module, configured to send a registration message corresponding to the to-be-processed offline data to the target offline data processing process, so that the target offline data processing process processes the to-be-processed offline data. The process determination module is further configured to: determine whether there is a data structure corresponding to the offline data to be processed in the first data structure already bound to the candidate offline data processing process; if so, determine the candidate offline data processing process bound to the data structure corresponding to the offline data to be processed as the target offline data processing process; if not, generate a second data structure corresponding to the offline data to be processed, and determine the target offline data processing process from the candidate offline data processing processes based on the first data structures already bound to each candidate offline data processing process; The process determination module is further configured to: determine the current idle state of each candidate offline data processing process based on the first data structures already bound to each candidate offline data processing process; and determine the target offline data processing process from the candidate offline data processing processes according to the current idle state; The process determination module is further configured to: for each candidate offline data processing process, obtain the weight parameter corresponding to each first data structure already bound to the candidate offline data processing process, and calculate the total weight corresponding to the candidate offline data processing process based on the weight parameter corresponding to each first data structure; and determine the current idle state of each candidate offline data processing process according to the total weight corresponding to each candidate offline data processing process.

9. A server, characterized in that, it includes a processor and a memory, the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, the computer-readable storage medium stores computer executable instructions, and when the computer executable instructions are called and executed by a processor, the computer executable instructions cause the processor to implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Off-line task processing method and device, electronic equipment and storage medium

    CN110750419A