Ranking list data read-write method and device, server and storage medium

By introducing multiple ranking processes and Raft algorithm management in the game, the stability problem of single-point single-threaded processes under high load is solved, and higher business stability and traffic processing capabilities are achieved.

CN119185958APending Publication Date: 2024-12-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310773290.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-27
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

In the game, the ranking process of single-point and single-thread is prone to abnormalities when it bears high load, resulting in unstable service in the entire server ranking business. Especially when the number of users is large and the QPS is high, the process is difficult to run normally .

Method used

Multiple ranking processes are used to share the burden, and a cluster composed of multiple processes is managed using the Raft algorithm. The main process is responsible for calculating, sorting and updating the data on the entire server list, and the slave process is responsible for reading the data. Even if some processes are abnormal, other processes are Still functioning normally.

Benefits of technology

It improves the stability of the service rankings, reduces the negative impact of individual service process downtime on the business, and improves traffic processing capabilities and user data query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119185958A_ABST
    Figure CN119185958A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a ranking list data reading and writing method and device, a server and a storage medium, and relates to the technical field of data reading and writing. The method is executed by a first ranking list process in N ranking list processes, one master process and N-1 slave processes exist in the N ranking list processes, and N is an integer greater than 1; the method comprises the following steps: after a first reading request sent by a hall server is received, obtaining first list data to be obtained by the first reading request from a memory corresponding to a first ranking list process, and sending the first list data to the hall server; after a first write-in request sent by the hall server is received, under the condition that the first ranking list process is the slave process, the first write-in request is forwarded to a main process, and the main process is used for updating the full-service list data according to the first write-in request. According to the technical scheme provided by the embodiment of the invention, the stability of the full-service ranking list service can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the technical field of data reading and writing, and in particular, to a method, device, server and storage medium for reading and writing ranking data. Background Art

[0002] In some games, there are various rankings to count the ranking data of user accounts.

[0003] In related technologies, the ranking process is generally designed as a single-point single-thread, that is, the process needs to bear the pressure of reading from all server users while bearing the pressure of writing from all server users. In the above-mentioned related technologies, when the number of all server users is large, the QPS (Queries-per-second) is high, which will affect the normal operation of the process, and the ranking business of the whole server is prone to abnormalities and instability. Summary of the invention

[0004] The present application embodiment provides a method, device, server and storage medium for reading and writing ranking data, which can improve the stability of the ranking service of the whole server. The technical solution is as follows:

[0005] According to one aspect of an embodiment of the present application, a method for reading and writing ranking data is provided, the method being executed by a first ranking process among N ranking processes, wherein there is 1 master process and N-1 slave processes among the N ranking processes, and N is an integer greater than 1; the method comprising:

[0006] After receiving the first read request sent by the lobby server, obtaining the first list data to be obtained by the first read request from the memory corresponding to the first ranking process, and sending the first list data to the lobby server;

[0007] After receiving the first write request sent by the lobby server, when the first ranking process is the slave process, the first write request is forwarded to the master process, and the master process is used to update the server-wide ranking data according to the first write request.

[0008] According to one aspect of an embodiment of the present application, a device for reading and writing ranking data is provided, the device comprising:

[0009] A reading module, configured to, after receiving a first reading request sent by a lobby server, obtain first ranking data to be obtained by the first reading request from a memory corresponding to the first ranking process, and send the first ranking data to the lobby server; wherein the first ranking process is one ranking process among N ranking processes, wherein the N ranking processes include 1 master process and N-1 slave processes, and N is an integer greater than 1;

[0010] The writing module is used to forward the first writing request sent by the lobby server to the master process after receiving the first writing request when the first ranking process is the slave process, and the master process is used to update the whole server ranking data according to the first writing request.

[0011] According to one aspect of an embodiment of the present application, a server is provided, the server comprising a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above-mentioned method for reading and writing ranking data.

[0012] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the above-mentioned method for reading and writing ranking data.

[0013] According to one aspect of an embodiment of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a server reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the server executes the above-mentioned method for reading and writing ranking data.

[0014] The technical solution provided by the embodiments of the present application may have the following beneficial effects:

[0015] By setting up multiple ranking processes, multiple ranking processes share the reading and writing requests of the ranking data, thereby increasing the traffic that the whole-server ranking process can bear; and, compared with the single-point single-threaded whole-server ranking process, the embodiment of the present application uses the raft algorithm to manage a cluster composed of multiple ranking processes, and the main process is responsible for managing the calculation, sorting and updating of the whole-server ranking data, and the slave process can manage the reading of the whole-server ranking data. Even if some ranking processes are abnormal, the remaining ranking processes can still operate normally, thereby reducing the negative impact of individual service process crashes on the whole-server ranking business and improving the stability of the whole-server ranking business.

[0016] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a schematic diagram of a real-time environment of a solution provided by an embodiment of the present application;

