Nothing Special   »   [go: up one dir, main page]

CN109173270B - Game service system and implementation method - Google Patents

Game service system and implementation method Download PDF

Info

Publication number
CN109173270B
CN109173270B CN201811037918.8A CN201811037918A CN109173270B CN 109173270 B CN109173270 B CN 109173270B CN 201811037918 A CN201811037918 A CN 201811037918A CN 109173270 B CN109173270 B CN 109173270B
Authority
CN
China
Prior art keywords
service
layer
request
data
game
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811037918.8A
Other languages
Chinese (zh)
Other versions
CN109173270A (en
Inventor
邹靖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201811037918.8A priority Critical patent/CN109173270B/en
Publication of CN109173270A publication Critical patent/CN109173270A/en
Application granted granted Critical
Publication of CN109173270B publication Critical patent/CN109173270B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/70Game security or game management aspects
    • A63F13/79Game security or game management aspects involving player-related data, e.g. identities, accounts, preferences or play histories
    • A63F13/795Game security or game management aspects involving player-related data, e.g. identities, accounts, preferences or play histories for finding other players; for building a team; for providing a buddy list
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/30Interconnection arrangements between game servers and game devices; Interconnection arrangements between game devices; Interconnection arrangements between game servers
    • A63F13/35Details of game servers
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/50Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers
    • A63F2300/51Server architecture
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/50Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by details of game servers
    • A63F2300/55Details of game data or player data management
    • A63F2300/5546Details of game data or player data management using player registration data, e.g. identification, account, preferences, game history
    • A63F2300/556Player lists, e.g. online players, buddy list, black list

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • General Business, Economics & Management (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention provides a game service system and an implementation method, wherein the system comprises: logging in a server; the service logic layer comprises a plurality of service modules which are respectively connected with the login server, the client and the registration center layer; the registration center layer comprises a plurality of registration modules and is connected with the basic service layer; the basic service layer comprises a plurality of service modules and is connected with the data storage layer; the data storage layer comprises a plurality of storage modules and is connected with the storage medium layer; a storage medium layer, including a storage medium. Because each layer comprises a plurality of independent functional modules which form distributed connection to form a distributed system, each layer is responsible for different business data processing, on one hand, even if one module in each layer is down, other modules in the layer can carry out corresponding business processing, the operation of the whole game service system cannot be influenced, and on the other hand, the modules in each layer are mutually independent, and the mashup degree among the layers and the development difficulty of the system are reduced.

Description

Game service system and implementation method
Technical Field
The invention relates to the technical field of service system architecture, in particular to a game service system and an implementation method of the game service system.
Background
With the network technology, games are also changed from stand-alone games to network games, and the network games become the mainstream of the game industry.
An existing network game needs to be supported by a game service system, such as the game service system shown in fig. 1, which mainly includes a scene server, a group server, a friend server, a storage server, and so on, in fig. 1, the corresponding services of the game are centralized in one server for processing, for example, data related to friend services of players in the game are centralized in the friend server for processing, and data related to group services are centralized in the group server for processing, so that different servers need to be set for different services, and the servers are connected with each other.
Disclosure of Invention
In view of the above problems, a game service system and an implementation method of a game service system according to embodiments of the present invention are provided to solve the problems of service convergence and high mashup in a game service system.
In order to solve the above problem, an embodiment of the present invention discloses a game service system, including:
the login server is used for enabling the player to log in the game when the login service request is received;
the service logic layer comprises a plurality of service modules which are respectively connected with the login server, the client and the registration center layer and are used for receiving a login service request and a game service request of the client, sending the login service request to the login server and sending the game service request to the registration center layer;
the registration center layer comprises a plurality of registration modules, is connected with the basic service layer and is used for registering a calling interface of the basic service layer and sending the game service request to the basic service layer through the calling interface;
the basic service layer comprises a plurality of service modules, is connected with the data storage layer and is used for sending a data reading request to the data storage layer according to the game service request, processing the read data to obtain a data processing result, returning the data processing result to the client and sending a storage request aiming at the data processing result to the data storage layer;
the data storage layer comprises a plurality of storage modules, is connected with the storage medium layer and is used for processing the data reading request and the storage request aiming at the data processing result;
and a storage medium layer including a storage medium for storing data.
Optionally, the basic service layer is further configured to:
and sending a calling interface registration request of each service module to the registration center layer after starting up, wherein the calling interface registration request is used for indicating each registration module of the registration center layer to register a calling interface for each service module.
Optionally, when the registration center layer sends the game service request to the basic service layer through the call interface, the registration center layer is further configured to:
acquiring load information of a plurality of service modules of the basic service layer;
determining a target service module according to the load information;
and sending the game service request to the target service module through a calling interface of the target service module.
Optionally, when the basic service layer sends a data reading request to the data storage layer according to the game service request and processes the read data to obtain a data processing result, the basic service layer is further configured to:
and synchronizing the data of each service module by adopting a preset algorithm.
Optionally, when the basic service layer synchronizes data of each service module by using a preset algorithm, the basic service layer is further configured to:
judging whether a service module corresponding to the game service request is a non-reentrant service;
and if so, synchronizing the data of the service module of the non-reentrant service by adopting a Raft algorithm.
Optionally, when the basic service layer synchronizes data of the service module of the non-reentrant service by using a Raft algorithm, the basic service layer is further configured to:
determining a leader and a plurality of followers in a service module of a non-reentrant service;
processing the game service request through the leader to obtain a data processing result;
the leader broadcasts the data processing results to the plurality of followers;
and when the followers with the number exceeding the preset number receive the data processing results for synchronization, the leader returns the data processing results to the client.
Optionally, the calling interface of each service module includes a first parameter and a second parameter, where the first parameter is used to determine whether to wait for the data processing result to be completed synchronously, and the second parameter is used to determine whether to broadcast the request of the calling interface to the multiple followers.
Optionally, the storage medium includes a relational database and a non-relational database.
Optionally, the registry layer is further configured to:
and when receiving the service closing of the specified type, stopping registering the calling interface of the basic service layer for the specified type of service.
In order to solve the above problem, an embodiment of the present invention discloses an implementation method of a game service system, including:
configuring a login server, wherein the login server enables a player to log in a game when receiving a login service request;
configuring a service logic layer comprising a plurality of service modules, wherein the service logic layer is respectively connected with the login server and the registration center layer, receives a login service request and a game service request of a client, sends the login service request to the login server and sends the game service request to the registration center layer;
configuring a registration center layer comprising a plurality of registration modules, wherein the registration center layer is connected with a basic service layer, registers a calling interface of the basic service layer, and sends the game service request to the basic service layer through the calling interface;
configuring a basic service layer comprising a plurality of service modules, wherein the basic service layer is connected with a data storage layer, the basic service layer sends a data reading request to the data storage layer according to the game service request and processes the read data to obtain a data processing result, and returns the data processing result to the client and sends a storage request aiming at the data processing result to the data storage layer;
configuring a data storage layer comprising a plurality of storage modules, wherein the data storage layer is connected with a storage medium layer and processes the data reading request and the storage request aiming at the data processing result;
a storage medium layer is configured to include a storage medium for storing data.
Optionally, configuring a basic service layer including a plurality of service modules includes:
and configuring the basic service layer to send a calling interface registration request of each service module to the registration center layer after starting up, wherein the calling interface registration request is used for indicating each registration module of the registration center layer to register a calling interface for each service module.
Optionally, configuring a registration center layer including a plurality of registration modules includes:
configuring the registration center layer to acquire load information of a plurality of service modules of the basic service layer; determining a target service module according to the load information; and sending the game service request to the target service module through a calling interface of the target service module.
Optionally, configuring a basic service layer including a plurality of service modules includes:
and configuring the basic service layer to synchronize the data of each service module by adopting a preset algorithm.
Optionally, the configuring the basic service layer synchronizes data of each service module by using a preset algorithm, including:
configuring the basic service layer to judge whether a service module corresponding to the game service request is a non-reentrant service; and if so, configuring the basic service layer to synchronize the data of the service module of the non-reentrant service by adopting a Raft algorithm.
Optionally, the configuring the basic service layer employs a Raft algorithm to synchronize data of service modules of the non-reentrant service, including:
configuring the basic service layer to determine a leader and a plurality of followers in a service module of a non-reentrant service;
configuring the leader to process the game service request to obtain a data processing result;
configuring the leader to broadcast the data processing results to the plurality of followers;
and when the followers with the number exceeding the preset number receive the data processing results and synchronize, configuring the leader to return the data processing results to the client.
Optionally, the calling interface of each service module includes a first parameter and a second parameter, where the first parameter is used to determine whether to wait for the data processing result to be completed synchronously, and the second parameter is used to determine whether to broadcast the request of the calling interface to the multiple followers.
Optionally, the storage medium includes a relational database and a non-relational database.
Optionally, configuring a registration center layer including a plurality of registration modules includes:
and configuring the registration center layer to stop registering the call interface of the basic service layer for the specified type of service when receiving the service closing the specified type of service.
The embodiment of the invention discloses a device, which comprises: one or more processors; and one or more machine readable media having instructions stored thereon, which when executed by the one or more processors, cause the apparatus to perform one or more methods as described in embodiments of the invention.
Embodiments of the invention disclose one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform one or more methods as described in embodiments of the invention.
The embodiment of the invention has the following advantages:
in the embodiment of the invention, the game service system comprises a login server, a service logic layer, a registration center layer, a basic service layer, a data storage layer and a storage medium layer, wherein each layer comprises a plurality of independent functional modules except the login server and the storage medium layer, the layers are connected to form distributed connection, the whole system is a distributed system, and each layer is responsible for different service data processing.
In the embodiment of the invention, the registration center layer can carry out load balancing and close the specified type of service according to the load information of the plurality of service modules of the basic service layer, so that on one hand, the load of the whole game service system can be balanced, the running efficiency of the whole game service system is improved, on the other hand, the fault processing is facilitated, and the problem that the whole game service system is down and out of service due to a certain service fault is avoided.
In the embodiment of the invention, the basic service layer can adopt the Raft algorithm to synchronize the data of the service module of the non-reentrant service, thereby realizing dynamic data updating and ensuring the data consistency of the distributed system.
In the embodiment of the invention, the storage medium comprises the relational database and the non-relational database, different storage schemes can be adopted according to different services, and the flexibility of data storage is improved.
In the embodiment of the invention, each layer and each module of each layer are connected through the network, can be deployed in the network, and compared with single machine deployment, the deployed modules can be expanded or closed at any time, so that the game service system can be flexibly deployed.
Drawings
FIG. 1 is a block diagram of a structure of a conventional game service system;
FIG. 2 is a block diagram of a game service system according to an embodiment of the present invention;
FIG. 3 is a block diagram illustrating the connection of the layers of a game service system according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of state transitions of a service module according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a log replication mechanism of an embodiment of the present invention;
fig. 6 is a flowchart of steps of a method for implementing a game server system according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Referring to fig. 2 and 3, there are shown block diagrams of a game service system of the present invention. As shown in fig. 2 and 3, the game service system of the embodiment of the present invention includes: a login server 10, a business logic layer 20, a registration center layer 30, a basic service layer 40, a data storage layer 50 and a storage medium layer 60.
In the embodiment of the present invention, the login server 10, the business logic layer 20, the registration center layer 30, the basic service layer 40, the data storage layer 50, and the storage medium layer 60 may be a cluster of servers, modules, components, or related running processes, which are deployed in a network and configured to implement related functions. The modules in each layer can be connected through a network, and the modules in each layer can also be connected through the network, so that the whole game service system forms distributed connection.
The login server 10 is configured to log in a game for a player when receiving a login service request, and the login server 10 may be a server storing data such as a player account and a password, and may be configured to implement a login service, verify the identity of the player when receiving the login service request for the player, and log in the game for the player after the verification is passed.
The service logic layer 20 may include a plurality of service modules, which are respectively connected to the login server 10, the client 70 and the registration center layer 30, and configured to receive a login service request and a game service request of the client 70, send the login service request to the login server 10, and send a game service request to the registration center layer, for example, when the player a logs in a game through the client 70, the service module connected to the client 70 of the player a receives the login service request, sends the login service request of the player a to the login server 10, the login server 10 processes the login service request to allow the player to log in the game, and if a game service request of the player a is received, such as adding a friend, viewing equipment, or performing a prop transaction, the game service request is sent to the registration center layer 30.
The registration center layer 30 includes a plurality of registration modules, the plurality of registration modules of the registration center layer 30 are connected to the basic service layer 40 layer and are configured to register a call interface of the basic service layer 40, and send the game service request to the basic service layer 40 through the call interface, for example, when receiving the game service request sent by the service module of the service logic layer 20, the plurality of registration modules of the registration center layer 30 send the game service request to the basic service layer 40 through the call interface registered for the basic service layer 40 in advance, and the registration center layer 30 may also receive a data processing result of the basic service layer 40 and return the result to the client 70.
The basic service layer 40 includes a plurality of service modules, and the basic service layer 40 is connected to the data storage layer 50 and configured to send a data reading request to the data storage layer 50 according to the game service request, process the read data to obtain a data processing result, return the data processing result to the client 70, and send a storage request for the data processing result to the data storage layer 50.
The data storage layer 50 comprises a plurality of storage modules, and the data storage layer 50 is connected with the storage medium layer 60 and used for processing data reading requests and storing requests aiming at data processing results;
the storage medium layer 60, including a storage medium, stores data.
As shown in fig. 3, the service logic layer 20 includes four service modules, the registration center layer 30 includes two registration modules, the basic service layer 40 includes four service modules, the data storage layer 50 includes four storage modules, the storage medium layer 60 includes a relational database and a non-relational database, after configuration, the four service modules of the service logic layer 20 can be connected to the login server 10 and the client 70, the two registration modules of the registration center layer 30 are connected to the four service modules of the service logic layer 20 and the four service modules of the basic service layer 40, the four service modules of the basic service layer 40 are connected to the four storage modules of the data storage layer 50, the four storage modules of the data storage layer 50 are connected to the relational database and the non-relational database of the storage medium layer 60, of course, in practical applications, a person skilled in the art can configure the number of function modules in each layer and the connection manner between the function modules according to actual needs, the embodiment of the present invention does not limit the number and connection manner of the functional modules in each layer.
The login server 10, the business logic layer 20, the registration center layer 30, the basic service layer 40, the data storage layer 50 and the storage medium layer 60 can be deployed on a network, each layer comprises a plurality of independent functional modules, the layers are connected to form distributed connection, the whole system is a distributed system, each layer is responsible for different business data processing, on one hand, when one module in each layer is down, the other module in the layer can perform corresponding business processing, the operation of the whole game service system cannot be influenced, on the other hand, each layer is responsible for different business data processing, and the modules in each layer are independent, so that the mashup degree among the layers is reduced, and the development difficulty of the system is reduced.
In the embodiment of the invention, each functional module of each layer can be directly restarted, and each functional module is in network connection, so that compared with single-machine communication, the method has no requirement on the machine environment, can infinitely restart and close some functional modules, can realize flexible capacity expansion and deployment, can adopt different languages to realize the functions of the functional modules of each layer, and can realize multi-technology type selection.
In one embodiment of the present invention, the basic service layer 40 is further configured to:
after the system is powered on, a call interface registration request of each service module is sent to the registration center layer, where the call interface registration request is used to instruct each registration module of the registration center layer to register a call interface for each service module, for example, after the system is powered on, each service module of the basic service layer 40 tries to send a call interface registration request to the registration center layer 30 until the call interface registration is successful.
In the embodiment of the present invention, the service logic layer 30 is mainly responsible for communicating with the client 70, including receiving a service request of the client 70, and returning data corresponding to the client 70 after the logic processing is performed by the basic service layer 40. Since the business logic layer 30 has no processing logic of the game, the business logic layer 30 needs to call the call interface exposed by the basic service layer 40 to access the game data, and the basic service layer 40 makes the business logic layer 30 call the call interface of the basic service layer 40 by registering the call interface with the registry layer 30.
In a preferred embodiment of the present application, when the registry layer 30 sends the game service request to the basic service layer 40 through the call interface, the registration layer is further configured to: acquiring load information of a plurality of service modules of the basic service layer; determining a target service module according to the load information; and sending a game service request to the target service module through a calling interface of the target service module.
Specifically, the basic service layer 40 and the registry layer 30 maintain a heartbeat connection, and the heartbeat may carry hardware information of each service module on the basic service layer 40, such as a current CPU usage rate, a memory usage rate, a hard disk remaining space, and the like of each service module. After the registration center layer 30 receives the call interface request of the service logic layer 20, it may determine a target service module according to the hardware information of each service module, for example, determine a service module with low load according to the hardware information, determine a service module with low CPU utilization and memory utilization as the target service module, send a game service request to the target service module, and perform data processing by the target service module, thereby implementing load balancing.
In another embodiment of the present invention, the registry layer 30 is further configured to: and when receiving an instruction of closing the specified type of service, stopping registering the call interface of the basic service layer for the specified type of service.
The instruction for closing the specified service may be that a system administrator operates and then sends the instruction to the registration center layer 30, for example, when the friend management service in the game has a fault, the registration information of the basic service layer 40 about the call interface of the friend management service may be removed from the registration center layer 30, and all the friend service requests passing through the registration center layer 30 are invalid. The method can ensure that the current game shields the service of the fault without stopping service, and after the fault is solved, the service of the solved fault is started again.
According to the game service system of the embodiment of the application, through the registration center layer 30, on one hand, the target service module can be determined according to the load information of the basic service layer 40, so that the load balance of the system is realized, on the other hand, the specified type of service can be closed according to the instruction, the service with faults is shielded under the condition that the current game is not stopped, after the faults are solved, the service with the faults solved is started again, and the reliability of the game service system is improved.
In another embodiment of the present invention, when the basic service layer 40 sends a data reading request to the data storage layer 50 according to the game service request and processes the read data to obtain a data processing result, the basic service layer is further configured to: and synchronizing the data of each service module by adopting a preset algorithm.
The basic service layer 40 includes a plurality of service modules, and in order to ensure consistency of data, data of each service module needs to be synchronized, and specifically, the basic service layer determines whether a service module corresponding to a game service request is a non-reentrant service; and if so, synchronizing the data of the service module of the non-reentrant service by adopting a Raft algorithm.
In the embodiment of the present invention, each service of the basic service layer 40 may be defined as a re-enterable service and a non-re-enterable service.
The reentrant service can be a service in which a subsequent request is irrelevant to previous access, and the reentrant service has no stateness, that is, the reentrant service has no state data and is irrelevant to stored data, and the former request and the latter request have the same utility for the reentrant service. For example, in the in-game combat service, the combat of player a and player B does not affect the combat of player C and player D, and the combat service of player a and player B is a reentrant service. Whether a service is a reentrant service or not is judged, and whether the service generates data which needs to be dynamically put in storage in the running process or not can be judged.
The non-reentrant service may be that a subsequent request is associated with a previous access, the non-reentrant service is associated with stored data. For example, the friend services, the friend relationship services of Player A and Player B, determine whether Player C and Player D can become friends' services.
Therefore, since the reentrant service is independent of the stored data, if one service is a reentrant service, there is no need to synchronize data, and there is no data consistency problem.
In order to know the non-reentrant service, when the basic service layer adopts the Raft algorithm to synchronize the data of the service module of the non-reentrant service, the basic service layer is further used for:
determining a leader and a plurality of followers in a service module of a non-reentrant service;
processing the game service request through the leader to obtain a data processing result;
the leader broadcasts the data processing results to the plurality of followers;
and when the followers with the number exceeding the preset number receive the data processing results for synchronization, the leader returns the data processing results to the client.
The Raft algorithm is a consistency algorithm used for managing log replication, the Raft divides a service module into three states of a Leader, a Follower and a Candidate, wherein each state is responsible for different tasks, and the Leader and the Follower exist when the Raft algorithm provides service during operation, wherein the Leader is responsible for synchronous management of logs, processes requests from clients and keeps heartbeat with the Follower; all nodes are in a Follower state when the Follower is started, respond to a log synchronization request of the Leader, respond to a Candidate request, and forward a service requested to the Follower to the Leader; candidate is responsible for election voting, when the Raft algorithm is started, a node is converted from Follower to Candidate to initiate election, and after Leader is elected, the node is converted from Candidate to Leader state.
The left algorithm has two times, one is broadcast time (broadcastTime), which is used for the time interval when the Leader broadcasts a message to the Follower, and if the Follower does not receive a message within the broadcast time, a new round of election is triggered, and the state of the Follower is changed into the state of the Candidate. And the other is election timeout (election timeout) which is used for election time of Candidate, if the election time is exceeded, a new round of election is started, and all nodes perform random election within the timeout time. The broadcast time is much shorter than the election timeout, for example, the broadcast time may be 0.5ms to 20ms, and the election timeout may be 10ms to 500 ms.
As shown in fig. 4, in the Raft algorithm, three state migration flows of Leader, Follower and Candidate are as follows:
s1, when the Raft algorithm is started, all nodes are in a Follower state, and since no Leader exists at this time, after the broadcasting time is over, all Followers are converted into Candidate, and the first round of election is carried out.
S2, Candidate will elect Leader (if not elected, it will continue electing until Leader is elected), generate the option number of this election (the option number naturally grows, each time +1), if in the election process, find that there is Leader already (receiving the broadcast message of Leader) or find that there is new Leader option, will return to the Follower state.
S3, after electing the Leader, the Leader will accept all external requests or messages, and at the same time, the Leader broadcasts once per broadscastTime to inform other nodes that there is the Leader, so as to prevent other nodes from overtime because no message is received in the broadcast time, and if the Leader finds that there is a new node at a higher deadline, the Leader will become a Follower state.
After a Leader is elected, in order to ensure data consistency, the Raft algorithm adopts a replication state machine (replicated state machine) principle, the replication state machine is based on replication logs, for example, a, B and C are nodes, a is the Leader, B and C are followers, and the replication state machine ensures that after a certain request is received by a node, the obtained output or result is consistent after each node processes a transaction.
As shown in fig. 5, the process is as follows:
1. in the Raft algorithm, there is only one valid Leader, and after the Leader receives a request, the request is added to the log as a new log entry, and simultaneously the corresponding log is additionally broadcast to all Followers, wherein each log comprises an index number, an option number and an instruction.
2. When more than half of the nodes are successfully added with the corresponding logs, the logs are successfully submitted logs (committed entries), and meanwhile, the Leader returns the execution result to the client, as shown in fig. 5, the logs 1 to 7 are already stored in the Leader, the follower b and the follower d, and if more than half of the logs are successfully added, the logs are considered to be submitted logs.
3. If a certain Follower is disconnected for a period of time, the status of the Follower can be kept up with the status of the Leader according to the committed entries log, for example, the Follower a and the Follower c can copy the relevant logs according to the submitted logs, so that the logs of all nodes are kept consistent.
Through a log addition mode, the Raft algorithm can ensure that all clusters keep relatively consistent states, and the log keeping consistent state of each node can refer to a state with consistent index numbers, expiration numbers and instructions.
In particular, in the embodiment of the invention, a Raft algorithm can be adopted for the non-reentrant service group to solve the consistency problem. According to the Raft algorithm, a Leader and a plurality of Followers are generated by a service module group of the non-reentrant service, a game service request is transmitted to the Leader firstly, and then the Leader is synchronized to the Follower, so that the data consistency of each service module is ensured.
For example, if player a wants to add player B as a friend and the description instruction may be add (a, B), the synchronization flow is as follows:
1. the service module in charge of friend management in the basic service layer 40 receives add (a, B), and the Leader in the service module firstly adds a log add (a, B) and broadcasts to other service modules.
2. After receiving add (A, B), other service modules will attach to their own log and tell Leader that the attachment was successful.
3. When more than half of the service modules reply to the Leader, add (A, B) becomes a log which is successfully submitted, and the Leader executes add (A, B) and returns the result to the client.
4. Finally, all service modules will execute add (A, B), and the data is kept consistent, i.e. synchronized.
In the process, the calling interface of each service module comprises a first parameter and a second parameter, the first parameter is used for judging whether to wait for the synchronous completion of the data processing result, and the second parameter is used for judging whether to broadcast the request of the calling interface to the plurality of followers, wherein whether to wait for the synchronous completion of the data processing result indicates that if the synchronous completion does not exist, the service module waits for the synchronous completion of all the data processing results and then processes the next request, such as the service related to fee deduction of a player; whether to broadcast to the followers is indicative of whether the received request may be posted directly to Follower, typically for requests with relatively low data immediacy requirements, such as viewing a certain player's equipment, viewing a certain player's friends, etc.
In the game service system of the embodiment of the invention, the service modules of the basic service layer are defined as the reentrant service and the non-reentrant service, the strong Leader's Raft algorithm is adopted for the non-reentrant service to ensure the consistency of data, all game service requests can be processed in consistency through the Leader, and for the reentrant service, the service can be accessed by starting the service because of the reentrant stateless state, so that the access delay of the Raft algorithm is avoided, the structure of the system is more flexible, and meanwhile, the calling interfaces of all the service modules of the basic service layer comprise the first parameter and the second parameter, so that the service logic layer has better access performance and load balancing capability.
As shown in fig. 3, in another embodiment of the present invention, the storage medium includes a relational database and a non-relational database, and the data storage layer 50 can process the storage request of the basic service layer 40 to determine the storage type of the data, for example, for a player log, the data structure is stable and the service does not need to be modified, the non-relational database can be used for direct serialization, for a service that a player ranking list changes frequently, the relational database can be used for storage, and the data storage layer 50 and the storage medium layer 60 can use different storage modes according to different services, so that the game data storage is more flexible.
In the game service system of the embodiment of the invention, each layer comprises a plurality of independent functional modules, the layers are connected to form distributed connection, the whole system is a distributed system, and each layer is responsible for different business data processing.
In the embodiment of the invention, the registration center layer can carry out load balancing and close the specified type of service according to the load information of the plurality of service modules of the basic service layer, so that on one hand, the load of the whole game service system can be balanced, the running efficiency of the whole game service system is improved, on the other hand, the fault processing is facilitated, and the problem that the whole game service system is down and out of service due to a certain service fault is avoided.
In the embodiment of the invention, the basic service layer can adopt the Raft algorithm to synchronize the data of the service module of the non-reentrant service, thereby realizing dynamic data updating and ensuring the data consistency of the distributed system.
In the embodiment of the invention, the storage medium comprises the relational database and the non-relational database, different storage schemes can be adopted according to different services, and the flexibility of data storage is improved.
In the embodiment of the invention, each layer and each module of each layer are connected through the network, can be deployed in the network, and compared with single machine deployment, the deployed modules can be expanded or closed at any time, so that the game service system can be flexibly deployed.
Referring to fig. 6, a flowchart illustrating steps of a method for implementing a game service system according to an embodiment of the present invention specifically includes the following steps:
step 101, configuring a login server, wherein the login server enables a player to log in a game when receiving a login service request.
102, configuring a service logic layer comprising a plurality of service modules, wherein the service logic layer is respectively connected with the login server and the registration center layer, receives a login service request and a game service request of a client, sends the login service request to the login server, and sends the game service request to the registration center layer;
103, configuring a registration center layer comprising a plurality of registration modules, wherein the registration center layer is connected with a basic service layer, registers a calling interface of the basic service layer, and sends the game service request to the basic service layer through the calling interface;
step 104, configuring a basic service layer comprising a plurality of service modules, wherein the basic service layer is connected with a data storage layer, and sends a data reading request to the data storage layer according to the game service request and processes the read data to obtain a data processing result, and returns the data processing result to the client and sends a storage request aiming at the data processing result to the data storage layer;
step 105, configuring a data storage layer comprising a plurality of storage modules, wherein the data storage layer is connected with a storage medium layer, and processes the data reading request and the storage request aiming at the data processing result;
step 106, configuring a storage medium layer, including a storage medium, for storing data.
Optionally, step 104 may include:
and configuring the basic service layer to send a calling interface registration request of each service module to the registration center layer after starting up, wherein the calling interface registration request is used for indicating each registration module of the registration center layer to register a calling interface for each service module.
Optionally, step 103 may comprise:
configuring the registration center layer to acquire load information of a plurality of service modules of the basic service layer; determining a target service module according to the load information; and sending the game service request to the target service module through a calling interface of the target service module.
Optionally, step 104 may include:
and configuring the basic service layer to synchronize the data of each service module by adopting a preset algorithm.
Optionally, the configuring the basic service layer synchronizes data of each service module by using a preset algorithm, including:
configuring the basic service layer to judge whether a service module corresponding to the game service request is a non-reentrant service; and if so, configuring the basic service layer to synchronize the data of the service module of the non-reentrant service by adopting a Raft algorithm.
Optionally, the configuring the basic service layer employs a Raft algorithm to synchronize data of service modules of the non-reentrant service, including:
configuring the basic service layer to determine a leader and a plurality of followers in a service module of a non-reentrant service;
configuring the leader to process the game service request to obtain a data processing result;
configuring the leader to broadcast the data processing results to the plurality of followers;
and when the followers with the number exceeding the preset number receive the data processing results and synchronize, configuring the leader to return the data processing results to the client.
Optionally, the configuration of the call interface of each service module includes a first parameter and a second parameter, where the first parameter is used to determine whether to wait for the data processing result to be completed synchronously, and the second parameter is used to determine whether to broadcast the request of the call interface to the multiple followers.
Optionally, configuring the storage medium includes a relational database and a non-relational database.
Optionally, step 103 may comprise:
and configuring the registration center layer to stop registering the call interface of the basic service layer for the specified type of service when receiving the service closing the specified type of service.
An embodiment of the present invention provides an apparatus, including: one or more processors; and one or more machine-readable media having instructions stored thereon, which when executed by the one or more processors, cause the apparatus to perform a method of implementing a game service system according to an embodiment of the present invention.
Embodiments of the present invention provide one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a method for implementing a game service system according to an embodiment of the present invention.
As for the method embodiment, since it is basically similar to the apparatus embodiment, the description is simple, and the relevant points can be referred to the partial description of the apparatus embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The game service system and the implementation method of the game service system provided by the invention are described in detail above, and a specific example is applied in the text to explain the principle and the implementation mode of the invention, and the description of the above embodiment is only used to help understand the method of the invention and the core idea thereof; meanwhile, for a person skilled in the art, in light of the above teachings, there may be controls over the specific embodiments and applications, and as such, the present disclosure should not be construed as limiting the present disclosure.

Claims (20)

1. A game service system, comprising:
the login server is used for enabling the player to log in the game when the login service request is received;
the service logic layer comprises a plurality of service modules which are respectively connected with the login server, the client and the registration center layer and are used for receiving a login service request and a game service request of the client, sending the login service request to the login server and sending the game service request to the registration center layer;
the registration center layer comprises a plurality of registration modules, is connected with the basic service layer and is used for registering a calling interface of the basic service layer and sending the game service request to the basic service layer through the calling interface;
the basic service layer comprises a plurality of service modules, is connected with the data storage layer and is used for sending a data reading request to the data storage layer according to the game service request, processing the read data to obtain a data processing result, returning the data processing result to the client and sending a storage request aiming at the data processing result to the data storage layer; the service module of the basic service layer is a reentrant service or a non-reentrant service; the reentrant service is a service in which subsequent requests are unrelated to previous accesses; the non-reentrant service is a service for which a subsequent request is related to a previous access;
the data storage layer comprises a plurality of storage modules, is connected with the storage medium layer and is used for processing the data reading request and the storage request aiming at the data processing result;
and a storage medium layer including a storage medium for storing data.
2. The game service system of claim 1, wherein the base service layer is further configured to:
and sending a calling interface registration request of each service module to the registration center layer after starting up, wherein the calling interface registration request is used for indicating each registration module of the registration center layer to register a calling interface for each service module.
3. The game service system of claim 2, wherein the registry layer, when sending the game service request to the base service layer through the call interface, is further configured to:
acquiring load information of a plurality of service modules of the basic service layer;
determining a target service module according to the load information;
and sending the game service request to the target service module through a calling interface of the target service module.
4. The game service system of claim 1, wherein the basic service layer, when sending a data reading request to the data storage layer according to the game service request and processing the read data to obtain a data processing result, is further configured to:
and synchronizing the data of each service module by adopting a preset algorithm.
5. The game service system of claim 4, wherein the basic service layer, when synchronizing the data of each service module by using a preset algorithm, is further configured to:
judging whether a service module corresponding to the game service request is a non-reentrant service;
and if so, synchronizing the data of the service module of the non-reentrant service by adopting a Raft algorithm.
6. The game service system of claim 5, wherein the basic service layer, when synchronizing data of the service modules of the non-reentrant service using the Raft algorithm, is further configured to:
determining a leader and a plurality of followers in a service module of a non-reentrant service;
processing the game service request through the leader to obtain a data processing result;
the leader broadcasts the data processing results to the plurality of followers;
and when the followers with the number exceeding the preset number receive the data processing results for synchronization, the leader returns the data processing results to the client.
7. The game service system of claim 6, wherein the call interface of each service module comprises a first parameter for determining whether to wait for the data processing result to be completed synchronously, and a second parameter for determining whether to broadcast the request of the call interface to the plurality of followers.
8. The game service system of claim 1, wherein the storage medium comprises a relational database and a non-relational database.
9. The game service system of claim 1, wherein the registry layer is further configured to:
and when receiving the service closing of the specified type, stopping registering the calling interface of the basic service layer for the specified type of service.
10. A method for implementing a game service system, comprising:
configuring a login server, wherein the login server enables a player to log in a game when receiving a login service request;
configuring a service logic layer comprising a plurality of service modules, wherein the service logic layer is respectively connected with the login server and the registration center layer, receives a login service request and a game service request of a client, sends the login service request to the login server and sends the game service request to the registration center layer;
configuring a registration center layer comprising a plurality of registration modules, wherein the registration center layer is connected with a basic service layer, registers a calling interface of the basic service layer, and sends the game service request to the basic service layer through the calling interface;
configuring a basic service layer comprising a plurality of service modules, wherein the basic service layer is connected with a data storage layer, the basic service layer sends a data reading request to the data storage layer according to the game service request and processes the read data to obtain a data processing result, and returns the data processing result to the client and sends a storage request aiming at the data processing result to the data storage layer; the service module of the basic service layer is a reentrant service or a non-reentrant service; the reentrant service is a service in which subsequent requests are unrelated to previous accesses; the non-reentrant service is a service for which a subsequent request is related to a previous access;
configuring a data storage layer comprising a plurality of storage modules, wherein the data storage layer is connected with a storage medium layer and processes the data reading request and the storage request aiming at the data processing result;
a storage medium layer is configured to include a storage medium for storing data.
11. The method of claim 10, wherein configuring a base service layer comprising a plurality of service modules comprises:
and configuring the basic service layer to send a calling interface registration request of each service module to the registration center layer after starting up, wherein the calling interface registration request is used for indicating each registration module of the registration center layer to register a calling interface for each service module.
12. The method of claim 11, wherein configuring a registry tier comprising a plurality of registry modules comprises:
configuring the registration center layer to acquire load information of a plurality of service modules of the basic service layer; determining a target service module according to the load information; and sending the game service request to the target service module through a calling interface of the target service module.
13. The method of claim 10, wherein configuring a base service layer comprising a plurality of service modules comprises:
and configuring the basic service layer to synchronize the data of each service module by adopting a preset algorithm.
14. The method as claimed in claim 13, wherein said configuring said basic service layer to synchronize data of each service module by using a preset algorithm comprises:
configuring the basic service layer to judge whether a service module corresponding to the game service request is a non-reentrant service; and if so, configuring the basic service layer to synchronize the data of the service module of the non-reentrant service by adopting a Raft algorithm.
15. The method as claimed in claim 14, wherein said configuring said basic service layer employs a Raft algorithm to synchronize data of service modules of non-reentrant services, comprising:
configuring the basic service layer to determine a leader and a plurality of followers in a service module of a non-reentrant service;
configuring the leader to process the game service request to obtain a data processing result;
configuring the leader to broadcast the data processing results to the plurality of followers;
and when the followers with the number exceeding the preset number receive the data processing results and synchronize, configuring the leader to return the data processing results to the client.
16. The method as claimed in claim 15, wherein the calling interface of each service module includes a first parameter and a second parameter, the first parameter is used to determine whether to wait for the data processing result to be completed synchronously, and the second parameter is used to determine whether to broadcast the request of calling interface to the plurality of followers.
17. The method of claim 10, wherein the storage medium includes a relational database and a non-relational database.
18. The method of claim 10, wherein configuring a registry tier comprising a plurality of registry modules comprises:
and configuring the registration center layer to stop registering the call interface of the basic service layer for the specified type of service when receiving the service closing the specified type of service.
19. A gaming apparatus, comprising: one or more processors; and one or more machine readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of any of claims 10-18.
20. A machine-readable medium having stored thereon instructions, which when executed by one or more processors, cause an apparatus to perform the method of any one of claims 10-18.
CN201811037918.8A 2018-09-06 2018-09-06 Game service system and implementation method Active CN109173270B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811037918.8A CN109173270B (en) 2018-09-06 2018-09-06 Game service system and implementation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811037918.8A CN109173270B (en) 2018-09-06 2018-09-06 Game service system and implementation method

Publications (2)

Publication Number Publication Date
CN109173270A CN109173270A (en) 2019-01-11
CN109173270B true CN109173270B (en) 2022-05-03

Family

ID=64915089

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811037918.8A Active CN109173270B (en) 2018-09-06 2018-09-06 Game service system and implementation method

Country Status (1)

Country Link
CN (1) CN109173270B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110278284B (en) * 2019-07-10 2021-09-14 中国民航信息网络股份有限公司 Service calling method and device
CN110354493B (en) * 2019-08-22 2022-03-01 腾讯科技(深圳)有限公司 Access control method, device, server and storage medium
CN112068939A (en) * 2020-08-24 2020-12-11 浙江知水信息技术有限公司 Method and system for scheduling multiple early warning services
CN112837524B (en) * 2021-01-19 2022-05-17 国网山西省电力公司营销服务中心 Intelligent distributed communication method based on power line carrier
CN113209635B (en) * 2021-05-11 2024-04-19 腾讯科技(上海)有限公司 Data processing method, device and storage medium based on cache queue
CN116743786A (en) * 2022-02-25 2023-09-12 比亚迪股份有限公司 Rail transit system control method, system and storage medium based on Raft algorithm
CN115086405B (en) * 2022-06-10 2024-05-31 上海莉莉丝科技股份有限公司 Data processing method, system, device, medium and program product for server

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102254098A (en) * 2011-07-08 2011-11-23 盛趣信息技术(上海)有限公司 Distributed system and method for developing, deploying and operating games
CN104007965A (en) * 2014-05-09 2014-08-27 深圳中青宝互动网络股份有限公司 Method and system for designing three-dimensional game
KR20160052524A (en) * 2016-04-29 2016-05-12 주식회사 아이온커뮤니케이션즈 Multi work space system for supporting software as a service
CN106610871A (en) * 2016-12-30 2017-05-03 郑州云海信息技术有限公司 Cloud operating system architecture

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102254098A (en) * 2011-07-08 2011-11-23 盛趣信息技术(上海)有限公司 Distributed system and method for developing, deploying and operating games
CN104007965A (en) * 2014-05-09 2014-08-27 深圳中青宝互动网络股份有限公司 Method and system for designing three-dimensional game
KR20160052524A (en) * 2016-04-29 2016-05-12 주식회사 아이온커뮤니케이션즈 Multi work space system for supporting software as a service
CN106610871A (en) * 2016-12-30 2017-05-03 郑州云海信息技术有限公司 Cloud operating system architecture

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
分布式共识算法 (三) Raft算法;FAw67J7;《https://blog.csdn.net/FAw67J7/article/details/108644565》;20170303;第1-11页 *
分布式架构在银行的应用实践与发展;张升;《金融电子化》;20150630;第61-63页 *

Also Published As

Publication number Publication date
CN109173270A (en) 2019-01-11

Similar Documents

Publication Publication Date Title
CN109173270B (en) Game service system and implementation method
US9984140B1 (en) Lease based leader election system
US11533220B2 (en) Network-assisted consensus protocol
Zheng et al. A distributed replication strategy evaluation and selection framework for fault tolerant web services
KR20200112633A (en) Consensus system downtime recovery
CN107291750B (en) Data migration method and device
CN107453929B (en) Cluster system self-construction method and device and cluster system
CN110309161B (en) Data synchronization method and device and server
CN108712457B (en) Method and device for adjusting dynamic load of back-end server based on Nginx reverse proxy
KR20200112634A (en) Consensus system downtime recovery
CN108744504B (en) Game data processing method and device, game server and game system
CN107666493B (en) Database configuration method and equipment thereof
CN112988377B (en) Resource allocation method, system and medium for cloud service
Lofstead et al. D2t: Doubly distributed transactions for high performance and distributed computing
CN113055461A (en) ZooKeeper-based unmanned cluster distributed cooperative command control method
CN107025257A (en) A kind of transaction methods and device
CN114726871A (en) Data synchronization method, device and network system
CN111092956A (en) Resource synchronization method, device, storage medium and equipment
CN112532754B (en) Method and system for rapidly serving school network files
Sun et al. Adaptive trade‐off between consistency and performance in data replication
Vieira et al. Seamless paxos coordinators
CN112764837A (en) Data reporting method, device, storage medium and terminal
US10178221B2 (en) Time synchronization method and apparatus
CN113743564B (en) Counting method, counting device, electronic equipment and storage medium
CN112153093A (en) Task scheduling method, device and equipment based on cluster and readable storage medium

Legal Events

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