[0018] Figure 2 is a schematic diagram of a system for reading and writing ranking data provided by an embodiment of the present application;

[0019] Figure 3 is a schematic diagram of a ranking data reading and writing system provided by another embodiment of the present application;

[0020] Figure 4 is a flowchart of a method for reading and writing ranking data provided by an embodiment of the present application;

[0021] Figure 5 is a schematic diagram of a ranking list provided by an embodiment of the present application;

[0022] Figure 6 is a schematic diagram of a ranking list provided by another embodiment of the present application;

[0023] Figure 7 is a schematic diagram of a ranking list provided by another embodiment of the present application;

[0024] Figure 8 is a schematic diagram of a ranking list provided by another embodiment of the present application;

[0025] Fig. 9 is a schematic diagram of settlement data provided by an embodiment of the present application;

[0026] Fig.10 It is an interactive flow chart of a method for reading and writing ranking data provided by an embodiment of the present application;

[0027] Fig.11 is an interactive flow chart of a method for reading and writing ranking data provided by another embodiment of the present application;

[0028] Fig.12 is an interactive flow chart of a method for reading and writing ranking data provided by another embodiment of the present application;

[0029] Fig.13 is an interactive flow chart of a method for reading and writing ranking data provided by another embodiment of the present application;

[0030] Fig.14 is an interactive flow chart of a method for reading and writing ranking data provided by another embodiment of the present application;

[0031] Fig.15is a block diagram of a device for reading and writing ranking data provided by an embodiment of the present application;

[0032] Fig.16 This is a block diagram of a server provided by an embodiment of the present application. DETAILED DESCRIPTION

[0033] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of methods consistent with some aspects of the present application as detailed in the appended claims.

[0034] Please refer to Figure 1 , which shows a schematic diagram of an implementation environment provided by an embodiment of the present application, and the implementation environment can be implemented as a reading and writing system for ranking data. Figure 1 As shown, the system 100 may include: a terminal device 11, a lobby server 12, and a server-wide ranking server 13.

[0035] The terminal device 11 has a target application installed and running, such as a client of the target application. Optionally, a user account is logged in to the client. The terminal device is an electronic device with data calculation, processing and storage capabilities. The terminal device 11 can be a smart phone, a tablet computer, a PC (Personal Computer), a wearable device, etc., which is not limited to this embodiment of the present application. The target application can be a game application, such as a shooting game application, a multiplayer gun battle survival game application, a battle royale survival game application, an LBS (Location Based Service) game application, a MOBA (Multiplayer Online Battle Arena) game application, etc., which is not limited to this embodiment of the present application. The target application can also be a social application, a payment application, a video application, a music application, a shopping application, a news application, or any other application with the function of obtaining ranking data.

[0036] A communication connection (such as a network connection) is established between the lobby server 12 and the terminal device 11, and the lobby server 12 is used to provide lobby background services for the target application. A communication connection (such as a network connection) is also established between the lobby server 12 and the server-wide ranking server 13, and the lobby server 12 is used to settle the game data or activity data generated in the target application and send the game data and / or activity data to the server-wide ranking server 13.

[0037] In some embodiments, the system 100 may also include a game server 14, which establishes a communication connection with the lobby server 12. The game server 14 is used to provide game background services for the target application and send game-related data to the lobby server 12. The lobby server 12 obtains the game data based on the settlement of the received game-related data.

[0038] A communication connection (such as a network connection) is established between the server-wide ranking server 13 and the lobby server 12. The server-wide ranking server 13 is used to, after receiving a first read request sent by the lobby server 12, obtain the first ranking data to be obtained by the first read request from the memory corresponding to the server-wide ranking server 13, and send the first ranking data to the lobby server 12. The server-wide ranking server 13 is also used to, after receiving a first write request sent by the lobby server 12, update the server-wide ranking data according to the first write request.

[0039] In some embodiments, Figure 2 As shown, the server-wide ranking server 13 includes N ranking processes, among which there is 1 master process 131 and N-1 slave processes 132, where N is an integer greater than 1. In some embodiments, if a user wants to put game data / activity data on the list, the user sends a first write request to the lobby server 12 through the client 111 in the terminal device; the lobby server 12 sends the first write request to the master process 131, or the lobby server 12 sends the first write request to the slave process 132, and then the slave process 132 forwards the first write request to the master process 131; after the master process 131 updates the server-wide ranking data according to the first write request, the updated server-wide ranking data is synchronized to the slave process 132 through broadcast.

[0040] In some embodiments, Figure 3 As shown, the server-wide ranking server 13 includes N ranking processes, among which there is 1 master process 131 and N-1 slave processes 132, where N is an integer greater than 1. In some embodiments, if a user wants to obtain first ranking data, the user sends a first read request to the lobby server 12 through the client 111 in the terminal device 11; the lobby server 12 sends the first read request to the ranking process (which can be the master process 131 or the slave process 132); the ranking process obtains the first ranking data to be obtained by the first read request from the corresponding memory, and sends the first ranking data to the lobby server 12, and the lobby server 12 then sends the first ranking data to the client 111.

[0041] In some embodiments, the server in the embodiments of the present application may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.

[0042] In the method provided in the embodiment of the present application, the execution subject of each step may be a ranking process in the server-wide ranking server 13, such as a master process or any slave process.

[0043] The technical solution of the present application is introduced and explained below through several embodiments.

[0044] Please refer to Figure 4 , which shows a flow chart of a method for reading and writing ranking data provided by an embodiment of the present application. In this embodiment, the method is applied to the ranking process introduced above as an example. In some embodiments, the method is executed by the first ranking process among N ranking processes, and there is 1 master process and N-1 slave processes in the N ranking processes, where N is an integer greater than 1. The method may include the following steps:

[0045] Step 410, after receiving the first read request sent by the lobby server, obtain the first list data to be obtained by the first read request from the memory corresponding to the first ranking process, and send the first list data to the lobby server.

[0046] In some embodiments, if a user wants to obtain list data of a certain ranking list, such as the first list data, the user can send a first read request to the lobby server through the client; the lobby server then forwards the first read request to the first ranking process; after receiving the first read request, the first ranking process obtains the first list data to be obtained by the first read request from the memory corresponding to the first ranking process, and sends the first list data to the lobby server; the lobby server then forwards the first list data to the client.

[0047] In some embodiments, the first ranking process can be a master process or a slave process. That is, whether it is a master process or a slave process, the list data corresponding to the read request can be obtained from the corresponding memory. In an embodiment of the present application, the Raft algorithm is used to build a cluster containing N ranking processes, in which the master process can also be called a leader and the slave process can also be called a follower. The Raft algorithm is a consensus algorithm proposed from the perspective of a multi-copy state machine for managing the state replication of a multi-copy state machine. The cluster runtime includes the leader election (i.e., the election of the master process) state and the log replication (i.e., data synchronization) state.

[0048] In some embodiments, the first list data may be as follows: Figure 5The list data of the rank ranking list 15 shown, the rank ranking list 15 is a ranking list used to sort the ranks of users in the entire server or a certain server from high to low.

[0049] In some embodiments, the first list data may be as follows: Figure 6 The list data of the hot ranking list 16 shown in the figure is a ranking list for sorting the ranks of users in the entire server or a certain server from high to low. In some embodiments, for a first client logged in with a first user account, the hot ranking list 16 obtained by it can also be a ranking list obtained by statistically sorting the ranks of the first user account and the friend accounts of the first user account from high to low.

[0050] In some embodiments, the popularity ranking list 16 refers to a ranking list obtained based on the popularity data statistics in the most recent first period. For example, the popularity ranking list 16 can be a popularity ranking list within a day, a popularity ranking list within a week, a popularity ranking list within a month, or a popularity ranking list within a year, which is not specifically limited in the embodiments of the present application.

[0051] In some embodiments, for a game application of the business dress-up type, the first list data may be as follows: Figure 7 The list data of the prosperity ranking list 17 shown, such as the prosperity of the house, garden, manor or farm that the user wants to manage and decorate.

[0052] In some embodiments, based on the photos taken by the user in the game, the following may also be generated: Figure 8 The photography ranking list 18 is shown. The higher the user account ranks in the photography ranking list 18, the more popular the photos taken by the user in the game are among other users.

[0053] In some embodiments, for a first client logged in with a first user account, the first list data obtained by it can be obtained based on data statistics of user accounts of the entire server or the entire region, that is, by sorting user accounts of the entire server or the entire region; the statistical data range of the first list data may also only include data of the first user account and the friend accounts of the first user account, that is, only the first user account and the friend accounts of the first user account are sorted to obtain the first list data corresponding to the first user account.

[0054] In some embodiments, Fig. 9As shown, after a game is over, the users who participated in the game and / or the spectator users of the game (i.e., users who only watched the game but did not participate in the game) can obtain the settlement data table 19 of the game, and the settlement data table 19 of the game is used to count the game data of each user who participated in the game. In some embodiments, the user who participated in the game can request to upload the data obtained from the settlement of the game to the server-wide ranking server to request to participate in the ranking of the server-wide ranking.

[0055] In some embodiments, Fig.10 As shown, when the user corresponding to the client requests to view the first list data, the following steps are included (1010-1040):

[0056] Step 1010: The client sends a first read request to the lobby server, where the first read request is used to request to obtain first list data;

[0057] Step 1020: the lobby server forwards the first read request to the first ranking process, which may be a master process or a slave process;

[0058] Step 1030, the first ranking process sends the first ranking data to the lobby server;

[0059] Step 1040: The lobby server sends the first list data to the client.

[0060] Step 420, after receiving the first write request sent by the lobby server, if the first ranking process is a slave process, forward the first write request to the master process, and the master process is used to update the server-wide ranking data according to the first write request.

[0061] In some embodiments, the client sends a ranking request to the lobby server, and the ranking request is used to request the user account corresponding to the client to request to participate in the ranking competition of the ranking list and update the server-wide ranking data based on its latest game data; the lobby server generates a first write request based on the ranking request and the latest game data of the user account, and sends the first write request to the first ranking process; since the slave process does not have the authority to sort and update the server-wide ranking data, when the first ranking process is a slave process, it is necessary to forward the first write request to the master process, and then the master process updates the server-wide ranking data. In some embodiments, the master process synchronizes the updated server-wide ranking data to the slave process.

[0062] In some embodiments, the business data of the user account corresponding to the client carried by the above-mentioned first write request may be game data, that is, data obtained based on the user's performance in the game, such as the number of users defeated by the user account in the game, the resources obtained, the total time used to complete a task in the game, etc.

[0063] In some embodiments, the above-mentioned business data may also be activity data, that is, data obtained after settlement of non-game type activities completed by users, such as the number of consecutive days of user sign-in, the number of new users attracted by users in new user activities, the quality and quantity of virtual props produced by users in target applications, etc. The embodiments of the present application do not make specific limitations on this.

[0064] In some embodiments, when the service data carried by the first write request is peer data, such as Fig.11 As shown, the method includes the following steps (1101-1108):

[0065] Step 1101, the client requests the lobby server to enter a game;

[0066] Step 1102, the user account corresponding to the client enters the game in the game server;

[0067] Step 1103, after the game is finished, the game server sends all relevant data in the game to the lobby server for settlement, and the lobby server settles and obtains the game data of the game;

[0068] Step 1104, the lobby server sends a first write request to the slave process;

[0069] Step 1105, the slave process forwards the first write request to the master process;

[0070] Step 1106, the main process updates the server-wide list data based on the first write request;

[0071] Step 1107, the master process synchronizes the updated server-wide list data to the slave process by broadcasting.

[0072] In some embodiments, Fig.12 As shown, the above steps 1104 to 1105 can be replaced by the following step 1108:

[0073] Step 1108, the lobby server sends a first write request to the main process.

[0074] In some embodiments, when the service data carried by the first write request is active data, such as Fig.13 As shown, the method includes the following steps (1301-1307):

[0075] Step 1301, the user account corresponding to the client completes the activity through the lobby server;

[0076] Step 1302, after the activity is completed, the lobby server settles the activity data based on the activity completion status of the user account;

[0077] Step 1303, the lobby server sends a first write request to the slave process;

[0078] Step 1304, the slave process forwards the first write request to the master process;

[0079] Step 1305: the main process updates the server-wide list data based on the first write request;

[0080] Step 1306: The master process synchronizes the updated server-wide ranking data to the slave process by broadcasting.

[0081] In some embodiments, Fig.14 As shown, the above steps 1303 to 1304 can be replaced by the following step 1307:

[0082] Step 1307, the lobby server sends a first write request to the main process.

[0083] To sum up, the technical solution provided by the embodiment of the present application, by setting up multiple ranking processes, multiple ranking processes share the reading and writing requests of the ranking data, thereby increasing the traffic that the whole server ranking process can bear; and, compared with the single-point single-threaded whole server ranking process, the embodiment of the present application uses the raft algorithm to manage the cluster composed of multiple ranking processes, and the main process is responsible for managing the calculation, sorting and updating of the whole server ranking data, and the slave process can manage the reading of the whole server ranking data. Even if some ranking processes are abnormal, the remaining ranking processes can still operate normally, thereby reducing the negative impact of individual service process crashes on the whole server ranking business and improving the stability of the whole server ranking business.

[0084] In some possible implementations, after forwarding the first write request to the main process, the following steps are further included:

[0085] 1. Receive the first synchronization message sent by the master process. The first synchronization message is sent by the master process to each slave process. The first synchronization message is used to synchronize the updated full-server list data;

[0086] 2. According to the first synchronization message, the server-wide ranking data stored in the memory corresponding to the first ranking process is updated.

[0087] In some embodiments, after obtaining the updated all-server ranking data, the master process stores the updated all-server ranking data in the inner village corresponding to the master process. In some embodiments, the master process also stores the updated all-server ranking data in a database, and the master process and each slave process have the authority to query the database, but compared with querying the all-server ranking data from the inner village corresponding to the ranking process, querying the database will be relatively time-consuming and inefficient.

[0088] In some embodiments, the master process synchronizes updated server-wide list data to each slave process via broadcasting.

[0089] In the above implementation, by updating the server-wide ranking data in each ranking process in real time, the master process and each slave process can provide the latest server-wide ranking data to the client, thereby improving the efficiency of users querying server-wide ranking data when there is a lot of user data.

[0090] In some possible implementations, when the first ranking process is the main process, the server-wide ranking data is updated according to the first write request.

[0091] In some embodiments, the master process has not only all the functions of the slave process, but also functions that the slave process does not have, that is, only the master process can update the server-wide ranking data. Then, if the first ranking process is the master process, the first ranking process can directly update the server-wide ranking data according to the first write request.

[0092] In some embodiments, after the server-wide list data is updated according to the first write request, a second synchronization message is sent to each slave process, and the second synchronization message is used to synchronize the updated server-wide list data; wherein the slave process is used to update the server-wide list data stored in the memory corresponding to the slave process according to the second synchronization message.

[0093] In some embodiments, each ranking process has a corresponding memory space, in which the server-wide ranking data is stored, and the server-wide ranking data is continuously updated.

[0094] In some embodiments, after sending the second synchronization message to each slave process, the following steps are also included:

[0095] 1. Receive the confirmation message sent by the slave process, which is used to indicate that the slave process has successfully completed the update of the server-wide list data stored in its own memory;

[0096] 2. When the number of confirmation messages received is less than or equal to the threshold, resend the second synchronization message to at least one target slave process, where the target slave process refers to a slave process that has not successfully completed the update of the server-wide list data stored in its own memory.

[0097] In some embodiments, when the first ranking process is the master process, a confirmation message sent by a slave process is received. If the number of received confirmation messages is less than or equal to a threshold, it indicates that the number of slave processes that have received the updated server-wide ranking data is small. Therefore, it is necessary to resend a second synchronization message to at least one target slave process, i.e., synchronize the updated server-wide ranking data again, to ensure that a larger number of slave processes can receive the updated server-wide ranking data, thereby ensuring the accuracy and timeliness of the server-wide ranking data queried by users.

[0098] In some embodiments, only updates to critical server-wide chart data require receiving confirmation messages sent by the slave process; for non-critical server-wide chart data, the master process only broadcasts once, and the slave process does not need to send a confirmation message to the master process.

[0099] In the above implementation, the first ranking process is the main process, so there is no need to forward the first write request, thereby improving the update efficiency of the server-wide ranking data.

[0100] In some possible implementations, the method may further include the following steps:

[0101] 1. When the first ranking process is a slave process, if the first ranking process does not receive a heartbeat message from the master process for a first period of time, a first voting request is sent to each other slave process, and the first voting request is used to request that the first ranking process be determined as the master process;

[0102] 2. Receive the first voting result sent by other slave processes, where the first voting result is used to indicate whether to agree or disagree to determine the first ranking process as the master process;

[0103] 3. When the number of first voting results that agree to determine the first ranking process as the master process meets the first condition, the first ranking process is determined to be changed from a slave process to a master process.

[0104] In some embodiments, the master process needs to send a heartbeat message to each slave process at a preset interval to indicate that the master process is running normally. In the case where the first ranking process is a slave process, if the first ranking process does not receive a heartbeat message from the master process for more than a first period of time, it means that the master process is likely to not run normally, and it is necessary to re-elect a master process from the N ranking processes to ensure the normal operation of the ranking business of the entire server. In some embodiments, if the first ranking process is a slave process, it can cast a vote of approval for itself and request other slave processes to vote for itself.

[0105] In some embodiments, N is an odd number, and the first condition includes that the number is greater than or equal to (N+1) / 2, thereby ensuring that the new main process is supported by the majority of leaderboard processes.

[0106] In some embodiments, the method may further include the following steps:

[0107] 1. If the first ranking process does not receive a heartbeat message from the main process for more than the first duration, a first interval duration is randomly generated;

[0108] 2. After the first interval duration is reached, execute the step of sending the first voting request to each other slave process.

[0109] In some embodiments, in some embodiments, the interval durations corresponding to different slave processes are randomly generated and are likely to be different, thereby greatly reducing the probability of two slave processes sending voting requests to other slave processes at the same time, and ensuring as much as possible that only one or a few slave processes participate in the competition for electing the master process each time, thereby reducing the number of times each slave process needs to vote and improving election efficiency.

[0110] In some embodiments, after the first interval duration is randomly generated, if a heartbeat message is received from a second ranking process during the first interval duration, the second ranking process is determined to be the main process; wherein the second ranking process is any one of the N ranking processes.

[0111] In some embodiments, during the first interval, if a heartbeat message is received from the second ranking process, indicating that a new master process has been elected in this round, the first ranking process will not participate in the competition for electing the master process in this round, thereby reducing the number of votes required by each slave process and improving election efficiency.

[0112] In the above implementation, if the slave process does not receive a heartbeat message from the master process for more than the first period of time, a new master process is elected, thereby minimizing the impact of the abnormal operation of the master process on the server-wide ranking business and ensuring the operational stability of the server-wide ranking business as much as possible.

[0113] In some possible implementations, the method may further include the following steps:

[0114] 1. Receive a second voting request from a third ranking process, where the second voting request is used to request that the third ranking process be determined as a master process; wherein the third ranking process is any slave process among the N ranking processes;

[0115] 2. If the second voting request is the first voting request received by the first leaderboard process in the current round of master process election, a second voting result indicating that the third leaderboard process is agreed to be determined as the master process is sent to the third leaderboard process;

[0116] 3. If other voting requests have been received in the current round of master process election before the second voting request is received, the second voting result indicating disagreement with determining the third leaderboard process as the master process is sent to the third leaderboard process;

[0117] Wherein, when the number of second voting results agreeing to determine the third ranking process as the master process satisfies the first condition, the third ranking process is changed from a slave process to a master process.

[0118] In some embodiments, N is an odd number greater than one.

[0119] In some embodiments, during each round of master process election, a slave process can only cast an affirmative vote for one ranking process, thereby ensuring one person one vote in each round, thereby ensuring as much as possible that the slave process with the shortest time interval corresponding to this round can be elected as the master process.

[0120] In the above implementation, N is an odd number greater than 1, and under the one-person-one-vote system, the probability of two processes having a tie is reduced as much as possible, thereby improving the efficiency of electing the main process.

[0121] In some embodiments, the pseudo code for electing the server-wide ranking process using the raft algorithm is as follows:

[0122]

[0123]

[0124] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0125] Please refer to Fig.15 , which shows a block diagram of a device for reading and writing ranking data provided by an embodiment of the present application. The device has the function of implementing the method example of reading and writing the above-mentioned ranking data, and the function can be implemented by hardware, or by hardware executing corresponding software. The device can be the full-server ranking server introduced above, and can also be set on the full-server ranking server. The device 1500 may include: a reading module 1510 and a writing module 1520.

[0126] The reading module 1510 is used to obtain the first list data to be obtained by the first reading request from the memory corresponding to the first ranking process after receiving the first reading request sent by the lobby server, and send the first list data to the lobby server; wherein, the first ranking process is a ranking process among N ranking processes, and there are 1 main process and N-1 slave processes among the N ranking processes, and N is an integer greater than 1.

[0127] The writing module 1520 is used for forwarding the first writing request sent by the lobby server to the master process after receiving the first writing request when the first ranking process is the slave process, and the master process is used for updating the whole server ranking data according to the first writing request.

[0128] In some embodiments, the apparatus 1500 further includes:

[0129] The receiving module is used to receive a first synchronization message sent by the master process, wherein the first synchronization message is sent by the master process to each of the slave processes, and the first synchronization message is used to synchronize the updated server-wide list data.

[0130] An updating module is used to update the server-wide ranking data stored in the memory corresponding to the first ranking process according to the first synchronization message.

[0131] In some embodiments, the update module is further used to update the server-wide ranking data according to the first write request when the first ranking process is the main process.

[0132] In some embodiments, the apparatus 1500 further includes:

[0133] A synchronization module is used to send a second synchronization message to each of the slave processes, wherein the second synchronization message is used to synchronize the updated server-wide list data; wherein the slave process is used to update the server-wide list data stored in the memory corresponding to the slave process according to the second synchronization message.

[0134] In some embodiments, the receiving module is further used to receive a confirmation message sent by the slave process, and the confirmation message is used to indicate that the slave process has successfully completed the update of the full-server list data stored in its own memory.

[0135] A sending module is used to resend the second synchronization message to at least one target slave process when the number of the received confirmation messages is less than or equal to a threshold. The target slave process refers to a slave process that has not successfully completed the update of the full-server list data stored in its own memory.

[0136] In some embodiments, the device 1500 further includes: a process determination module.

[0137] The sending module is further configured to, when the first ranking process is the slave process, send a first voting request to each other slave process if the first ranking process does not receive a heartbeat message from the master process for a first period of time, wherein the first voting request is used to request that the first ranking process be determined as the master process.

[0138] The receiving module is further configured to receive a first voting result sent by the other slave processes, where the first voting result is used to indicate whether or not to agree to determine the first ranking process as the master process.

[0139] The process determination module is configured to determine that the first ranking process is changed from the slave process to the master process when the number of the first voting results agreeing to determine the first ranking process as the master process satisfies a first condition.

[0140] In some embodiments, the apparatus 1500 further includes:

[0141] The duration generation module is used to randomly generate a first interval duration if the first ranking process does not receive a heartbeat message from the main process for more than a first duration.

[0142] The sending module is further configured to execute the step of sending the first voting request to each other slave process after the first interval duration is reached.

[0143] In some embodiments, the process determination module is further configured to determine that a second ranking process is the main process if a heartbeat message is received from the second ranking process during the first interval; wherein the second ranking process is any one of the N ranking processes.

[0144] In some embodiments, N is an odd number, and the first condition includes that the number is greater than or equal to (N+1) / 2.

[0145] In some embodiments, the apparatus 1500 further includes:

[0146] The receiving module is further used to receive a second voting request from a third ranking process, wherein the second voting request is used to request that the third ranking process be determined as the master process; wherein the third ranking process is any slave process among the N ranking processes.

[0147] The sending module is further configured to send a second voting result indicating agreement to determine the third ranking process as the master process to the third ranking process if the second voting request is the first voting request received by the first ranking process in this round of master process election.

[0148] The sending module is further configured to send a second voting result indicating disagreement with determining the third ranking process as the master process to the third ranking process if other voting requests have been received in the current round of master process election before receiving the second voting request; wherein, when the number of the second voting results agreeing to determine the third ranking process as the master process meets the first condition, the third ranking process changes from the slave process to the master process.

[0149] To sum up, the technical solution provided by the embodiment of the present application, by setting up multiple ranking processes, multiple ranking processes share the reading and writing requests of the ranking data, thereby increasing the traffic that the whole server ranking process can bear; and, compared with the single-point single-threaded whole server ranking process, the embodiment of the present application uses the raft algorithm to manage the cluster composed of multiple ranking processes, and the main process is responsible for managing the calculation, sorting and updating of the whole server ranking data, and the slave process can manage the reading of the whole server ranking data. Even if some ranking processes are abnormal, the remaining ranking processes can still operate normally, thereby reducing the negative impact of individual service process crashes on the whole server ranking business and improving the stability of the whole server ranking business.

[0150] It should be noted that the device provided in the above embodiment, when implementing its functions, only uses the division of the above functional modules as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment are of the same concept, and their specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0151] Please refer to Fig.16 , which shows a structural block diagram of a server provided in one embodiment of the present application. The server is used to implement the reading and writing method of the ranking data provided in the above embodiment. Specifically:

[0152] The server 1600 includes a CPU (Central Processing Unit) 1601, a system memory 1604 including a RAM (Random Access Memory) 1602 and a ROM (Read-Only Memory) 1603, and a system bus 1605 connecting the system memory 1604 and the central processing unit 1601. The server 1600 also includes a basic I / O (Input / Output) system 1606 for facilitating information transmission between various components in the computer, and a large-capacity storage device 1607 for storing an operating system 1613, application programs 1614, and other program modules 1615.

[0153] The basic input / output system 1606 includes a display 1608 for displaying information and an input device 1609 such as a mouse and a keyboard for user inputting information. The display 1608 and the input device 1609 are connected to the central processing unit 1601 through an input / output controller 1610 connected to the system bus 1605. The basic input / output system 1606 may also include an input / output controller 1610 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 1610 also provides output to a display screen, a printer, or other types of output devices.

[0154] The mass storage device 1607 is connected to the central processing unit 1601 via a mass storage controller (not shown) connected to the system bus 1605. The mass storage device 1607 and its associated computer-readable medium provide non-volatile storage for the server 1600. That is, the mass storage device 1607 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.

[0155] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read Only Memory), EEPROM (Electrically Erasable Programmable Read Only Memory), flash memory or other solid-state memory, CD-ROM, DVD (Digital Video Disc) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage media is not limited to the above. The above-mentioned system memory 1604 and mass storage device 1607 can be collectively referred to as memory.

[0156] According to various embodiments of the present application, the server 1600 may also be connected to a remote computer on a network through a network such as the Internet. That is, the server 1600 may be connected to a network 1612 through a network interface unit 1611 connected to the system bus 1605, or the network interface unit 1611 may be used to connect to other types of networks or remote computer systems (not shown).

[0157] In an exemplary embodiment, a computer-readable storage medium is further provided, wherein a computer program is stored in the storage medium, and when the computer program is executed by a processor, the computer program is used to implement the above-mentioned method for reading and writing ranking data.

[0158] Optionally, the computer readable storage medium may include: ROM (Read-Only Memory), RAM (Random-Access Memory), SSD (Solid State Drives) or optical disks, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).

[0159] In an exemplary embodiment, a computer program product is also provided, the computer program product includes a computer program, the computer program is stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned ranking data reading and writing method.

[0160] It should be noted that before collecting relevant data of users and during the process of collecting relevant data of users, this application can display a prompt interface, pop-up window or output voice prompt information, and the prompt interface, pop-up window or voice prompt information is used to prompt the user that its relevant data is currently being collected, so that this application only starts to execute the relevant steps of obtaining relevant data of users after obtaining the confirmation operation issued by the user to the prompt interface or pop-up window, otherwise (that is, when the confirmation operation issued by the user to the prompt interface or pop-up window is not obtained), the relevant steps of obtaining relevant data of users are terminated, that is, the relevant data of users are not obtained. In other words, all user data collected by this application are collected with the consent and authorization of the user, and the collection, use and processing of relevant user data need to comply with the relevant laws, regulations and standards of relevant countries and regions.

[0161] It should be understood that the "plurality" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0162] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for reading and writing ranking data, characterized in that: The method is executed by the first ranking process among N ranking processes, wherein there is 1 master process and N-1 slave processes among the N ranking processes, and N is an integer greater than 1; the method comprises: After receiving the first read request sent by the lobby server, obtaining the first list data to be obtained by the first read request from the memory corresponding to the first ranking process, and sending the first list data to the lobby server; After receiving the first write request sent by the lobby server, when the first ranking process is the slave process, the first write request is forwarded to the master process, and the master process is used to update the server-wide ranking data according to the first write request.

2. The method according to claim 1, characterized in that After forwarding the first write request to the main process, the method further includes: Receiving a first synchronization message sent by the master process, the first synchronization message being sent by the master process to each of the slave processes, the first synchronization message being used to synchronize updated server-wide list data; According to the first synchronization message, the server-wide ranking data stored in the memory corresponding to the first ranking process is updated.

3. The method according to claim 1, characterized in that The method further comprises: When the first ranking process is the main process, the server-wide ranking data is updated according to the first write request.

4. The method according to claim 3, characterized in that After the updating of the server-wide list data according to the first write request, the method further includes: A second synchronization message is sent to each of the slave processes, where the second synchronization message is used to synchronize the updated server-wide list data; wherein the slave process is used to update the server-wide list data stored in the memory corresponding to the slave process according to the second synchronization message.

5. The method according to claim 4, characterized in that After sending the second synchronization message to each of the slave processes, the method further includes: Receive a confirmation message sent by the slave process, where the confirmation message is used to indicate that the slave process has successfully completed the update of the server-wide list data stored in its own memory; When the number of the confirmation messages received is less than or equal to a threshold, the second synchronization message is resent to at least one target slave process, where the target slave process refers to a slave process that has not successfully completed the update of the server-wide list data stored in its own memory.

6. The method according to claim 1, characterized in that The method further comprises: In the case where the first ranking process is the slave process, if the first ranking process does not receive a heartbeat message from the master process for more than a first period of time, a first voting request is sent to each other slave process, where the first voting request is used to request that the first ranking process be determined as the master process; receiving a first voting result sent by the other slave processes, where the first voting result is used to indicate whether to agree or disagree to determine the first ranking process as the master process; When the number of the first voting results agreeing to determine the first leaderboard process as the master process satisfies a first condition, it is determined that the first leaderboard process is changed from the slave process to the master process.

7. The method according to claim 6, characterized in that The method further comprises: If the first ranking process does not receive a heartbeat message from the main process for more than a first time period, a first interval time period is randomly generated; After the first interval duration is reached, the step of sending the first voting request to each other slave process is performed.

8. The method according to claim 7, characterized in that After randomly generating the first interval duration, the method further includes: During the first interval, if a heartbeat message is received from a second ranking process, the second ranking process is determined to be the main process; wherein the second ranking process is any one of the N ranking processes.

9. The method according to claim 6, characterized in that The N is an odd number, and the first condition includes that the number is greater than or equal to (N+1) / 2.

10. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: receiving a second voting request from a third ranking process, wherein the second voting request is used to request that the third ranking process be determined as the master process; wherein the third ranking process is any slave process among the N ranking processes; If the second voting request is the first voting request received by the first leaderboard process in the current round of master process election, sending a second voting result indicating agreement to determine the third leaderboard process as the master process to the third leaderboard process to the third leaderboard process; If other voting requests have been received in the current round of master process election before receiving the second voting request, sending a second voting result indicating disagreement with determining the third leaderboard process as the master process to the third leaderboard process; Wherein, when the number of the second voting results that agree to determine the third ranking process as the master process satisfies a first condition, the third ranking process is changed from the slave process to the master process.

11. A device for reading and writing ranking data, characterized in that: The device comprises: A reading module, configured to, after receiving a first reading request sent by a lobby server, obtain first ranking data to be obtained by the first reading request from a memory corresponding to the first ranking process, and send the first ranking data to the lobby server; wherein the first ranking process is one ranking process among N ranking processes, wherein the N ranking processes include 1 master process and N-1 slave processes, and N is an integer greater than 1; The writing module is used to forward the first writing request sent by the lobby server to the master process after receiving the first writing request when the first ranking process is the slave process, and the master process is used to update the whole server ranking data according to the first writing request.

12. A server, characterized in that: The server includes a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the method for reading and writing ranking data as described in any one of claims 1 to 10 above.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is loaded and executed by a processor to implement the method for reading and writing ranking data as described in any one of claims 1 to 10 above.