Game service request processing method and apparatus, computer device, and storage medium
By migrating non-real-time game requests to the business server and making RPC remote calls, and deploying non-real-time services independently, the problems of high development complexity and low availability under the monolithic architecture are solved, achieving efficient game development and stable game operation.
Patent Information
- Application Number
- CN202211632392.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-19
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-12-19
AI Technical Summary
In multi-user online game scenarios, monolithic architecture game development is highly complex, and if a certain business function is blocked, the entire main logic process may become unavailable, affecting game development efficiency and availability.
Non-real-time game requests are migrated from the game server to the business server. Service interfaces are queried through the service registry and RPC remote calls are made. Non-real-time services are independently deployed and processed on different business servers to avoid tight coupling.
It reduces development complexity, improves game development efficiency and usability, and ensures that blocking certain business functions does not affect the normal use of other functions.
Smart Images

Figure CN115920371B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, and particularly relates to a game service request processing method and device, computer equipment and storage medium. BACKGROUND
[0002] With the development of computer technology and the popularity of mobile terminals, mobile phone games have gradually become a relatively popular game type. In the current game backend development technology, the overall structure is used to design the business main logic of the game, such as ray detection, damage calculation, game chat, game mail collection and other services, which are supported by the main logic process of the game server backend.
[0003] However, in the online game scenario involving frequent communication between multiple users, with the iteration and version update of the service, the code amount will continue to accumulate, and when modifying or adding services in the overall architecture, the development complexity is higher and higher, and when a certain service function is blocked, the entire main logic process may be unavailable, therefore, the game development efficiency of the overall architecture is low, and the game availability is low. SUMMARY
[0004] The present disclosure provides a game service request processing method and device, computer equipment and storage medium, to at least improve the game development efficiency and game availability. The technical solutions of the present disclosure are as follows:
[0005] According to an aspect of an embodiment of the present disclosure, a game service request processing method is provided, comprising:
[0006] In response to a game service request of an account, determining a service type of the game service request, the service type indicating a time attribute of a game service associated with the game service request;
[0007] In the case where the service type indicates that the game service is a non-real-time service, determining a service interface matched with the non-real-time service;
[0008] Querying an address of a service server for providing the service interface from a service registration center, the service registration center being used to record the addresses of service servers of various interfaces;
[0009] Based on the service interface, sending a remote procedure call RPC request to the address, the RPC request being used to instruct the service server to provide a response to the game service to the account.
[0010] In some embodiments, the querying of the address of the service server for providing the service interface from the service registration center comprises:
[0011] query, from the service registry, a set of addresses for providing the service interface;
[0012] query, from the set of addresses, an address of a business server closest to the account in geographical distance.
[0013] In some embodiments, the method further comprises:
[0014] creating, by the business server, a coroutine of the non-real-time business in response to the RPC request;
[0015] initiating, by the coroutine, a database operation of the non-real-time business;
[0016] blocking and suspending the coroutine before an operation result of the database operation is obtained;
[0017] returning, after the operation result of the database operation is obtained, a response generated based on the operation result.
[0018] In some embodiments, the game business request is a mail list pulling request; and the initiating, by the coroutine, of the database operation of the non-real-time business comprises:
[0019] obtaining, by the coroutine, from the mail list pulling request, a maximum personal mail sequence number and a maximum system mail sequence number in the pulled mails of the account;
[0020] initiating, based on the maximum personal mail sequence number, a batch reading operation of personal mails to a personal mail set of the account in the database, the batch reading operation being used to read multiple personal mails with mail sequence numbers greater than the maximum personal mail sequence number;
[0021] initiating, based on the maximum system mail sequence number, a batch reading operation of system mails to a system mail set in the database, the batch reading operation being used to read multiple system mails with mail sequence numbers greater than the maximum system mail sequence number.
[0022] In some embodiments, the game business request is a mail list pulling request; and the initiating, by the coroutine, of the database operation of the non-real-time business comprises:
[0023] obtaining, by the coroutine, a maximum mail sequence number in the pulled mails of the account carried in the mail list pulling request;
[0024] initiating, based on the maximum mail sequence number, a batch reading operation of system mails to a system mail set in the database, the batch reading operation being used to read multiple system mails with mail sequence numbers greater than the maximum mail sequence number.
[0025] storing the plurality of the system mails into a personal mail set of the account in the database;
[0026] based on the maximum mail sequence number, initiating a batch read operation on the personal mail set, the batch read operation being used to read a plurality of mails with mail sequence numbers greater than the maximum mail sequence number.
[0027] In some embodiments, the method further comprises:
[0028] based on the plurality of mails returned by the operation result of the batch read operation, determining a number of unread mails;
[0029] extracting an information digest of the plurality of mails, the information digest being used to provide at least one of the following: mail type, mail title, sender information, mail timestamp, and whether containing an attachment;
[0030] generating a response carrying the information digest and the number of unread mails.
[0031] In some embodiments, the method further comprises:
[0032] in a case where the number of the plurality of mail list pull requests received within the same time period exceeds a request quantity threshold, buffering, by the business server, a plurality of RPC requests associated with the plurality of mail list pull requests into a message queue;
[0033] in the message queue, merging RPC requests associated with the same mail list pull request sent multiple times by a same initiating account, and configuring a request number variable for the initiating account;
[0034] based on the request number variable, reordering each RPC request in the message queue;
[0035] every interval of a target duration, processing at least one RPC request in a current batch in the reordered message queue.
[0036] In some embodiments, the game business request is a mail detail pull request; and the initiating, by the coroutine, the database operation of the non-real-time business comprises:
[0037] determining, by the coroutine, a mail type and a mail sequence number requested to be pulled by the mail detail pull request;
[0038] initiating, to a mail set indicated by the mail type in the database, a read operation on a mail indicated by the mail sequence number, the read operation being used to read a mail body of the mail, and in a case where the mail carries an attachment, also reading the attachment.
[0039] In some embodiments, the game service request is a mail sending request; and the initiating, by the coroutine, the database operation of the non-real-time service comprises:
[0040] determining, by the coroutine, a mail type of a to-be-sent mail indicated by the mail sending request;
[0041] in a case where the mail type is a personal mail, initiating a write operation of the to-be-sent mail to a personal mail set of the account in the database;
[0042] in a case where the mail type is a system mail, initiating a write operation of the to-be-sent mail to a system mail set of the database.
[0043] In some embodiments, the method further comprises:
[0044] based on an operation result of the write operation, assigning a mail sequence number to the to-be-sent mail;
[0045] in a case where a recipient account of the to-be-sent mail is in a game offline state, generating a response of notifying the account of a mail sending success;
[0046] in a case where a recipient account of the to-be-sent mail is in a game online state, generating a response of notifying the account of a mail sending success; and generating a response of pushing the to-be-sent mail to the recipient account.
[0047] In some embodiments, the game service request is an unread message pulling request; and the initiating, by the coroutine, the database operation of the non-real-time service comprises:
[0048] acquiring, by the coroutine, a to-be-queried account and a maximum message identifier from the unread message pulling request, the maximum message identifier indicating a latest read message in a session of the account and the to-be-queried account;
[0049] based on the maximum message identifier, initiating a batch read operation of unread messages to message sets of the account and the to-be-queried account in the database, the batch read operation being used for reading a plurality of messages with message identifiers greater than the maximum message identifier.
[0050] In some embodiments, the method further comprises:
[0051] based on a plurality of messages returned by an operation result of the batch read operation, determining an unread message quantity;
[0052] generating a response carrying the plurality of unread messages and the unread message quantity.
[0053] In some embodiments, the game service request is a message sending request; and the initiating, by the coroutine, of the database operation of the non-real-time service comprises:
[0054] determining, by the coroutine, a message type of a to-be-sent message indicated by the message sending request;
[0055] in a case where the message type is a personal message, initiating, to a message collection of the account and a message receiving account in a database, a write operation of the to-be-sent message;
[0056] in a case where the message type is a group message, initiating, to a message collection of a message receiving group in a database, a write operation of the to-be-sent message.
[0057] In some embodiments, the method further comprises:
[0058] based on an operation result of the write operation, assigning a message identifier to the to-be-sent message, and generating a response of notifying the account of a success of the message sending;
[0059] for the personal message, only in a case where the message receiving account is in a game online state, generating a response of pushing the to-be-sent message to the message receiving account;
[0060] for the group message, pulling a latest member list of the message receiving group; and only for online member accounts in the latest member list, generating a response of pushing the to-be-sent message to the online member accounts.
[0061] In some embodiments, the game service request is an account adding request, the account adding request being used to apply to add a target account to an account relationship chain of the account; and the initiating, by the coroutine, of the database operation of the non-real-time service comprises:
[0062] performing, by the coroutine, permission verification on the account;
[0063] after the verification passes, initiating, to a database, a write operation of adding a record of the account to the target account to the account;
[0064] the returning, after an operation result of the database operation is acquired, of a response generated based on the operation result comprises:
[0065] in a case where the operation result indicates that the record of the account addition is written completely, generating an account addition notification response to the target account.
[0066] According to another aspect of the embodiments of the present disclosure, a processing apparatus of a game service request is provided, comprising:
[0067] The determining unit is configured to determine a service type of the game service request in response to the game service request of the account, the service type indicating a time attribute of a game service associated with the game service request.
[0068] The determining unit is further configured to determine a service interface matched with the non-real-time service when the service type indicates that the game service is a non-real-time service.
[0069] The querying unit is configured to query an address of a service server for providing the service interface from a service registry center, the service registry center being used to record addresses of service servers of various interfaces.
[0070] The sending unit is configured to send a remote procedure call (RPC) request to the address based on the service interface, the RPC request being used to instruct the service server to provide a response to the game service to the account.
[0071] In some embodiments, the querying unit is configured to:
[0072] query a set of addresses for providing the service interface from the service registry center;
[0073] query an address of a service server closest to the account in a geographical distance from the set of addresses.
[0074] In some embodiments, the apparatus further comprises:
[0075] The creating unit is configured to create a coroutine of the non-real-time service through the service server in response to the RPC request.
[0076] The initiating unit is configured to initiate a database operation of the non-real-time service through the coroutine.
[0077] The blocking unit is configured to block and suspend the coroutine before an operation result of the database operation is obtained.
[0078] The returning unit is configured to return a response generated based on the operation result of the database operation after the operation result is obtained.
[0079] In some embodiments, the game service request is a mail list pull request; and the initiating unit is configured to:
[0080] obtain a maximum personal mail sequence number and a maximum system mail sequence number in pulled mails of the account from the mail list pull request through the coroutine.
[0081] initiate, based on the maximum personal mail sequence number, a batch read operation of personal mails to a personal mail set of the account in the database, the batch read operation being configured to read a plurality of personal mails with mail sequence numbers greater than the maximum personal mail sequence number;
[0082] initiate, based on the maximum system mail sequence number, a batch read operation of system mails to a system mail set of the database, the batch read operation being configured to read a plurality of system mails with mail sequence numbers greater than the maximum system mail sequence number.
[0083] In some embodiments, the game service request is a mail list pull request; the initiating unit is configured to perform:
[0084] obtain, by the coroutine, a maximum mail sequence number in the pulled mails of the account carried in the mail list pull request;
[0085] initiate, based on the maximum mail sequence number, a batch read operation of system mails to a system mail set of the database, the batch read operation being configured to read a plurality of system mails with mail sequence numbers greater than the maximum mail sequence number.
[0086] store the plurality of system mails into a personal mail set of the account in the database;
[0087] initiate, based on the maximum mail sequence number, a batch read operation of mails to the personal mail set, the batch read operation being configured to read a plurality of mails with mail sequence numbers greater than the maximum mail sequence number.
[0088] In some embodiments, the apparatus further comprises a generating unit configured to perform:
[0089] determine, based on a plurality of mails returned by an operation result of the batch read operation, a number of unread mails;
[0090] extract an information digest of the plurality of mails, the information digest being configured to provide at least one of the following: mail type, mail title, sender information, mail timestamp, and whether containing an attachment;
[0091] generate a response carrying the information digest and the number of unread mails.
[0092] In some embodiments, the apparatus further comprises a batch processing unit configured to perform:
[0093] in a case where a number of mail list pull requests received in a same time period exceeds a request quantity threshold, cache, by the service server, a plurality of RPC requests associated with the plurality of mail list pull requests into a message queue;
[0094] In the message queue, RPC requests associated with the same mail list pull request sent multiple times by the same initiating account are merged, and a request number variable is configured for the initiating account;
[0095] Based on the request number variable, each RPC request in the message queue is reordered;
[0096] Every interval of a target duration, at least one RPC request in the current batch in the reordered message queue is processed in batches.
[0097] In some embodiments, the game service request is a mail detail pull request; the initiating unit is configured to perform:
[0098] Determine the mail type and mail sequence number requested to be pulled by the mail detail pull request through the coroutine;
[0099] Initiate a read operation on the mail indicated by the mail sequence number in the mail set indicated by the mail type in the database, which is used to read the mail body of the mail and also read the attachment if the mail carries an attachment.
[0100] In some embodiments, the game service request is a mail sending request; the initiating unit is configured to perform:
[0101] Determine the mail type of the to-be-sent mail indicated by the mail sending request through the coroutine;
[0102] In the case of a personal mail, initiate a write operation on the to-be-sent mail in the personal mail set of the account in the database;
[0103] In the case of a system mail, initiate a write operation on the to-be-sent mail in the system mail set of the database.
[0104] In some embodiments, the apparatus further comprises a generating unit configured to perform:
[0105] Based on the operation result of the write operation, assign a mail sequence number to the to-be-sent mail;
[0106] In the case where the recipient account of the to-be-sent mail is in a game offline state, generate a response to notify the account of the success of the mail sending;
[0107] In the case where the recipient account of the to-be-sent mail is in a game online state, generate a response to notify the account of the success of the mail sending; and generate a response to push the to-be-sent mail to the recipient account.
[0108] In some embodiments, the game service request is an unread message retrieval request; the initiating unit is configured to execute:
[0109] The coroutine retrieves the account to be queried and the maximum message identifier from the unread message retrieval request. The maximum message identifier indicates the latest read message in the session between the account and the account to be queried.
[0110] Based on the maximum message identifier, a batch read operation for unread messages is initiated from the message set of the account and the account to be queried in the database. The batch read operation is used to read multiple messages with message identifiers greater than the maximum message identifier.
[0111] In some embodiments, the apparatus further includes a generation unit configured to perform:
[0112] Based on the multiple messages returned by the batch read operation, determine the number of unread messages;
[0113] Generate a response carrying the number of unread messages and the quantity of unread messages.
[0114] In some embodiments, the game service request is a message sending request; the initiating unit is configured to execute:
[0115] The message type of the message to be sent, indicated by the message sending request, is determined by the coroutine.
[0116] When the message type is a personal message, a write operation is initiated on the message to be sent to the message set of the account and the message receiving account in the database;
[0117] When the message type is a group message, a write operation for the message to be sent is initiated to the message set of the message receiving group in the database.
[0118] In some embodiments, the apparatus further includes a generation unit configured to perform:
[0119] Based on the result of the write operation, a message identifier is assigned to the message to be sent, and a response is generated to notify the account that the message has been successfully sent.
[0120] For the personal message, a response to push the message to be sent to the message receiving account is generated only if the message receiving account is online in the game;
[0121] For the group message, retrieve the latest member list of the message receiving group; generate a response to push the message to be sent to the online member account only for the online member account in the latest member list.
[0122] In some embodiments, the game service request is an account addition request, the account addition request is used to apply to add a target account to an account relationship chain of the account; the initiation unit is configured to perform:
[0123] By the coroutine, the account is subjected to permission verification.
[0124] After the verification passes, a database operation of writing a record of account addition of the account to the target account is initiated to the database;
[0125] The apparatus further includes a generation unit configured to perform:
[0126] In a case where the operation result indicates that the writing of the record of account addition is completed, an account addition notification response to the target account is generated.
[0127] According to another aspect of embodiments of the present disclosure, a computer device is provided, comprising:
[0128] one or more processors;
[0129] one or more memories for storing instructions executable by the one or more processors;
[0130] The one or more processors are configured to perform the game service request processing method in any possible implementation manner of the above-mentioned aspect.
[0131] According to another aspect of embodiments of the present disclosure, a computer readable storage medium is provided, when at least one instruction in the computer readable storage medium is executed by one or more processors of a computer device, the computer device is enabled to perform the game service request processing method in any possible implementation manner of the above-mentioned aspect.
[0132] According to another aspect of embodiments of the present disclosure, a computer program product is provided, comprising one or more instructions executable by one or more processors of a computer device, so that the computer device is enabled to perform the game service request processing method in any possible implementation manner of the above-mentioned aspect.
[0133] The technical solutions provided by the embodiments of the present disclosure at least bring the following beneficial effects:
[0134] Through the game service request for requesting a non-real-time service, since the real-time requirement is not high, the game server does not need to locally perform real-time processing, thereby querying, in the service registration center, a service API specially used for processing the non-real-time service, and then performing RPC remote calling on a remote service server through the service API, so that the user load related to the non-real-time service can be migrated from the game server to the service server, resource configuration of the game server is optimized, and since iteration and update for the non-real-time service only need to modify code logic in the service server and modify the service API if necessary, the game main service logic is not patched, development complexity is reduced, game development efficiency is improved, and different types of non-real-time services can be separately deployed in different service servers, so that when some service functions are blocked, normal use of other service functions is not affected, and the game main service logic is also not affected, and game usability is greatly improved.
[0135] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0136] The accompanying drawings incorporated in the specification and forming a part of it, illustrate embodiments consistent with the present disclosure, and together with the description, serve to explain the principles of the present disclosure, and do not constitute an undue limitation on the present disclosure.
[0137] Figure 1 is an implementation environment schematic diagram of a game service request processing method according to an embodiment of the present disclosure;
[0138] Figure 2 is a flowchart of a game service request processing method according to an embodiment of the present disclosure;
[0139] Figure 3 is an interaction flowchart of a game service request processing method according to an embodiment of the present disclosure;
[0140] Figure 4 is a processing flowchart of a mail list pulling service according to an embodiment of the present disclosure;
[0141] Figure 5 is a logical structure diagram of a mail database in a service server according to an embodiment of the present disclosure;
[0142] Figure 6 is a method flowchart of a frame-by-frame processing mail list pulling request according to an embodiment of the present disclosure;
[0143] Figure 7 is a processing flowchart of a mail detail pulling service according to an embodiment of the present disclosure;
[0144] Figure 8 is a processing flowchart of a mail sending service provided by an embodiment of the present disclosure;
[0145] Figure 9 is a processing flowchart of a mail sending service provided by an embodiment of the present disclosure;
[0146] Figure 10 is a processing flowchart of an unread message pulling service provided by an embodiment of the present disclosure;
[0147] Figure 11 is an interaction flowchart of an unread message pulling service provided by an embodiment of the present disclosure;
[0148] Figure 12 is an interaction flowchart of a red dot data pulling service provided by an embodiment of the present disclosure;
[0149] Figure 13 is a processing flowchart of a message sending service provided by an embodiment of the present disclosure;
[0150] Figure 14 is an interaction flowchart of a message sending service provided by an embodiment of the present disclosure;
[0151] Figure 15 is an interaction flowchart of a message sending service provided by an embodiment of the present disclosure;
[0152] Figure 16 is a processing flowchart of an account adding service provided by an embodiment of the present disclosure;
[0153] Figure 17 is an interaction flowchart of an account adding service provided by an embodiment of the present disclosure;
[0154] Figure 18 is a business flowchart of a group service system provided by an embodiment of the present disclosure;
[0155] Figure 19 is a logic structure block diagram of a processing device for a game service request according to an embodiment of the present disclosure;
[0156] Figure 20 is a structural schematic diagram of a computer device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0157] In order for those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings.
[0158] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above drawings are used to distinguish similar objects, and do not necessarily have to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The implementation described in the following exemplary embodiments does not represent all implementations consistent with the present disclosure. Rather, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0159] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.), data (including but not limited to data for analysis, stored data, displayed data, etc.) and signals involved in the present disclosure are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions. For example, the information carried in the game service request involved in the present disclosure is obtained under sufficient authorization.
[0160] In some embodiments, the meaning of A and / or B includes: A and B, A, B, and three cases.
[0161] In the following, the terms related to the embodiments of the present disclosure are explained.
[0162] API (Application Program Interface, Application Program Interface): API is defined as a standard set of applications that can be used to exchange information and commands with the computer operating system. A standard API provides a common programming environment for users or software developers to write applications that can run interactively on different computer manufacturers' computers.
[0163] Service (Service): Service refers to various services in a computer device to support various functions, and some services can be manually turned on or off to achieve the purpose of managing the corresponding functions.
[0164] Micro-Service: a software development technique, which is a variant of Service-Oriented Architecture (SOA) architecture style, advocates dividing a single application into a group of small services, which coordinate and cooperate with each other to provide the final value for users. Each service runs in its own process, and services communicate with each other through a lightweight communication mechanism, which can be RPC (Remote Procedure Call) or RESTful API provided by HTTP (Hyper Text Transfer Protocol). Each service is built around a specific business and can be independently deployed to production environment, production-like environment, etc. In addition, unified and centralized service management mechanism should be avoided, and for a specific service, appropriate language and tool should be selected according to the context.
[0165] Remote Procedure Call (RPC): similar to a three-layer C / S (Client / Server) system, the game server requests services from a remote business server through a network, and the game engine in the game server usually provides services in the game. In the embodiments of the present disclosure, the business server provides APIs for the game server, and the game server calls the APIs matched with different game services to remotely call the standard or custom functions inside the business server indicated by the APIs, and displays or prints the data returned by the functions after processing.
[0166] Coroutine: a coroutine is also a program component like a subroutine. Compared with a subroutine, a coroutine is more general and flexible, and a coroutine is derived from Simula and Modula-2 languages, but other languages also support coroutines.
[0167] The following describes the system architecture related to the embodiments of the present disclosure.
[0168] Figure 1 is an implementation environment schematic diagram of a game service request processing method according to an embodiment of the present disclosure, referring to Figure 1 In the implementation environment, a terminal 110 and a server cluster 120 are included, the server cluster 120 includes at least a game server 121 and one or more business servers 122, and here, an email service server 122a, a message service server 122b and a group service server 122c are taken as examples for description.
[0169] The terminal 110 is installed and runs a game application supporting various game services. The game can be a mobile game or a PC (Personal Computer) game. The game services involve real-time services and non-real-time services. For example, ray detection when a player controls a virtual object to move in the game, damage determination when players control virtual objects to interact, etc. are all real-time services with high real-time requirements. For example, IM (Instant Messaging) messages sent by players in the game, players pulling unread mail lists, etc. are all non-real-time services with low real-time requirements.
[0170] Optionally, the game application described above can be an application originally built in the operating system of the terminal 110, can be a third-party application independently installed on the terminal 110, or can be an embedded game program embedded in other applications. The embodiments of the present disclosure do not specifically limit the implementation mode of the game application. In one example, the game application is also a cloud game application.
[0171] Optionally, the game types provided by the game application include FPS (First-Person Shooting) games, TPS (Third-Personal Shooting) games, MOBA (Multiplayer Online Battle Arena) games, survival building games, open-world games, business building games, exploration games, sandbox games, virtual reality application programs, three-dimensional map programs, or multi-player equipment survival games, etc. The embodiments of the present disclosure do not specifically limit this.
[0172] In some embodiments, the user starts the game application on the terminal 110, and triggers the terminal 110 to send a game service request to the server cluster 120 along with the user's operation in the game application. The game server 121 in the server cluster 120 first receives the game service request, and determines whether to route the game service request to the service server 122 based on the service type indicated by the game service request.
[0173] The terminal 110 is directly or indirectly connected to the server cluster 120 through wired or wireless communication. The embodiments of the present disclosure do not specifically limit this.
[0174] The server cluster 120 is configured to provide background services to the game application running on the terminal 110, and the server cluster 120 includes at least one of a plurality of servers, a cloud computing platform, or a virtualization center. Optionally, the server cluster 120 undertakes primary computing work, and the terminal 110 undertakes secondary computing work; or the server cluster 120 undertakes secondary computing work, and the terminal 110 undertakes primary computing work; or the server cluster 120 and the terminal 110 cooperatively compute in a distributed computing architecture.
[0175] The server cluster 120 involves a game server 121 and a service server 122. The game server 121 is configured to maintain main service logic of a game. For example, a GameSvr process is created in the game server 121 to provide basic gameplay logic of the game. Each game service request from outside is first sent to the GameSvr process of the game server 121, and the GameSvr process decides whether to forward the game service request to the service server 122. The service server 122 can be developed and deployed in a micro-service architecture. For example, each non-real-time service originally tightly coupled with the main service logic in the game server 121 is decomposed into a plurality of independent small services, each of which handles a specific service requirement. The request / response mode can ensure the stateless nature of the small services. The micro-service architecture can facilitate updating and extending each service, and can avoid the availability risk in the tightly coupled mode.
[0176] Optionally, different non-real-time services separated from the main service logic are distributed and deployed in different service servers. For example, a mail service is separated and deployed to a mail service server 122a, a message service is separated and deployed to a message service server 122b, and a group service is separated and deployed to a group service server 122c.
[0177] In some embodiments, the game server 121 in the server cluster 120 first receives each game service request from outside. For each game service request, it is determined whether to route the game service request to the service server 122 based on a service type indicated by the game service request. For example, if a game service associated with the game service request is a real-time service, the game server 121 itself responds to the game service request in real time. If the game service associated with the game service request is a non-real-time service, the game server 121 queries a service server most matched with the game service. For example, if the game service is a mail service, the game server 121 routes the game service request to the mail service server 122a for processing. If the game service is a message service, the game server 121 routes the game service request to the message service server 122b for processing.
[0178] In some embodiments, the server cluster 120 is further configured with a group service server 122c. When the game service involves sending emails or the message service involves sending messages, the email service server 122a or the message service server 122b can send an information message to the group service server 122c to pull the latest member list of the specified group, so as to ensure the timeliness of the group member update, avoid sending incorrect messages to the members who have exited the group, and avoid missing sending messages to the members who have joined the group.
[0179] In some embodiments, the device type of the terminal 110 includes at least one of a smartphone, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player, an MP4 (Moving Picture Experts Group Audio Layer IV) player, a laptop computer, or a desktop computer. For example, the terminal 110 is a smartphone or other handheld portable electronic device. The following embodiments are exemplified by taking the terminal 110 as a smartphone.
[0180] Those skilled in the art can know that the number of the terminal 110 can be more or less. For example, the terminal 110 is only one, or the terminal 110 is dozens or hundreds, or more. The number and device type of the terminal 110 are not limited in the embodiments of the present disclosure.
[0181] Figure 2 is a flowchart of a game service request processing method according to an embodiment of the present disclosure. Referring to Figure 2 The game service request processing method is executed by a computer device, and the following is exemplified by taking the computer device as a game server.
[0182] In step 201, the game server determines the service type of the game service request in response to the game service request of the account, and the service type indicates the timeliness attribute of the game service associated with the game service request.
[0183] The game service request related by the embodiments of the present disclosure refers to a game service request triggered by a user's operation on a terminal, after the user logs in an account on a game application of the terminal. The game service request carries at least a service identification (ID) of a requested game service and a service parameter matched with the game service. Optionally, the game service request can also carry a service type of the game service. The service ID is used to indicate which service the game service is, the service type is used to indicate whether the time attribute of the game service is a real-time service or a non-real-time service, and the service parameter is a related parameter necessary for the terminal to request the game service.
[0184] In some embodiments, the game server creates a GameSvr process to provide basic game play logic of the game. Each game service request from outside is first sent to the GameSvr process. The GameSvr process analyzes the game service request, such as analyzing a header field of the game service request to obtain a service ID recorded in the header field, analyzing a data field of the game service request to obtain a service parameter recorded in the data field, and then querying a service type to which the service ID belongs. If the service type is a real-time service, the GameSvr process processes the game service request. If the service type is a non-real-time service, the following step 202 is entered.
[0185] In other embodiments, the service type is directly carried in the real-time service. For example, the service type is encapsulated into the header field of the game service request. The GameSvr process of the game server analyzes the header field to obtain the service ID and the service type recorded in the header field. Then, if the service type is a real-time service, the GameSvr process processes the game service request. If the service type is a non-real-time service, the following step 202 is entered. In some embodiments, the service type can also be encapsulated into the data field of the game service request, which is not specifically limited by the embodiments of the present disclosure.
[0186] In step 202, in the case that the service type indicates that the game service is a non-real-time service, the game server determines a service interface matched with the non-real-time service.
[0187] In some embodiments, in the case that the service type to which the game service belongs is a non-real-time service, the GameSvr process does not need to spend resources to process the game service request in real time. The game server can route the game service request to a service server supporting the game service to process the game service request, which can save the processing resources of the game server and optimize the resource configuration of the game server.
[0188] In some embodiments, under the architecture that decouples the non-real-time service from the game server and deploys it to the service server to which it belongs independently, each non-real-time service is configured with a corresponding service API, which can inject the service parameters of the non-real-time service into an RPC request through the invocation of the GameSvr process and send the RPC request to the service server indicated by the service API.
[0189] In some embodiments, the game server queries the service API associated with the service ID of the non-real-time service based on the service ID of the non-real-time service. Alternatively, the game server queries the service API associated with the service name of the non-real-time service based on the service name of the non-real-time service, and the embodiments of the present disclosure do not make specific limitations on whether the service API is stored in correspondence with the service name or the service ID.
[0190] In step 203, the game server queries the address of the service server for providing the service interface from a service registration center, which is used to record the addresses of service servers of various interfaces.
[0191] In some embodiments, whenever a non-real-time service is decoupled from the game server, the service API of the non-real-time service and the address of the corresponding service server are registered in the service registration center, that is, the mapping relationship between each pair of service API and service server address is recorded in the service registration center. Alternatively, the mapping relationship is stored in the form of hash table, linked list, dynamic array, Key-Value data structure, etc., which will not be described here.
[0192] In some embodiments, after the game server queries the service API of the current game service based on step 202, it queries the mapping relationship in the service registration center, so as to obtain the address of the service server for providing the service API, which can include the IP (Internet Protocol) address and the communication port.
[0193] In step 204, the game server sends an RPC request to the address based on the service interface, which is used to instruct the service server to provide the response to the game service to the account.
[0194] In some embodiments, the game server invokes the service API, injects the service parameters parsed from the game service request into the service API, and then encapsulates the RPC request based on the injected service parameters and forwards the RPC request to the address obtained in step 203, so as to implement the scheme of initiating the game service request to the service based on the RPC framework.
[0195] In some embodiments, under the micro-service framework, a service API (which can be regarded as a micro-service interface) of each non-real-time business is configured with a separate business server, and the database clusters of different business servers are independent and environment-isolated, so that the database operation of one non-real-time business does not affect other non-real-time businesses, and different services are independent and no longer tightly coupled, avoiding the problem of fault cascade caused by the failure of a certain service in a tightly coupled case. Under such a micro-service framework, even if a certain service fails, it will only cause a single service to be unavailable, and will not affect the normal function of other services, greatly improving the overall availability of the service.
[0196] The method provided by the embodiments of the present disclosure can query the service API dedicated to processing the non-real-time business in the service registration center, and then perform RPC remote calling on the remote business server through the service API, so as to migrate the user load related to the non-real-time business from the game server to the business server, optimize the resource configuration of the game server, and only need to modify the code logic in the business server and the service API when iterating and updating the non-real-time business, without patching the main business logic of the game, thereby reducing the development complexity and improving the game development efficiency. In addition, different types of non-real-time businesses can be deployed in different business servers, so that when some business functions are blocked, it will not affect the normal use of other business functions, and will not affect the main business logic of the game, thereby greatly improving the game availability.
[0197] In some embodiments, querying the address of the business server for providing the service interface from the service registration center comprises:
[0198] querying a set of addresses for providing the service interface from the service registration center;
[0199] querying the address of the business server closest to the geographical distance of the account from the set of addresses.
[0200] In some embodiments, the method further comprises:
[0201] creating a coroutine of the non-real-time business by the business server in response to the RPC request;
[0202] initiating a database operation of the non-real-time business through the coroutine;
[0203] blocking and suspending the coroutine before obtaining the operation result of the database operation;
[0204] returning a response generated based on the operation result of the database operation after obtaining the operation result.
[0205] In some embodiments, the game service request is a mail list pull request; initiating, by the coroutine, the database operation of the non-real-time service comprises:
[0206] Obtaining, by the coroutine, from the mail list pull request, a maximum personal mail sequence number and a maximum system mail sequence number in the pulled mails of the account;
[0207] Based on the maximum personal mail sequence number, initiating a batch read operation of personal mails to the personal mail set of the account in the database, the batch read operation being used to read multiple personal mails with mail sequence numbers greater than the maximum personal mail sequence number;
[0208] Based on the maximum system mail sequence number, initiating a batch read operation of system mails to the system mail set of the database, the batch read operation being used to read multiple system mails with mail sequence numbers greater than the maximum system mail sequence number.
[0209] In some embodiments, the game service request is a mail list pull request; initiating, by the coroutine, the database operation of the non-real-time service comprises:
[0210] Obtaining, by the coroutine, from the mail list pull request, a maximum mail sequence number in the pulled mails of the account;
[0211] Based on the maximum mail sequence number, initiating a batch read operation of system mails to the system mail set of the database, the batch read operation being used to read multiple system mails with mail sequence numbers greater than the maximum mail sequence number;
[0212] Storing the multiple system mails into the personal mail set of the account in the database;
[0213] Based on the maximum mail sequence number, initiating a batch read operation of mails to the personal mail set, the batch read operation being used to read multiple mails with mail sequence numbers greater than the maximum mail sequence number.
[0214] In some embodiments, the method further comprises:
[0215] Determining a number of unread mails based on the multiple mails returned by the operation result of the batch read operation;
[0216] Extracting an information digest of the multiple mails, the information digest being used to provide at least one of the following: mail type, mail title, sender information, mail timestamp, and whether containing an attachment;
[0217] Generating a response carrying the information digest and the number of unread mails.
[0218] In some embodiments, the method further comprises:
[0219] In a case where the number of the plurality of mail list pull requests received in the same time period exceeds the request quantity threshold, caching, by the service server, the plurality of RPC requests associated with the plurality of mail list pull requests into a message queue;
[0220] In the message queue, merging the RPC requests associated with the same mail list pull requests sent multiple times by the same initiating account, and configuring a request quantity variable for the initiating account;
[0221] Based on the request quantity variable, reordering the respective RPC requests in the message queue;
[0222] Every interval of a target duration, processing at least one RPC request in a current batch in the reordered message queue in batches.
[0223] In some embodiments, the game service request is a mail detail pull request; and the database operation of the non-real-time service initiated by the coroutine comprises:
[0224] Determining, by the coroutine, a mail type and a mail sequence number requested to be pulled by the mail detail pull request;
[0225] Initiating, to a mail set indicated by the mail type in the database, a read operation on a mail indicated by the mail sequence number, the read operation being used to read a mail body of the mail and, in a case where the mail carries an attachment, also read the attachment.
[0226] In some embodiments, the game service request is a mail sending request; and the database operation of the non-real-time service initiated by the coroutine comprises:
[0227] Determining, by the coroutine, a mail type of a to-be-sent mail indicated by the mail sending request;
[0228] In a case where the mail type is a personal mail, initiating, to a personal mail set of the account in the database, a write operation on the to-be-sent mail;
[0229] In a case where the mail type is a system mail, initiating, to a system mail set of the database, a write operation on the to-be-sent mail.
[0230] In some embodiments, the method further comprises:
[0231] Based on an operation result of the write operation, assigning a mail sequence number to the to-be-sent mail;
[0232] In a case where a recipient account of the to-be-sent mail is in a game offline state, generating a response notifying the account of a mail sending success;
[0233] In a case where the account of the mail receiver is in an online state of the game, a response of notifying the account of the success of the mail sending is generated, and a response of pushing the mail to be sent to the account of the receiver is generated.
[0234] In some embodiments, the game service request is a message pulling request, and the database operation of the non-real-time service initiated by the coroutine includes:
[0235] The account to be queried and a maximum message identifier are obtained from the message pulling request by the coroutine, the maximum message identifier indicating a latest read message in a session of the account and the account to be queried.
[0236] Based on the maximum message identifier, a batch read operation of unread messages is initiated to a message set of the account and the account to be queried in the database, the batch read operation being used to read a plurality of messages with message identifiers greater than the maximum message identifier.
[0237] In some embodiments, the method further includes:
[0238] Based on the plurality of messages returned by the operation result of the batch read operation, a number of unread messages is determined.
[0239] A response carrying the plurality of unread messages and the number of unread messages is generated.
[0240] In some embodiments, the game service request is a message sending request, and the database operation of the non-real-time service initiated by the coroutine includes:
[0241] The message type of the message to be sent indicated by the message sending request is determined by the coroutine.
[0242] In a case where the message type is a personal message, a write operation of the message to be sent is initiated to a message set of the account and a message receiving account in the database.
[0243] In a case where the message type is a group message, a write operation of the message to be sent is initiated to a message set of a message receiving group in the database.
[0244] In some embodiments, the method further includes:
[0245] Based on the operation result of the write operation, a message identifier is assigned to the message to be sent, and a response of notifying the account of the success of the message sending is generated.
[0246] For the personal message, only in a case where the message receiving account is in an online state of the game, a response of pushing the message to be sent to the message receiving account is generated.
[0247] For the group message, a latest member list of the message receiving group is pulled; only for online member accounts in the latest member list, a response of pushing the to-be-sent message to the online member account is generated.
[0248] In some embodiments, the game service request is an account addition request, the account addition request is used to apply to add a target account to an account relationship chain of the account; initiating, by the coroutine, the database operation of the non-real-time service includes:
[0249] Performing, by the coroutine, permission verification on the account;
[0250] After the verification passes, initiating, to a database, a database operation of writing an account addition record from the account to the target account;
[0251] After obtaining an operation result of the database operation, returning a response generated based on the operation result includes:
[0252] In a case where the operation result indicates that the account addition record is written completely, generating an account addition notification response to the target account.
[0253] All the optional technical solutions described above can be combined to form optional embodiments of the present disclosure, which will not be described one by one here.
[0254] Figure 3 is an interactive flowchart of a game service request processing method according to an embodiment of the present disclosure, as shown in Figure 3 The game service request processing method is implemented by interaction between a game server and a service server, the game server and the service server can constitute a server cluster providing game services externally, and the game server and the service server are exemplary descriptions of computer devices, and the embodiment includes the following steps.
[0255] In step 301, the game server determines the service type of the game service request in response to the game service request of the account.
[0256] The service type indicates the timeliness attribute of the game service associated with the game service request.
[0257] In some embodiments, the game server creates a GameSvr process to provide basic gameplay logic of the game, each game service request from the outside is first sent to the GameSvr process, and the GameSvr process parses the game service request.
[0258] Optionally, the game service request carries the service ID and the service parameter, the GameSvr process parses the header field of the game service request to obtain the service ID recorded in the header field, and parses the data field of the game service request to obtain the service parameter recorded in the data field.
[0259] In this case, the game server side can record a mapping relationship between the service ID and the service type, and the mapping relationship is stored in a hash table, a linked list, a dynamic array, a Key-Value data structure, etc., which will not be described herein. After the service ID is parsed from the header field, the mapping relationship between the service ID and the service type is queried to obtain the service type to which the service ID belongs. The service type is used to indicate the time attribute of the game service indicated by the service ID in terms of time, such as real-time service and non-real-time service.
[0260] Optionally, the game service request carries the service ID, the service type and the service parameter, the GameSvr process parses the header field of the game service request to obtain the service ID and the service type recorded in the header field, and parses the data field of the game service request to obtain the service parameter recorded in the data field; or the GameSvr process parses the header field of the game service request to obtain the service ID recorded in the header field, and parses the data field of the game service request to obtain the service type and the service parameter recorded in the data field.
[0261] In one example, the header field or the data field of the game service request carries a Real-Time variable, and the Real-Time variable is used to indicate the service type of the game service. Optionally, the Real-Time variable is a binary variable, and if the Real-Time variable takes a value of 0, it represents non-real-time service, and if the Real-Time variable takes a value of 1, it represents real-time service. If the Real-Time variable is default, it can be considered to take a default value, which is 0 or 1, and the default value is preconfigured by the technician on the game server side. Alternatively, the Real-Time variable is a Boolean variable, and if the Real-Time variable takes a value of False, it represents non-real-time service, and if the Real-Time variable takes a value of True, it represents real-time service. If the Real-Time variable is default, it can be considered to take a default value, which is False or True, and the default value is preconfigured by the technician on the game server side.
[0262] In another embodiment, a Real-Time field is set in a header field or a data field of the game service request, or is set between the header field and the data field, and the Real-Time field is used to record the service type, so that the service type can be obtained by parsing the Real-Time field. For example, the service type recorded in the Real-Time field is a string variable, and the string variable takes a value of "Real-Time" to indicate a real-time service, or takes a value of "Non-Real-Time" to indicate a non-real-time service. Alternatively, the service type recorded in the Real-Time field is a binary variable or a Boolean variable, which is not limited in the embodiments of the present disclosure.
[0263] In some embodiments, if the service type obtained by the game server is a real-time service, the game service request is processed by the GameSvr process, and if the service type is a non-real-time service, the following step 302 is entered.
[0264] In step 302, if the service type indicates that the game service is a non-real-time service, the game server determines a service interface matched with the non-real-time service.
[0265] In some embodiments, if the service type to which the game service belongs is a non-real-time service, the GameSvr process does not need to spend resources to process the game service request in real time, and the game server can route the game service request to a service server supporting the game service to process the game service request, so that the processing resources of the game server can be saved and the resource configuration of the game server can be optimized.
[0266] In some embodiments, in the architecture in which the non-real-time service is decoupled from the game server and independently deployed to the service server to which the non-real-time service belongs, a corresponding service API is configured for each non-real-time service. The service API can inject the service parameters of the non-real-time service into an RPC request by calling the GameSvr process, and send the RPC request to the service server indicated by the service API.
[0267] In some embodiments, the game server queries the service API associated with the service ID of the non-real-time service based on the service ID of the non-real-time service. Alternatively, the game server queries the service API associated with the service name of the non-real-time service based on the service name of the non-real-time service, and the embodiments of the present disclosure do not limit whether the service API is stored in association with the service name or the service ID.
[0268] In step 303, the game server queries the address of the service server for providing the service interface from a service registration center.
[0269] The service registry is configured to record the addresses of the service servers of various interfaces.
[0270] In some embodiments, whenever a non-real-time service is decoupled from the game server, the service API of the non-real-time service and the address of the corresponding service server are registered in the service registry, i.e., the mapping relationship between each service API and the address of the service server is recorded in the service registry. Optionally, the mapping relationship between the service API and the address of the service server is stored in the form of a hash table, a linked list, a dynamic array, a Key-Value data structure, etc., which will not be described here.
[0271] In some embodiments, after the game server queries the service API of the current game service based on step 302, the mapping relationship in the service registry is queried, and the address of the service server for providing the service API is obtained, which optionally includes an IP (Internet Protocol) address and a communication port.
[0272] In some embodiments, the service servers deployed for the same non-real-time service are not a single server, but a plurality of servers deployed in various places in a CDN (Content Delivery Network) architecture. In this case, when each service API is registered in the service registry, the address set composed of the respective addresses of a group of service servers is recorded. On this basis, the game server queries the address set for providing the service API from the mapping relationship in the service registry, and then, since the address set records the respective addresses of a group of service servers, the game server can query the address of the service server closest to the account in geographical distance from the address set. For example, under the condition of obtaining sufficient authorization of the user, the IP country of the account is determined, and the address of the service server in the same IP country is found in the address set. If there are multiple addresses of service servers in the same IP country, the address of the service server closest in geographical distance is selected. If the address of the service server in the same IP country is not found in the address set, the search range is expanded, and the address of the service server closest in geographical distance is found from the addresses of the service servers in the adjacent IP country, which is not specifically limited in the embodiments of the present disclosure.
[0273] Optionally, only for part of the relatively busy non-real-time services, the CDN architecture is used for distributed deployment of the service server, for the remaining relatively idle non-real-time services, a service server is independently deployed, or for all non-real-time services, the CDN architecture is used for distributed deployment of the service server, or for all non-real-time services, a service server is independently deployed, and the deployment mode of the service server is not limited in the embodiments of the present disclosure.
[0274] In the above process, by using the CDN architecture for distributed deployment of part or all of the non-real-time services, the game service request of each account can be routed from the game server to the service server closest in geographical distance according to the nearest principle, and the non-real-time service is provided by the service server closest in geographical distance, which greatly improves the processing efficiency and response speed of the non-real-time service.
[0275] In step 304, the game server sends an RPC request to the address of the service server based on the service interface.
[0276] The RPC request is used to instruct the service server to provide a response to the game service to the account.
[0277] In some embodiments, the game server calls the service API, injects the service parameters parsed from the game service request into the service API, then encapsulates the RPC request based on the injected service parameters, and forwards the RPC request to the address obtained in step 303, to realize the scheme of initiating a game service request based on the RPC framework to the service.
[0278] In some embodiments, under the micro-service framework, for each non-real-time service service API (which can be regarded as a micro-service interface), a service server is configured for it, and the database clusters of different service servers are independent and environmentally isolated, so that the database operation of one non-real-time service does not affect other non-real-time services, and different services are independent and not tightly coupled, avoiding the problem of fault cascade caused by the failure of a service in a tightly coupled situation. Under such a micro-service framework, even if a service fails, only the single service is unavailable, and the normal function of other services is not affected, which greatly improves the overall availability of the service.
[0279] Further, the service registration center and the RPC framework can be directly supported by the original game engine in the game server, and the service API can isolate the stateless RPC request of the non-real-time service from the stateful game service request of the real-time service by encapsulating the RPC request. Here, stateful and stateless refer to whether a state machine needs to be maintained during service processing.
[0280] For example, for real-time services with high real-time requirements, such as real-time skill casting, damage statistics, ray detection, in-game intercom, etc., a link between the player client, the game server and the player client needs to be maintained for such real-time services, and a state machine needs to be maintained to process stateful game service requests. Such real-time services are processed and responded by the GameSvr process of the game server. For non-real-time services with low real-time requirements, such as non-real-time mail services, message services, friend services, ranking list services, etc., the terminal encapsulates the service parameters of the non-real-time service into a game service request each time the terminal needs to access the non-real-time service, and sends the game service request to the game server. Then, the terminal can continue to perform other operations, wait for the business server to directly return a response, or the business server generates a response and then calls the game server to notify the game server, and then the game server returns a response to the terminal. In this way, the non-real-time service does not block the game thread on the terminal side or the GameSvr process on the game server side. Instead, the non-real-time service is separated from the overall architecture and implemented through a micro-service architecture, which can optimize the resource configuration of the server cluster and improve the availability of game services. The following steps 305-308 will describe the processing flow on the business server side in detail.
[0281] In step 305, the business server creates a coroutine for the non-real-time service in response to the RPC request.
[0282] In some embodiments, coroutine development is adopted on the business server side. In the coroutine development, the business server creates a new coroutine for each RPC request. When the non-real-time service associated with the RPC request involves database operations (such as read operations or write operations), the current coroutine is triggered to be blocked. In this way, the blocking of the current coroutine does not affect the running of the main thread on the business server. If multiple coroutines involve database operations and enter the blocked state at the same time, the main thread selects one of the existing coroutines to execute, and the blocked coroutine is suspended until the main thread selects itself as the execution unit and obtains the execution result of the database operation.
[0283] In the above process, by adopting coroutine development, the overhead of the coroutine is smaller than that of the thread when the CPU schedules database resources, which can save the processing resources of the business server.
[0284] In some embodiments, a main thread is maintained on the service server, which, in response to the RPC request from the service API in step 304, parses the RPC request, obtains the service parameters of the non-real-time service, and determines whether the non-real-time service involves database operation. In the case where the non-real-time service involves database operation, a coroutine is newly created for the non-real-time service.
[0285] Optionally, in the creation of the coroutine, a gevent coroutine is created based on a third-party coroutine library gevent of python. Since the gevent coroutine can have an event loop by itself and find other executable coroutines when the main thread executes a function that blocks the current coroutine, the development difficulty can be simplified, or other types of coroutines can also be created in other ways, and the type of the created coroutine is not specifically limited here.
[0286] In step 306, the service server initiates the database operation of the non-real-time service through the coroutine.
[0287] In some embodiments, in the case where the non-real-time service involves database operation, the service server performs SQL (Structured Query Language) parsing based on the service parameters of the non-real-time service through the main thread or the coroutine to obtain the SQL statement of a transaction. The transaction refers to a transaction created for the database operation involved in the non-real-time service, and the database operation involves read operation and write operation. After obtaining the SQL statement of the transaction, it is considered that the database operation of the non-real-time service has been initiated. However, since there can be multiple coroutines waiting for processing at the same time in the main thread, it is usually necessary to add a lock to each data record operated by the currently awakened coroutine to ensure the consistency of the database. If the added lock is a shared lock, other coroutines applying for a shared lock can be processed in parallel, and if the added lock is an exclusive lock, other coroutines applying for the lock of the data record can only be awakened after the current coroutine is processed and the lock is released. Therefore, after generating the SQL statement of the transaction, the coroutine caches the SQL statement of the transaction, blocks the current transaction, suspends the coroutine, and waits for the main thread to awaken the coroutine.
[0288] In step 307, the service server blocks and suspends the coroutine before obtaining the operation result of the database operation.
[0289] In some embodiments, before the main thread of the business server wakes up the current coroutine, the coroutine will be in a suspended state and needs to block the transaction until the main thread wakes up the current coroutine, at which time the database operation is performed by the coroutine or the main thread based on the SQL statement of the transaction on the data records involved in the SQL statement in the underlying database, and the operation result of the database operation is waited for from the underlying database. Optionally, the underlying database is a Mango database, a Redis storage cluster, or other architecture database, and the embodiments of the present disclosure are not limited in this regard.
[0290] In step 308, the business server returns a response generated based on the operation result after obtaining the operation result of the database operation.
[0291] In some embodiments, the operation result of the database operation by the underlying database includes transaction commit or transaction rollback. If the operation result is transaction commit, it means that the database operation is executed and has been written to the disk, and an operation success response for non-real-time business needs to be returned, and in the case of returning business data, the business data is further obtained based on the data read or written by the SQL statement, the business data is encapsulated into the operation success response, and in the case of not returning business data, the operation success response can be implemented as an ACK (Acknowledge Character, acknowledgment character) message. If the operation result is transaction rollback, it means that the database operation fails and causes transaction rollback, and an operation failure response for non-real-time business needs to be returned, for example, the operation failure response is provided as a string of error codes or a command carrying an operation failure identifier, and the embodiments of the present disclosure are not limited in this regard.
[0292] In some embodiments, after the business server generates the above-mentioned response (operation success response or operation failure response) for non-real-time business, the business server directly returns the above-mentioned response to the terminal, which can save communication overhead, or the business server returns the above-mentioned response to the game server through a service API, so that the game server sends the above-mentioned response to the terminal, which can reduce the perceptibility of the terminal and ensure that the terminal is not aware of the business server, and the micro-service framework is transparent to the user side.
[0293] The method provided by the embodiments of the present disclosure can, by the game service request for requesting a non-real-time service, since the real-time requirement is not high, not need to be processed in real time by the game server locally, thereby querying, in the service registration center, a service API specially used for processing the non-real-time service, and then performing RPC remote calling on a remote service server through the service API, so that the user load related to the non-real-time service can be migrated from the game server to the service server, the resource configuration of the game server is optimized, and since the iteration and update for the non-real-time service only need to modify the code logic in the service server and modify the service API if necessary, the game main service logic is not patched, the development complexity is reduced, the game development efficiency is improved, and different types of non-real-time services can be deployed in different service servers, so that when some service functions are blocked, the normal use of other service functions is not affected, and the game main service logic is also not affected, and the game usability is greatly improved.
[0294] All the optional technical solutions described above can be combined to form optional embodiments of the present disclosure, which will not be described again.
[0295] In the above embodiment, how the game server and the service server interact to migrate the game service request of the non-real-time service to the service server for processing is simply introduced, so as to relieve the load pressure of the game server, and also improve the fault cascade problem caused by a single non-real-time service. In the following several embodiments, the details of the processing flow of the service server will be introduced by taking two specific service scenarios, i.e., the mail service scenario and the chat service scenario, as examples. The following will be described.
[0296] (I) Mail list pulling service
[0297] Figure 4 is a processing flow diagram of a mail list pulling service provided by the embodiments of the present disclosure, as shown in FIG. 8, taking the game service request initiated by the terminal side account as a mail list pulling request as an example, the processing method of the mail list pulling request is executed by the service server, the service server can be a server integrating processing of various non-real-time services, or a separately deployed mail service server, wherein the service server is an exemplary illustration of a computer device. Figure 4
[0298] It should be noted that only the processing flow after the game server sends the RPC request corresponding to the mail list pulling request to the service server and the service server creates a coroutine is described herein, that is, the scheme of the embodiments of the present disclosure is implemented after step 305 in the above embodiment, and how the RPC request is sent from the game server to the service server and how the service server creates a coroutine are described in the above embodiment, which will not be described again.
[0299] In some embodiments, since two types of mail are involved in the game: personal mail and system mail, the personal mail refers to the mail sent by a player to another player (i.e., game account to game account), and the system mail refers to the mail sent by the game system or the game administrator to all players in the server. Optionally, the business server side assigns different mail sequence numbers to personal mail and system mail, and keeps each mail sequence number increasing, or the business server side adopts a unified coded mail sequence number for personal mail and system mail, and keeps the mail sequence number increasing. For the two different mail sequence number assignment methods, the business server side mail list pulling process is also different, which will be described below.
[0300] Case one, personal mail and system mail are coded separately
[0301] In the case of separate coding of personal mail and system mail, each personal mail has a unique personal mail sequence number, and each system mail also has a unique system mail sequence number. The personal mail sequence number and the system mail sequence number can be assigned based on the same or different coding method, and both the personal mail sequence number and the system mail sequence number are kept increasing.
[0302] In step 306-A1, the business server obtains the maximum personal mail sequence number and the maximum system mail sequence number in the pulled mail of the account carried in the mail list pulling request through the coroutine.
[0303] In some embodiments, in the case of separate coding of personal mail and system mail, the terminal side will determine the maximum personal mail sequence number and the maximum system mail sequence number in the pulled mail of the account currently logged into the game application when initiating the mail list pulling request. For example, the above maximum personal mail sequence number and maximum system mail sequence number are encapsulated as business parameters in the mail list pulling request. After the game server parses the above business parameters, the above business parameters are injected into the mail service API. The mail service API initiates an RPC request to the business server, and the RPC request carries the business parameters injected in the above mail service API, so that after the business server creates a coroutine, the coroutine can obtain the maximum personal mail sequence number and the maximum system mail sequence number through the business parameters provided by the mail service API.
[0304] In the above process, since the terminal side provides the maximum mail sequence number of each type of pulled mail in the mail list pulling request, the business server can directly read the maximum personal mail sequence number and the maximum system mail sequence number transmitted in the mail service API, without the need for the business server to parse the mail list pulling request twice, which can save the processing resources of the business server.
[0305] In step 306-A2, the business server initiates a batch reading operation of the personal mails in the personal mail set of the account in the database based on the maximum personal mail sequence number, to obtain multiple personal mails with mail sequence numbers greater than the maximum personal mail sequence number.
[0306] The batch reading operation is used to read the multiple personal mails with mail sequence numbers greater than the maximum personal mail sequence number.
[0307] In some embodiments, the database referred to by the embodiments of the present disclosure refers to a mail database, which can be a Mango database, a SQL database or other types of databases, and the type of database is not specifically limited here. Optionally, a global system mail set is maintained in the mail database, used to store all system mails, and a personal mail set of each account is also maintained, used to store all personal mails of the account.
[0308] In some embodiments, in the case of separately maintaining a mail database on the business server side, after obtaining the maximum personal mail sequence number through step 306-A1, the personal mail set of the account is queried with the account ID of the account as the index, the personal mails in the personal mail set are arranged in order from small to large according to the mail sequence number, and then the next personal mail after the latest read personal mail indicated by the maximum personal mail sequence number is read backward one by one until there is no new readable personal mail, i.e. all personal mails with mail sequence numbers greater than the maximum personal mail sequence number are obtained.
[0309] In step 306-A3, the business server initiates a batch reading operation of the system mails in the system mail set of the database based on the maximum system mail sequence number, to obtain multiple system mails with mail sequence numbers greater than the maximum system mail sequence number.
[0310] The batch reading operation is used to read the multiple system mails with mail sequence numbers greater than the maximum system mail sequence number.
[0311] In some embodiments, in the case of separately maintaining a mail database on the business server side, after obtaining the maximum system mail sequence number through step 306-A1, the system mail set in the mail database is queried, the system mails in the system mail set are arranged in order from small to large according to the mail sequence number, and then the next system mail after the latest read system mail indicated by the maximum system mail sequence number is read backward one by one until there is no new readable system mail, i.e. all system mails with mail sequence numbers greater than the maximum system mail sequence number are obtained.
[0312] In the above process, only the case where the mail list pull request indicates the business server to obtain all the personal mails and all the system mails that have not been pulled is described as an example. In some embodiments, it is assumed that after the account switching device, the terminal newly switched to may have many mails that have not been pulled. If all the mails that have not been pulled are obtained at one time, the response speed is likely to be very slow. Therefore, the user can choose to pull only the last 50, the last 100, the last 200, etc. At this time, the mail pull quantity business parameter can be added to the mail list pull request. In this case, all the mails that have not been pulled can be found, and the latest multiple mails that meet the mail pull quantity can be selected.
[0313] In steps 306-A1 to 306-A3, a possible implementation of the database operation of the business server initiated by the coroutine for non-real-time business is provided, i.e., in the case of separate coding of personal mails and system mails, batch read operations are initiated from the personal mail set according to the maximum personal mail sequence number, and batch read operations are initiated from the system mail set according to the maximum system mail sequence number.
[0314] This way of separate coding of personal mails and system mails only needs to perform a read operation for each system mail that has not been pulled and each personal mail that has not been pulled, i.e., reading the system mail from the system mail set and reading the personal mail from the personal mail set, without involving backup of the system mail (not to mention reordering during backup), so the database operation has small overhead and high transaction execution efficiency. However, in the case of carrying the mail pull quantity in the business parameter, the calculation overhead may be slightly increased because the personal mail sequence number and the system mail sequence number need to be compared.
[0315] Case two, unified coding of personal mails and system mails
[0316] In other embodiments, a unified coding method of personal mails and system mails is also provided. In this way, the personal mail sequence number and the system mail sequence number will no longer be distinguished. Each personal mail or system mail will be assigned a unique mail sequence number, and the mail sequence number will be kept globally increasing.
[0317] In step 306-B1, the business server obtains the maximum mail sequence number in the pulled mails of the account carried in the mail list pull request through the coroutine.
[0318] In some embodiments, in the case of unified encoding of personal mails and system mails, the terminal side determines the maximum mail sequence number in the pulled mails of the account currently logged in the game application when initiating the mail list pulling request, such as encapsulating the maximum mail sequence number as a business parameter into the mail list pulling request, and the game server injects the business parameter into the mail service API after parsing the business parameter, initiates an RPC request to the business server by the mail service API, and carries the injected business parameter in the mail service API in the RPC request, so that the business server can obtain the maximum mail sequence number through the business parameter provided by the mail service API after creating the coroutine.
[0319] In the above process, since the terminal side provides the global maximum mail sequence number in the mail list pulling request, the business server can directly read the maximum mail sequence number transmitted in the mail service API, without the need for the business server to parse the mail list pulling request again, thereby saving the processing resources of the business server.
[0320] In step 306-B2, the business server initiates a batch reading operation of system mails to the system mail set of the database based on the maximum mail sequence number, and obtains multiple system mails with mail sequence numbers greater than the maximum mail sequence number.
[0321] The batch reading operation is used to read the multiple system mails with mail sequence numbers greater than the maximum mail sequence number.
[0322] In some embodiments, the database involved in the embodiments of the present disclosure refers to a mail database, which can be a Mango database, a SQL database or other types of databases, and the type of database is not limited here. Optionally, the mail database maintains a global system mail set for storing all system mails, and also maintains a personal mail set for each account for storing all personal mails of the account.
[0323] In some embodiments, in the case of separately maintaining a mail database on the business server side, after obtaining the maximum mail sequence number through step 306-B1, the system mail set in the mail database is queried, the system mails in the system mail set are arranged in order from small to large according to the mail sequence number, and then the next system mail after the latest read system mail indicated by the maximum mail sequence number is read backward one by one until there is no new readable system mail, that is, all system mails with mail sequence numbers greater than the maximum mail sequence number are obtained.
[0324] In step 306-B3, the business server stores the multiple system mails in the personal mail set of the account in the database.
[0325] In some embodiments, in order to facilitate the batch reading of the mails, in the case of unified encoding of the personal mails and the system mails, after the business server reads all the system mails with the mail sequence number greater than the maximum mail sequence number based on step 306-B2, the business server can also locate the personal mail set of the account in the mail database based on the account ID of the account as the index, and store all the system mails with the mail sequence number greater than the maximum mail sequence number into the personal mail set of the account, so as to facilitate the subsequent one-time scanning of all the un-pulled mails in the personal mail set.
[0326] In some embodiments, when storing all the system mails into the personal mail set, the business server needs to store them in the order of the mail sequence number from small to large, that is, to ensure that all the mails in the personal mail set still maintain the order of the mail sequence number in ascending order after all the system mails are stored into the personal mail set (cannot be out of order). Specifically, when storing each system mail, the business server finds the target mail with the mail sequence number closest to and not exceeding the current system mail in the personal mail set, and inserts the current system mail after the target mail (next to the target mail), so as to ensure that the system mails will not be out of order when stored.
[0327] In other embodiments, after the business server stores all the system mails into the personal mail set, the business server reorders the personal mail set in the order of the mail sequence number from small to large, so that there is no need to consider whether the mails are out of order when stored, but the resource consumption is large due to the reordering of the personal mail set.
[0328] In step 306-B4, the business server initiates a batch reading operation of the mails based on the maximum mail sequence number to the personal mail set, and obtains multiple mails with the mail sequence number greater than the maximum mail sequence number.
[0329] The batch reading operation is used to read the multiple mails with the mail sequence number greater than the maximum mail sequence number.
[0330] In some embodiments, after the business server stores all the system mails with the mail sequence number greater than the maximum mail sequence number into the personal mail set of the account, in the case that all the mails (personal mails and system mails) in the personal mail set are arranged in the order of the mail sequence number from small to large, the reading starts from the next mail of the latest read mail indicated by the maximum mail sequence number and goes backward until there is no new mail to be read, so as to obtain all the mails with the mail sequence number greater than the maximum mail sequence number.
[0331] The above process is illustrated using the example of a mail list retrieval request instructing the business server to retrieve all unretrieved emails. In some embodiments, it is assumed that after an account switches devices, the newly switched terminal may have many unretrieved emails. If all unretrieved emails are retrieved at once, the response speed may be very slow. Therefore, users can choose to retrieve only the most recent 50, 100, or 200 emails, etc. In this case, a business parameter for the number of emails to retrieve can be added to the mail list retrieval request. In this case, after finding all unretrieved emails, the latest multiple emails that meet the email retrieval requirement can be selected. Alternatively, after storing all system emails with email sequence numbers greater than the maximum email sequence number into the account's personal email set, the system can start reading from the latest email in the personal email set (referring to the email with the largest email sequence number) and proceed backwards until multiple emails that meet the email retrieval requirement are read, and then stop reading.
[0332] In steps 306-B1 to 306-B4 above, a possible implementation method is provided for the business server to initiate database operations for non-real-time business through coroutines. That is, when personal emails and system emails are uniformly encoded, all unfetched system emails are first found from the system email set according to the maximum email sequence number, and all unfetched system emails are stored into the personal email set in order. Then, batch reading operations are performed again from the personal email set.
[0333] This unified encoding method for personal and system emails makes it convenient to read emails from the latest one backwards when the number of emails to be retrieved is included in the business parameters. This can improve the efficiency of retrieving only a portion of the unretrieved emails. However, since it is necessary to read all the unretrieved system emails in batches and store them in the personal email collection, and then read the backed-up part or all of the system emails again in the personal email collection during subsequent batch readings, it is necessary to perform two read operations on the backed-up system emails. The database operation overhead is slightly large.
[0334] Figure 5 This is a logical structure diagram of an email database in a business server provided in an embodiment of this disclosure, such as... Figure 5 As shown, the Mail Service system 500 is configured with a mail database 510, which optionally uses a Mango database. The mail database 510 maintains a global system mail set (global_mail) 511 and a personal mail set (personal_mail) 512 for each account. Each account's personal mail is stored in its personal mail set 512, while system mail sent across the entire server is uniformly stored in the system mail set 511.
[0335] In the case of separate encoding of personal mails and system mails, each personal mail in the personal mail set 512 keeps a personal mail sequence number personal mail ID which is incremented, and each system mail in the system mail set 511 keeps a system mail sequence number global mail ID which is incremented. The personal mail ID and the global mail ID can be encoded in the same or different ways. In this case, all the non-pulled mails can be read based on the manner of steps 306-A1 to 306-A3.
[0336] In the case of unified encoding of personal mails and system mails, each personal mail in the personal mail set 512 and each system mail in the system mail set 511 keeps a mail sequence number mail ID which is incremented. In this case, all the non-pulled mails can be read based on the manner of steps 306-B1 to 306-B4.
[0337] In the above two cases, two possible implementations of the database operation of the non-real-time service initiated by the coroutine of the service server in different encoding manners of the mail sequence number are provided. Through the above manners, the batch read operation on the mail database can be initiated, and at this time, the step 307 in the previous embodiment can still be performed, that is, the coroutine is blocked when the operation result of the database operation is not obtained, and then when the operation result of the database operation is obtained, if the operation result indicates transaction commit (rather than transaction rollback), the following steps 401-403 are performed:
[0338] In step 401, the service server determines the number of unread mails based on the plurality of mails returned by the operation result of the batch read operation.
[0339] In some embodiments, after the batch read operation on the non-pulled mails is performed by the service server through any of the above possible implementations, in the case where the operation result of the batch read operation indicates transaction commit, the plurality of mails read by the batch read operation can be obtained, the number of the plurality of mails read by the batch read operation is counted, and the number of unread mails is obtained.
[0340] In step 402, the service server extracts the information digest of the plurality of mails, and the information digest is used to provide at least one of the following: mail type, mail title, sender information, mail timestamp, and whether there is an attachment.
[0341] The mail type is used to indicate whether the mail is a personal mail or a system mail.
[0342] The sender information refers to the relevant information of the sender of the mail, such as at least one of the following: the account nickname of the sender of the mail in the game, the account ID, and the account avatar.
[0343] wherein the mail timestamp refers to a sending timestamp of the mail sent by the mail sender.
[0344] wherein the whether containing attachment is used to indicate whether the mail contains an attachment, which can be a binary variable or a Boolean variable, and when the binary variable takes the value of 1 or the Boolean variable takes the value of True, it indicates that the mail contains an attachment, and when the binary variable takes the value of 0 or the Boolean variable takes the value of False, it indicates that the mail does not contain an attachment.
[0345] In some embodiments, when a plurality of mails are read in batches, if all the mails are returned to the terminal at one time, on the one hand, the communication overhead of data transmission is large, the bandwidth occupied is large, and on the other hand, the data transmission efficiency is low, and the terminal needs to wait for a long time to receive the response. Therefore, the business server can extract the information digest of the above batch read mails, such as extracting at least one of the mail type, the mail title, the sender information, the mail timestamp and whether containing the attachment of each mail to form the information digest (mailInfo) of this mail. When generating the response to the mail list pull request, only the information digest of each mail read in batches can be carried, and the specific mail body (and the attachment if the mail contains the attachment) is not carried, which can greatly save the communication overhead of the above response in transmission, save the bandwidth occupied by the response transmission, improve the data transmission efficiency and the response efficiency to the mail list pull request.
[0346] In some embodiments, when extracting the information digest of each mail, it is judged whether the sender of the mail is a game administrator or a game system, and then the mail type is assigned as a system mail; otherwise, the mail type is assigned as a personal mail, and the assigned mail type is written into the information digest of the mail.
[0347] In some embodiments, when extracting the information digest of each mail, the mail title of the mail is extracted, and the extracted mail title is written into the information digest of the mail in the form of a string.
[0348] In some embodiments, when extracting the information digest of each mail, at least one of the account nickname, the account ID and the account avatar of the sender in the game is extracted, and the extracted sender information is written into the information digest of the mail.
[0349] In some embodiments, when extracting the information digest of each mail, the sending timestamp of the mail sent by the mail sender is extracted, and the extracted mail timestamp is written into the information digest of the mail.
[0350] In some embodiments, when extracting the information digest of each email, it is determined whether the email contains an attachment, and if the email contains an attachment, a binary variable indicating whether the email contains an attachment is set to 1 or a Boolean variable is set to True; otherwise, the binary variable indicating whether the email contains an attachment is set to 0 or the Boolean variable is set to False, and the assigned variable is written into the information digest of the email.
[0351] In some embodiments, when the above one or more information is obtained and the information digest is generated, an information digest can be initialized, including four fields of email type, email title, sender information, email timestamp, and whether an attachment is contained, and the information actually extracted from the current email is written into the above four fields. Optionally, the information digest is implemented in the form of data such as a list, a hash table, a dynamic array, a plurality of Key-Value data structures, a URL (Uniform Resource Locator, Uniform Resource Locator) string, and the like. The data form of the information digest is not specifically limited in the embodiments of the present disclosure.
[0352] In some embodiments, in addition to the above four fields, fields in the information digest can be flexibly added or deleted according to business needs, such as adding an email valid time field to indicate the valid time of the email (such as valid before a certain time point), and adding an attachment valid time field to indicate the valid time of the attachment (such as a virtual prop class of attachment limited to be taken before a certain time point or otherwise invalid). The field composition of the information digest is not specifically limited in the embodiments of the present disclosure.
[0353] In step 403, the business server generates a response carrying the information digest and the number of unread emails.
[0354] In some embodiments, the business server encapsulates the number of unread emails obtained in the above step 401 and the information digest generated in the above step 402 into a response, and then sends the response directly to the terminal sending the email list pulling request, which can reduce the communication round and save the communication overhead.
[0355] In some embodiments, the business server sends the above encapsulated response to the game server, and then the game server sends the above response to the terminal, which can ensure that the terminal is unaware of the background micro-service architecture, and make the split deployment of non-real-time business in the game transparent and unaware to the user side.
[0356] In the above steps 401-403, one possible implementation of the service server generating a response is provided, i.e., the service server side generates a response, which is directly returned to the terminal by the service server or is sent to the game server by the service server and then forwarded to the terminal by the game server. Since only the information digest of each email that has not been pulled is carried in the response, but not the email body of each email, the information digest itself already supports the normal display of the email list on the terminal side. Only when the viewing operation of a specific email by the user is detected, the email body of the email is pulled. This not only greatly saves the communication bandwidth and communication overhead, but also improves the response efficiency of the email list pull request.
[0357] In other embodiments, the service server notifies the email unread quantity obtained in the above step 401 and the information digest generated in the above step 402 to the mail service API on the game server side in a callback manner, so that the game server can obtain the email unread quantity and the information digest returned by the service server through the mail service API. Then, the game server encapsulates the email unread quantity and the information digest into a response and sends the response to the terminal. In this way, the service server does not need to parse the request and does not need to encapsulate the response. It only needs to execute the corresponding database operation according to the business parameter and return the operation completed business data (i.e., the information digest and the email unread quantity), which greatly saves the processing resources of the service server.
[0358] In the above embodiments, how the service server side reads the emails that have not been pulled by the terminal from the email database under different encoding modes of the email sequence number and how to generate a response to the email list pull request are provided. In some embodiments, if the game server is flooded with too many email list pull requests in the same time period, the service server may be flooded with too many RPC requests in the same time period, which may cause the service server to be busy or down. In order to further ensure the high availability of the service server, the game server side can perform frame operation on a large number of email list pull requests flooded in the same time period, or the service server side can perform frame operation on a large number of RPC requests flooded in the same time period, i.e., adding a timer to process a large number of email list pull requests or RPC requests flooded in the same time period in batches. Figure 6 is a method flowchart for frame processing of an email list pull request provided by the embodiments of the present disclosure, as shown in Figure 6 The method can be connected after the step 304 in the above embodiments:
[0359] In step 601, in a case where the number of the plurality of mail list pull requests received in the same time period exceeds the request quantity threshold, the service server caches the plurality of RPC requests associated with the plurality of mail list pull requests into a message queue.
[0360] In some embodiments, the above-mentioned time period is taken as an example of a time period constituted by a specified length of time before the current time to the current time. The game server can be used to count the number of mail list pull requests received in the above-mentioned time period, and determine whether the number is greater than the request quantity threshold. If the number is greater than the request quantity threshold, it means that the frame operation needs to be started on the service server side, and a frame operation start instruction is sent to the service server to make the service server cache the plurality of RPC requests received in the above-mentioned time period into the message queue. The specified length of time is a value greater than 0 pre-configured by a technician in the background, and the request quantity threshold is an integer greater than 0 pre-configured by a technician in the background.
[0361] In some embodiments, the game server does not need to count the number of mail list pull requests received in the above-mentioned time period, but the service server itself counts the number of RPC requests received in the above-mentioned time period, and determines whether the number is greater than the request quantity threshold. If the number is greater than the request quantity threshold, it means that the service server needs to automatically start the frame operation, so that the game server does not need to give an instruction, and one round of communication overhead about the frame operation start instruction is saved.
[0362] In some embodiments, in a case where the service server side detects that the frame operation needs to be started, a message queue is created, and then the plurality of RPC requests received in the above-mentioned time period are uniformly cached into the message queue.
[0363] In step 602, the service server merges the RPC requests associated with the same mail list pull requests sent multiple times by the same initiating account in the message queue, and configures a request number variable for the initiating account.
[0364] In some embodiments, since the user is likely to send the same mail list pull request continuously for multiple times in a short time, the business server needs to traverse the message queue once, and merge the RPC requests from the same initiating account in the message queue, that is, only keep one RPC request carrying the request number variable, and delete the remaining repeated RPC requests, such as only keeping the RPC request with the earliest timestamp, and deleting the subsequent new RPC request, while configuring a request number variable for the kept one RPC request, and assigning the number of all RPC requests from the initiating account in the message queue to the above-mentioned request number variable. It should be noted that, with the passage of time, if the RPC request has not yet been processed, if a new repeated RPC request is received subsequently, the business server does not need to store the new repeated RPC request, but only needs to increment the above-mentioned request number variable by 1, which can also save the storage overhead of the business server.
[0365] In step 603, the business server reorders each RPC request in the message queue based on the request number variable.
[0366] In some embodiments, after traversing all RPC requests in the message queue in step 602, the message queue no longer contains repeated RPC requests from the same initiating account, and thereafter, the business server can reorder each RPC request in the message queue based on the request number variable of each RPC request, which is equivalent to adding a request number variable as a weight to measure the urgency of the RPC request. Because the user side is likely to trigger the same mail list pull request multiple times in a short time if the user is in a hurry to pull the mail list, such requests are more likely to be processed in priority, and such requests can be appropriately arranged in the front position of the message queue.
[0367] Optionally, in the reordering process, each RPC request in the message queue is sorted in descending order of the request number variable, and such sorting logic is relatively simple and easy to implement, and has low complexity.
[0368] Optionally, in the reordering process, one or more RPC requests with a request number variable greater than a target threshold value are placed in front of the remaining RPC requests in the message queue, and are reordered in order of request timestamp from old to new or in order of request number variable from large to small. The remaining RPC requests in the message queue with a request number variable less than or equal to the target threshold value are still sorted in the original order of request timestamp from old to new, wherein the target threshold value is an integer greater than 0 pre-configured by technicians in the background.
[0369] Optionally, in the reordering process, for each RPC request, a sorting weight is calculated by weighting the request timestamp and the request number variable, and then the RPC requests in the message queue are sorted in descending order of the sorting weight, which makes the sorting method more accurate and can flexibly control the contribution of the request timestamp and the request number variable to the sorting weight, with higher controllability.
[0370] In step 604, the service server processes at least one RPC request in the current batch in the reordered message queue every target time interval.
[0371] In some embodiments, after reordering the RPC requests in the message queue based on the request number variable, a timer can be created to take at least one RPC request in the first batch in the message queue every target time interval, and process the RPC requests in this batch in series or in parallel based on the processing methods involved in the above embodiments. The target time interval is a value greater than 0 pre-configured by the technician in the background, and the maximum RPC request capacity of each batch is also a value greater than 0 pre-configured by the technician in the background. The values of the target time interval and the batch capacity are not limited here.
[0372] In one example, taking a target time interval of 1 second and a batch capacity of 100 as an example, a 1-second timer is configured on the service server side to take the top 100 RPC requests in the message queue every 1 second for processing, return the corresponding response, and repeat the above operation until all RPC requests in the message queue are taken out.
[0373] In the above process, by providing a framing operation method for a large number of RPC requests that pour in within the same time period, the pressure on the service server caused by a large number of players simultaneously pulling the mail list can be avoided (even the server may be overloaded and down), and the availability of the service server is further improved.
[0374] (II) Mail detail pulling service
[0375] Figure 7 is a processing flowchart of a mail detail pulling service provided by the embodiments of the present disclosure, as shown in Figure 7 Taking a game service request initiated by a terminal-side account as a mail detail pulling request as an example, the processing method of the mail detail pulling request is executed by a service server. The service server can be a server integrated to process various non-real-time services, or a mail service server deployed separately. The service server is an exemplary illustration of a computer device.
[0376] It should be noted that only the process after the game server sends the RPC request corresponding to the mail detail pulling request to the business server and the business server creates the coroutine is described here, that is, the scheme of the embodiment of the present disclosure is implemented after step 305 in the foregoing embodiment. For how the RPC request is sent from the game server to the business server and how the business server creates the coroutine, please refer to the description of the foregoing embodiment, which will not be repeated here.
[0377] In step 306-C1, the business server determines the mail type and the mail sequence number requested to be pulled by the mail detail pulling request through the coroutine.
[0378] In some embodiments, when the terminal side detects the user's viewing operation on a certain designated mail, it initiates a mail detail pulling request for the mail, which carries the mail type and the mail sequence number of the mail. That is, the mail type and the mail sequence number are encapsulated as business parameters in the mail detail pulling request, and the game server injects the business parameters into the mail service API after parsing the business parameters, initiates an RPC request to the business server through the mail service API, and carries the business parameters injected in the mail service API, so that the business server can obtain the mail type and the mail sequence number through the business parameters provided by the mail service API after creating the coroutine. The mail type and the mail sequence number are described in the previous embodiment and will not be repeated here.
[0379] In step 306-C2, the business server initiates a read operation on the mail indicated by the mail sequence number in the mail set indicated by the mail type in the database, and obtains the mail body and the mail attachment of the mail.
[0380] The read operation is used to read the mail body of the mail, and also read the attachment of the mail if the mail carries the attachment.
[0381] In some embodiments, in the case of separate coding of personal mail and system mail, if the mail type is personal mail, the personal mail set of the account is found in the mail database based on the account ID of the account, and the mail hit by the mail sequence number is queried in the personal mail set, and then the mail body of the mail is read, and the mail attachment of the mail is also read if the mail carries the attachment; if the mail type is system mail, the mail hit by the mail sequence number is queried in the system mail set of the mail database, and then the mail body of the mail is read, and the mail attachment of the mail is also read if the mail carries the attachment.
[0382] In some embodiments, in the case of unified coding of personal mails and system mails, since the system mails are stored in the personal mail set when pulled by the terminal, and the user can only initiate a viewing operation on the mails for which the information digest has been pulled, it is indicated that the mail indicated by the mail detail pull request must be a mail for which the terminal has locally loaded the information digest but not the mail body (and mail attachment), and such mails, whether personal mails or system mails, are stored in the personal mail set, so regardless of the mail type, the system mail or the personal mail, the account ID of the account is directly used to find the personal mail set of the account in the mail database, and the mail hit by the mail sequence number in the personal mail set is queried, then the mail body of the mail is read, and in the case where the mail carries an attachment, the mail attachment of the mail is also read.
[0383] In steps 306-C1 to 306-C2, a possible implementation of initiating a database operation of a non-real-time service by the coroutine in the case of the non-real-time service being a mail detail pull service is provided, that is, for any mail that has only provided an information digest but not a mail body in the previous embodiment, when a mail detail pull request for the mail is received, the mail body (and mail attachment) of the mail can be read from the mail database through steps 306-C1 to 306-C2, so that the performance overhead of single-mail reading operation is small, the response rate of the mail detail pull request is high, and the mail body does not need to be provided in the stage of pulling the mail list, which has almost no impact on the user side.
[0384] In step 701, the service server generates a response carrying the mail body and the mail attachment.
[0385] In some embodiments, the service server encapsulates the mail body and the mail attachment obtained in step 306-C2 above into a response, and then sends the response directly to the terminal that sent the mail detail pull request, which can reduce the communication round and save communication overhead.
[0386] In some embodiments, the service server sends the above-encapsulated response to the game server, and then the game server sends the above-encapsulated response to the terminal, which can ensure that the terminal is unaware of the background micro-service architecture, and make the split deployment of non-real-time services in the game transparent and unaware to the user side.
[0387] In step 701 above, a possible implementation of generating a response by the service server is provided, that is, the response is generated on the service server side, and the response is returned directly to the terminal by the service server, or the response is sent to the game server by the service server and then forwarded to the terminal by the game server.
[0388] In some embodiments, the business server notifies the mail body and the mail attachment obtained in step 306-C2 above to the mail service API on the game server side in a callback manner, so that the game server can obtain the mail body and the mail attachment returned by the business server through the mail service API, and then the game server encapsulates the mail body and the mail attachment into a response and sends the response to the terminal, so that the business server does not need to parse the request and encapsulate the response, but only needs to execute corresponding database operations according to the business parameters and return the business data (i.e. the mail body and the mail attachment) after the operations are completed, which greatly saves the processing resources of the business server.
[0389] It should be noted that the present embodiment only takes the case of carrying the mail attachment as an example for description, if the mail does not carry the attachment, only the mail body needs to be read in step 306-C2 without reading the mail attachment, and a response carrying the mail body is generated in step 701, that is, the mail attachment is a default item, and the present embodiment does not specifically limit whether the mail attachment is carried.
[0390] (Three) Mail sending service
[0391] Figure 8 is a processing flowchart of a mail sending service provided by the present embodiment, as shown in Figure 8 Taking the game service request initiated by the terminal side account as a mail sending request as an example, the processing method of the mail sending request is executed by a business server, which can be a server integrating the processing of various non-real-time services, or a separately deployed mail service server, wherein the business server is an exemplary illustration of a computer device.
[0392] It should be noted that only the processing flow after the business server creates the coroutine when the game server sends the RPC request corresponding to the mail sending request to the business server is described herein, that is, the scheme of the present embodiment is implemented after step 305 in the foregoing embodiment, and how the RPC request is sent from the game server to the business server and how the business server creates the coroutine will be described in the foregoing embodiment, and will not be described again.
[0393] In step 306-D1, the business server determines the mail type of the to-be-sent mail indicated by the mail sending request through the coroutine.
[0394] In some embodiments, the user can edit the to-be-sent mail on the terminal side, and the terminal initiates a mail sending request for the to-be-sent mail when detecting a sending operation on the to-be-sent mail, the mail sending request at least carrying the to-be-sent mail, and optionally, the terminal can also generate the mail type of the to-be-sent mail based on the account permission logged in the terminal, and then encapsulate the mail type into the mail sending request, that is, the to-be-sent mail (or the mail type) is encapsulated into the mail sending request as a business parameter. After receiving the mail sending request, the game server parses the above business parameter, and if the to-be-sent mail and the mail type are carried in the business parameter, the above business parameter is injected into the mail service API, and the game server initiates an RPC request to the business server through the mail service API, the RPC request carrying the business parameter injected in the mail service API, so that the business server can obtain the to-be-sent mail and the mail type through the business parameter provided by the mail service API after creating a coroutine. If only the to-be-sent mail is carried in the business parameter without the mail type, the game server can detect whether the sender is a game system or a game administrator, and if so, set the mail type as a system mail, and inject the to-be-sent mail and the mail type into the mail service API, and if not, set the mail type as a personal mail, and inject the to-be-sent mail and the mail type into the mail service API. The subsequent process refers to the previous mode and will not be described in detail.
[0395] It should be noted that in different game business logics, the mail sending conditions can also be specified, such as detecting whether the mail body exceeds the set number of characters before the terminal sends the mail initiation request, so as to avoid that the mail body content is too long, and detecting whether the mail list length exceeds the set length, so as to avoid that the number of mails of a single player is too large, which will not be described in detail.
[0396] Through any of the above modes, the business server can directly obtain the to-be-sent mail and the mail type from the mail service API. In the case of a personal mail type, step 306-D2 is performed; in the case of a system mail type, step 306-D3 is performed.
[0397] In step 306-D2, the business server initiates a write operation for the to-be-sent mail to the personal mail set of the account in the database in the case of a personal mail type.
[0398] In some embodiments, in the case of a personal mail type, the business server finds the personal mail set of the account in the mail database based on the account ID of the account, creates a transaction for writing the to-be-sent mail into the personal mail set, and initiates the write operation for the to-be-sent mail through the transaction.
[0399] In step 306-D3, the business server initiates a write operation of the to-be-sent mail to the system mail collection of the database in the case that the mail type is a system mail.
[0400] In some embodiments, in the case that the mail type is a system mail, the business server finds a global system mail collection in the mail database, creates a transaction of writing the to-be-sent mail to the system mail collection, and initiates the write operation of the to-be-sent mail through the transaction.
[0401] In steps 306-D1 to 306-D3, a possible implementation of initiating a database operation of a non-real-time business through the coroutine in the case that the non-real-time business is a mail sending business is provided, that is, for a game user, the sending operation of a personal mail can be implemented through steps 306-D1 and 306-D2; for a game administrator, the sending operation of a system mail can be implemented through steps 306-D1 and 306-D3, so that a general interface of the personal mail or the system mail can be provided, or a sending interface of the personal mail and a sending interface of the system mail are provided respectively, and the high availability of the mail sending business is achieved.
[0402] In step 801, the business server assigns a mail sequence number to the to-be-sent mail based on the operation result of the write operation.
[0403] In some embodiments, after the business server completes the write operation of the to-be-sent mail, in the case that the operation result of the write operation indicates that the transaction is committed, it is represented that the to-be-sent mail has been successfully written into the corresponding mail collection and has been data-dumped, and a unique and incrementally increasing mail sequence number can be assigned to the to-be-sent mail. The encoding mode of the mail sequence number can be separate encoding or unified encoding of the personal mail and the system mail, which will not be described herein again. In the case that the operation result of the write operation indicates that the transaction is rolled back, a response of notifying the mail sending failure is directly generated and returned.
[0404] In some embodiments, in the case that the operation result of the write operation indicates that the transaction is committed, the business server detects the login state of the recipient account of the to-be-sent mail after assigning the mail sequence number, executes step 802 in the case that the recipient account is in a game offline state, and executes step 803 in the case that the recipient account is in a game online state. Alternatively, in the case that the to-be-sent mail contains multiple recipient accounts, the login state of each recipient account is detected, the step 802 is executed for the recipient account in the game offline state, and the step 803 is executed for the recipient account in the game online state.
[0405] In step 802, the service server generates a response to the sender account that the sending of the mail is successful in the case that the recipient account of the mail to be sent is in a game offline state.
[0406] In some embodiments, if the recipient account is in a game offline state, the service server can generate an ACK message as the response to the sender account that the sending of the mail is successful, and the recipient account will receive the mail to be sent when it first pulls the mail list after logging in. Alternatively, the service server returns the ACK message to the terminal directly after generating the ACK message, which can save communication overhead, or the service server returns the ACK message to the game server through a service API, so that the game server sends the ACK message to the terminal, which can reduce the perceptibility of the terminal and ensure that the terminal is not aware of the service server, and the micro-service framework is transparent to the user side.
[0407] In step 803, the service server generates a response to the account that the sending of the mail is successful in the case that the recipient account of the mail to be sent is in a game online state, and generates a response to push the mail to be sent to the recipient account.
[0408] In some embodiments, if the recipient account is in a game online state, in addition to generating an ACK message as the response to the sender account that the sending of the mail is successful in the manner of step 802, a new mail reminder needs to be sent to the recipient account.
[0409] In some embodiments, the information digest of the mail to be sent is extracted in the manner of step 402 in the foregoing embodiments, and the information digest is encapsulated into the response to push the mail to be sent to the recipient account (hereinafter referred to as a new mail push response), and then the new mail push response is sent to the terminal directly or indirectly. The sending manner of the new mail push response is the same as that of step 802, and is not repeated here.
[0410] In other embodiments, the information digest and the mail body of the mail to be sent are encapsulated into the new mail push response directly, and the present disclosure does not make a specific limitation on whether the new mail push response carries only the information digest or carries both the information digest and the mail body.
[0411] In steps 801 to 803, a possible implementation of the response generated by the service server is provided, i.e., the service server side generates an ACK message to indicate that the mail sending is successful only for the sender account when the recipient account is offline, and generates a new mail push response for the recipient account in addition to the ACK message for the sender account when the recipient account is online. The above responses can be returned directly by the service server to the terminal, or the service server sends the responses to the game server which forwards them to the terminal. By detecting the login state of the recipient account, a new mail push response is returned to the recipient account when the recipient account is detected to be in the game online state, which can effectively avoid the recipient account missing new mails, remind the recipient account to check the new mails as soon as possible, and improve the mail delivery efficiency and timeliness.
[0412] In (I) to (III) above, the mail list pulling service, the mail detail pulling service, and the mail sending service and other mail services supported by the mail service system are introduced respectively. It should be understood that the above services are only examples of mail services, and the mail service system also supports other services such as marking as read, deleting mails, and picking up attachments. The processing procedures of these services are the same, and are not enumerated one by one.
[0413] The following takes the scenario of a game administrator initiating a system mail as an example, Figure 9 is a processing procedure of a mail sending service provided by the embodiment of the disclosure, as shown in Figure 9 The game administrator inputs a mail sending request of a system mail on the terminal side. After the mail sending request is parsed by the game server, a corresponding RPC request reaches the service server. The main thread MailService of the service server applies for a mail sequence number mailID of the next system mail from the mail database Mango. The mail database Mango returns the mail sequence number mailID to the main thread MailService. The main thread MailService fills the mail sequence number mailID into the to-be-sent mail, and writes the to-be-sent mail filled with the mail sequence number mailID into the system mail set. The mail database Mango performs a write operation on the to-be-sent mail, and returns an operation result after the write operation is performed. When the operation result indicates that the transaction is committed, the main thread MailService of the service server broadcasts a notification to one or more logical processes Logic of the game server that there is a new system mail for the whole server. The logical process Logic creates and maintains an object Avatar for each online player, and then notifies all online players of their respective objects Avatar, so as to realize the whole-server broadcasting of the system mail.
[0414] For the convenience of understanding the relationship between the logic process Logic and the object Avatar, please refer to the above Figure 5 On the server side, one or more logic processes Logic can be created, each of which provides services for the objects Avatar of one or more online players, and whenever an online player initiates a mail sending request, the mail sending request is first sent to the object Avatar on the corresponding logic process Logic, and then the object Avatar parses the mail sending request and remotely calls the mail service system 500 on the remote business server.
[0415] In the above embodiments, the processing flow of the mail service system on the server side in various types of businesses is described in detail. Since the mail service system itself has a large number of orders of magnitude, and the real-time requirement is not high (usually with the nature of in-game messages, and does not need to be pushed or viewed in real time), and the processing logic of the mail service system is relatively independent compared with the game main business logic, the splitting of the mail service system is realized through the micro-service architecture, and the mail service system is deployed on the remote business server, so that the business server supports the mail function, which can greatly reduce the user load of the game server.
[0416] In the game scene, in addition to the mail service system, there is also a type of message service system, which involves providing in-game IM message pulling, sending, and adding friends and other message businesses. The processing flow of the message service system for various types of message businesses is discussed in the following.
[0417] (Four) Unread message pulling business
[0418] Figure 10 is a processing flow diagram of an unread message pulling business provided by an embodiment of the present disclosure, as Figure 10 shown, taking the game business request initiated by the terminal side account as an unread message pulling request as an example, the processing method of the unread message pulling request is executed by a business server, which can be a server integrating various non-real-time businesses, or a separately deployed message business server, wherein the business server is an exemplary description of a computer device.
[0419] It should be noted that only the processing flow after the game server sends the RPC request corresponding to the unread message pulling request to the business server and the business server creates a coroutine is described herein, that is, the scheme of the present embodiment is implemented after step 305 in the foregoing embodiments. How the RPC request is sent from the game server to the business server and how the business server creates a coroutine are described in the foregoing embodiments and will not be described again.
[0420] In step 306-E1, the business server obtains the to-be-queried account carried in the unread message pull request and the maximum message identifier (maximum message ID) in the read messages of the session between the account and the to-be-queried account through a coroutine.
[0421] The maximum message ID indicates the latest read message in the session between the current account and the to-be-queried account.
[0422] In some embodiments, the terminal side determines the maximum message ID in each read message in the session between the current account and the to-be-queried account when initiating the unread message pull request, for example, encapsulates the maximum message ID as a business parameter into the unread message pull request, and the game server injects the business parameter into the message service API after parsing the business parameter, initiates an RPC request to the business server through the message service API, and carries the injected business parameter in the message service API in the RPC request, so that the business server can obtain the maximum message ID through the business parameter provided by the message service API after creating the coroutine. In other words, the business server can obtain the to-be-queried account and the maximum message ID from the unread message pull request through the coroutine.
[0423] In step 306-E2, the business server initiates a batch read operation of unread messages to the message set of the account and the to-be-queried account in the database based on the maximum message ID, and obtains a plurality of messages with message IDs greater than the maximum message ID.
[0424] The batch read operation is used to read the plurality of messages with message IDs greater than the maximum message ID.
[0425] In some embodiments, the database involved in the embodiments of the present disclosure refers to a message database, which is used to store the sent messages (for example, chat records) in all sessions. For example, the message database can be a Redis storage cluster, which is a Key-Value type database and has good support for high-concurrency business and a list storage format, and is more suitable for the business demand of the message business which needs to view historical messages.
[0426] Illustratively, for the Redis message database, each message record in the session between each account and another account is stored in the Redis message database in the form of a message list. Each message record in the message list is implemented as a dictionary, and different fields can be configured in the dictionary, such as the following fields: message sender, message content, sending time, etc.
[0427] Since the message type can be divided into private conversation (referring to the private chat conversation between two accounts) and group conversation (referring to the group chat conversation among three or more accounts), in the Redis message database, the message records of the private conversation and the group conversation can be stored in different channels. In the private conversation channel, the private conversation between each pair of accounts is stored as a private message list, and the private message list is implemented by a Key-Value data structure, for example, the Key (key name) of the Key-Value data structure is constructed based on the account ID of each pair of accounts. In the group conversation channel, the group conversation of each group is stored as a group message list, and the group message list is implemented by a Key-Value data structure, for example, the Key of the Key-Value data structure is constructed based on the group ID. In this way, even if the members in the group change, the Key does not need to be changed, reducing the database performance overhead.
[0428] Illustratively, for the private conversation of player A and player B, in the Redis message database, the Key of the Key-Value data structure is constructed based on the account ID-1 of player A and the account ID-2 of player B, for example, first determine the order of the two players' account IDs in the ID dictionary, and then assemble the following Key according to the order of the account IDs in the ID dictionary from front to back: private_chat_between_1_2. The assembled Key can be reused when player A or player B queries the conversation message, without backing up the respective conversation messages of the two players, which can reduce the database storage overhead.
[0429] In some embodiments, in the Redis message database, whether it is a private message list or a group message list, when a new message is included, the business server will allocate a self-incrementing message ID to the message. Since the message ID remains incremental, the terminal side only needs to record the maximum message ID of the read message. In the message list, all messages with a message ID greater than the recorded maximum message ID are unread messages of the terminal side, greatly simplifying the pull logic of unread messages.
[0430] In some embodiments, when the business server obtains the account to be queried in step 306-E1, if the account to be queried is a personal account, it means that the unread messages in the private conversation are pulled this time, and if the account to be queried is a group ID, it means that the unread messages in the group conversation are pulled this time.
[0431] In some embodiments, for a pull request of unread messages in a private session, a Key of the private session between the current account and the account to be queried can be determined based on the current account and the account to be queried, and a corresponding Value, i.e., a private message list of the private session, can be queried in the Redis message database by taking the determined Key as an index. The messages in the private message list are arranged in order of message ID from small to large. Then, starting from the next message of the latest read message indicated by the maximum message ID obtained in step 306-E1, the messages are read backward until there is no new readable message, and thus all unread messages with message ID greater than the maximum message ID can be obtained.
[0432] In some embodiments, for a pull request of unread messages in a group session, a Key of the group session indicated by the group ID can be determined based on the group ID, and a corresponding Value, i.e., a group message list of the group session, can be queried in the Redis message database by taking the determined Key as an index. The messages in the group message list are arranged in order of message ID from small to large. Then, starting from the next message of the latest read message indicated by the maximum message ID obtained in step 306-E1, the messages are read backward until there is no new readable message, and thus all unread messages with message ID greater than the maximum message ID can be obtained.
[0433] In steps 306-E1 to 306-E2, a possible implementation of initiating a database operation of a non-real-time service by a coroutine of a business server is provided. That is, for a pull request of unread messages in a private session or a group session, only the account to be queried recorded in the pull request needs to be changed, and the maximum message ID in the session needs to be encapsulated into the pull request, without other complex processing. In this message processing architecture, the data amount carried by the pull request itself is small, which greatly saves the communication bandwidth and communication overhead.
[0434] Through steps 306-E1 to 306-E2, a batch read operation on the Redis message database can be initiated. At this time, step 307 in the foregoing embodiments can still be executed, i.e., the coroutine is blocked when the operation result of the database operation is not obtained. Then, when the operation result of the database operation is obtained, if the operation result indicates transaction submission (rather than transaction rollback), the following steps 1001-1002 are executed:
[0435] In step 1001, the business server determines the number of unread messages based on the multiple messages returned by the operation result of the batch read operation.
[0436] In some embodiments, after the business server performs the batch read operation on the unread messages, in the case that the operation result of the batch read operation indicates transaction commit, the business server can obtain the batch read messages (i.e. all unread messages), count the number of the batch read messages, and obtain the number of unread messages.
[0437] In step 1002, the business server generates a response carrying the plurality of unread messages and the number of unread messages.
[0438] In some embodiments, the business server encapsulates the number of unread messages obtained in step 1001 and all unread messages batch read in step 306-E2 into the response, and then sends the response directly to the terminal that initiates the unread message pull request, which can reduce the communication round and save communication overhead.
[0439] In some embodiments, the business server sends the encapsulated response to the game server, and the game server sends the response to the terminal, which can ensure that the terminal is unaware of the background micro-service architecture, and make the split deployment of non-real-time services in the game transparent and unaware to the user side.
[0440] Figure 11 is an interaction flowchart of an unread message pull service provided by an embodiment of the present disclosure, as shown in Figure 11 The player triggers an unread message pull request in the game application on the terminal side. The object Avatar of the player is maintained on the logic process Logic on the game server side. The unread message pull request on the terminal side is received through the object Avatar, and an RPC request associated with the unread message pull request is sent to the main thread ChatService of the business server. Then, the main thread ChatService initiates a batch read operation of unread messages to the Redis message database. Then, the Redis message database batch reads all unread messages with message IDs greater than the maximum message ID of the read messages carried in the RPC request, counts the number of unread messages of all unread messages, and returns all unread messages and the number of unread messages as business data to the main thread ChatService. The main thread ChatService can perform json.loads operation on the business data, i.e. convert the JSON string formed by all unread messages returned by the Redis message database into a Python dictionary through the json.loads() method, and return the unread messages in the form of Python dictionary and the number of unread messages to the object Avatar on the logic process Logic. The object Avatar returns the unread messages in the form of Python dictionary and the number of unread messages to the terminal.
[0441] In the steps 1001-1002, a possible implementation of the service server generating a response is provided, that is, the service server side generates a response, which is directly returned to the terminal by the service server or sent to the game server by the service server and then forwarded to the terminal by the game server. Since the response carries not only all unread messages but also the number of unread messages, the number of unread messages can be rendered into "red dot data" in the message viewing interface on the terminal side. The red dot data refers to a type of UI display mode that represents the existence of unread messages with red dots and displays the number of unread messages. The red dot data can conveniently prompt whether there are unread messages and how many unread messages exist, greatly improving the information quantity and information density of the message viewing interface on the terminal side and being conducive to improving the information acquisition efficiency of the user.
[0442] In some other embodiments, the service server notifies the message service API on the game server side of the number of unread messages obtained in the step 1001 and all unread messages read in batches in the steps 306-E2 in a callback manner, so that the game server can obtain the number of unread messages and all unread messages returned by the service server through the message service API. Then, the game server encapsulates the number of unread messages and all unread messages into a response and sends the response to the terminal. In this way, the service server does not need to parse the request or encapsulate the response, but only needs to execute corresponding database operations according to business parameters and return the operation completed business data (that is, all unread messages and the number of unread messages), which greatly saves the processing resources of the service server.
[0443] In the above embodiments, a possible implementation of pulling all unread messages and the number of unread messages (that is, red dot data) for any private session or group session is provided. Optionally, the terminal side can also separately initiate a red dot data pulling request, that is, only pull the red dot data of each session, so as to normally display the red dot data of all sessions in the message viewing interface on the terminal side, but not load all unread messages of each session. Only when the opening operation of a certain session is detected, the unread message pulling request of the specified session is triggered. In this way, the communication overhead between the terminal and the server cluster can be saved, that is, all unread messages of all sessions do not need to be pulled when the message viewing interface is displayed (which is likely to have a large data volume and occupy a lot of bandwidth), but only the unread messages of the current session are pulled when a certain session is opened. The storage overhead on the terminal side can also be saved.
[0444] Hereinafter, the red dot data pulling request is taken as an example to be pulled by the terminal side.
[0445] Figure 12 is an interactive flowchart of a red dot data pulling service provided by the embodiments of the present disclosure, as shown in Figure 12As shown, the player triggers a red dot data pulling request in the game application on the terminal side; the object Avatar of the player is maintained on the logic process Logic on the game server side, the red dot data pulling request on the terminal side is received through the object Avatar, and an RPC request associated with the red dot data pulling request is sent to the main thread ChatService of the business server; then, the main thread ChatService initiates a query operation on the red dot data to the Redis message database; then, the Redis message database counts the number of unread messages whose message IDs are greater than the maximum message ID of the read messages carried in the RPC request, and returns the number of unread messages as the red dot data to the main thread ChatService; the main thread ChatService returns the red dot data to the object Avatar on the logic process Logic; and the object Avatar returns the red dot data to the terminal.
[0446] In the above manner, for the two accounts in the private session, only different maximum message IDs need to be provided, and the respective correct red dot data and unread messages can be pulled on the basis of reusing the same private message list Key-Value data structure, that is, the two accounts in the private session can reuse the same chat record to find the respective specified chat messages, which greatly saves the storage cost of the business server side.
[0447] In some embodiments, after the business server side obtains the maximum message ID provided by each player, the latest received maximum message ID is cached in the Redis message database, and the maximum message ID is overwritten by the subsequently updated maximum message ID, which facilitates the business server side to perform other business decisions based on the maximum message ID of the read messages, for example, the business decisions include: when a new message is received, whether to display or update the unread message and the red dot data is determined by comparing the message ID of the new message with the size of the maximum message ID cached by the message receiver.
[0448] In some embodiments, for player A, when caching the maximum message ID of the private session between player A and player B, assuming that the maximum message ID of the message read by player A in the private session described above is 3, a hash structure can be created as follows: based on the account ID of player A, generate the Key of the hash structure, that is, private_chat_readflag_A, and configure the Field of the hash structure as the account ID of player B, and configure the Value of the hash structure as 3, so that when the updated maximum message ID is subsequently received on the business server side, only the Value of the hash structure needs to be modified. Through the above Key-Field-Value three-level hash structure, the maximum message ID of each player in the private session with all other players in the friend list can be stored concisely in a hash structure, which not only saves storage overhead, but also greatly improves the index efficiency of the hash structure similar to a two-level index.
[0449] (V) Message sending service
[0450] Figure 13 is a message sending service processing flowchart provided by an embodiment of the present disclosure, as shown in Figure 13 Taking a game service request initiated by a terminal side account as a message sending request as an example, the processing method of the message sending request is executed by a business server. The business server can be a server integrated to process various non-real-time services, or a separately deployed message service server. The business server is an exemplary description of a computer device.
[0451] It should be noted that only the processing flow after the business server creates a coroutine is described herein when the game server sends the RPC request corresponding to the message sending request to the business server, that is, the scheme of the embodiment of the present disclosure is implemented after step 305 in the foregoing embodiment. For how the RPC request is sent from the game server to the business server and how the business server creates a coroutine, please refer to the description of the foregoing embodiment, which will not be described again.
[0452] In step 306-F1, the business server determines the message type of the to-be-sent message indicated by the message sending request through the coroutine.
[0453] In some embodiments, the user can edit the to-be-sent message on the terminal side, and the terminal initiates a message sending request for the to-be-sent message when detecting a sending operation of the to-be-sent message, the message sending request at least carrying the to-be-sent message, and optionally, the terminal can also determine the message type of the to-be-sent message according to the message receiving account specified by the to-be-sent message, and then encapsulate the message type into the message sending request, that is, the to-be-sent message (or the message type) is encapsulated into the message sending request as a service parameter. After receiving the message sending request, the game server parses the above service parameter, and if the to-be-sent message and the message type are carried in the service parameter, the game server injects the above service parameter into the message service API, and initiates an RPC request to the business server through the message service API, the RPC request carrying the service parameter injected in the message service API, so that the business server can obtain the to-be-sent message and the message type through the service parameter provided by the message service API after creating a coroutine. If only the to-be-sent message is carried in the service parameter without the message type, the game server can detect whether the message receiving account is a certain account group, if yes, set the message type as a group message, and inject the to-be-sent message and the message type into the message service API, if not, set the message type as a personal message, and inject the to-be-sent message and the message type into the message service API, and the subsequent process is the same as the previous method, which will not be described in detail.
[0454] It should be noted that in different game business logics, the message sending condition can also be specified, for example, the terminal needs to detect whether the message body exceeds the set number of characters before sending the message initiation request, so as to avoid that the message body content is too long, and whether the message contains sensitive words, so as to realize message legality verification, which will not be described in detail.
[0455] Through any of the above methods, the business server can directly obtain the to-be-sent message and the message type from the message service API. In the case of a personal message, step 306-F2 is executed; in the case of a group message, step 306-F3 is executed.
[0456] In step 306-F2, the business server initiates a write operation for the to-be-sent message to the message collection of the account and the message receiving account in the database in the case of a personal message.
[0457] In some embodiments, in the case that the message type is a personal message, the business server determines the Key of the private session between the account and the message receiving account in the Redis message database based on the account ID of the account and the account ID of the message receiving account, queries the private message list of the private session in the Redis message database using the Key as an index, and the private message list is an exemplary illustration of the message collection in the Redis database. Then, a transaction of inserting a new to-be-sent message into the private message list is created, and the write operation of the to-be-sent message is initiated through the transaction, for example, the to-be-sent message is inserted into the Value of the Key-Value private message list.
[0458] In step 306-F3, in the case that the message type is a group message, the business server initiates the write operation of the to-be-sent message to the message collection of the message receiving group in the database.
[0459] In some embodiments, in the case that the message type is a group message, the message receiving account is actually provided as a message receiving group, and the business server determines the Key of the group session of the message receiving group in the Redis message database based on the group ID of the message receiving group, queries the group message list of the group session in the Redis message database using the Key as an index, and the group message list is an exemplary illustration of the message collection in the Redis database. Then, a transaction of inserting a new to-be-sent message into the group message list is created, and the write operation of the to-be-sent message is initiated through the transaction, for example, the to-be-sent message is inserted into the Value of the Key-Value group message list.
[0460] In steps 306-F1 to 306-F3, a possible implementation of initiating the database operation of the non-real-time business through the coroutine in the case that the non-real-time business is a message sending business is provided, that is, for a newly sent personal message in a private session, the operation of sending the personal message to the message receiving account can be realized through steps 306-F1 and 306-F2, and for a newly sent group message in a group session, the operation of sending the group message in the message receiving group can be realized through steps 306-F1 and 306-F3, so that a general interface of the personal message or the group message can be provided, or a sending interface of the personal message and a sending interface of the group message can be provided respectively, and the high availability of the message sending business is realized.
[0461] In step 1301, the business server allocates a message ID for the to-be-sent message based on the operation result of the write operation, and generates a response of notifying the account of the success of the message sending.
[0462] In some embodiments, after the business server completes the write operation on the to-be-sent message, in the case where the operation result of the write operation indicates that the transaction is committed, the to-be-sent message is assigned a unique and incrementally maintained message ID, which can be incrementally maintained in the session itself or incrementally maintained for all messages in the server, i.e., the message ID is incrementally maintained for each session separately or incrementally maintained for all messages in the server, in the case where the operation result of the write operation indicates that the transaction is committed, a response (e.g., an ACK message) is generated to notify the account of the success of the message sending, and details are not repeated; in the case where the operation result of the write operation indicates that the transaction is rolled back, a response is directly generated and returned to notify the account of the failure of the message sending.
[0463] Optionally, after the business server generates the ACK message, the ACK message is returned to the terminal by the business server directly, which can save communication overhead, or the ACK message is returned to the game server by the business server through a service API, so that the game server sends the ACK message to the terminal, which can reduce the perceptibility of the terminal and ensure that the terminal is not aware of the business server, and the micro-service framework is transparent to the user side.
[0464] In some embodiments, in the case where the operation result of the write operation indicates that the transaction is committed, after the message ID is assigned, in the case where the to-be-sent message is a personal message, the login state of the message receiving account of the personal message is detected, if the message receiving account is in a game offline state, the ACK message generated is returned and the process is exited, if the message receiving account is in a game online state, step 1302 is executed to generate a new message push response to the message receiving account in the game online state; in the case where the to-be-sent message is a group message, since the message receiving group includes multiple member accounts, step 1303 is entered, i.e., the login state of each member account in the message receiving group is detected, and a new message push response is additionally generated only to the online member account in the game online state. The new message push response is a response to notify the online message receiving account or the online member account in the message receiving group that a new message has been received.
[0465] In step 1302, in the case where the to-be-sent message is a personal message, the business server generates a response to push the to-be-sent message to the message receiving account only in the case where the message receiving account is in a game online state.
[0466] In some embodiments, in the case that the message to be sent is a personal message, the service server detects the login state of the message receiving account of the personal message, if the message receiving account is in a game offline state, the new message to be sent will be sent when the message receiving account logs in and first pulls unread messages in batches, and real-time notification is not needed; if the message receiving account is in a game online state, a response for pushing the message to be sent to the message receiving account (hereinafter referred to as a new message push response) needs to be generated to notify the message receiving account that there is a new unread message, which is equivalent to implementing a real-time reminding mechanism after the new message is sent.
[0467] In some embodiments, the above-mentioned message to be sent is encapsulated into the new message push response, and the new message push response is sent to the terminal directly or indirectly. The sending mode of the new message push response is the same as that of the ACK message in step 1301, and will not be described again.
[0468] In the following, a case in which a player newly sends a personal message to a message receiving account will be described.
[0469] Figure 14 is an interactive flowchart of a message sending service provided by the embodiments of the present disclosure, as shown in Figure 14As shown, the player triggers a message sending request for a personal message in the game application on the terminal side; the object Avatar of the player is maintained on the logic process Logic on the game server side, and the message sending request on the terminal side is received through the object Avatar, and an RPC request associated with the message sending request is sent to the main thread ChatService of the service server; then, the main thread ChatService detects that the message type is a personal message, and the message content of the personal message is pre-checked, such as sensitive word screening, to ensure the legality of the personal message; then, the main thread ChatService determines the Key of the private conversation between the two accounts according to the account ID of the player account and the account ID of the message receiving account, to query the private message list recorded in the Value through the Key, and initiate a write operation of writing the personal message into the private message list to the Redis message database; the Redis message database returns the operation result of the write operation to the main thread ChatService; then, in the case that the operation result indicates that the transaction is committed, a new message ID that keeps increasing is allocated to the personal message that is written successfully, and the main thread ChatService indicates to directly mark the state of the personal message for the player account as a read state (such as updating the maximum message ID cached for the player account to the newly allocated message ID for the personal message) to the Redis message database; then, the main thread ChatService detects the login state of the message receiving account, generates a new message push response for the message receiving account, and pushes the new message push response to other terminals logged in by the message receiving account.
[0470] In step 1303, in the case that the to-be-sent message is a group message, the service server pulls the latest member list of the message receiving group of the group message; only for the online member accounts in the latest member list, a response of pushing the to-be-sent message to the online member account is generated.
[0471] In some embodiments, in the case that the to-be-sent message is a group message, in order to avoid message push errors caused by changes in member accounts in the message receiving group, the service server needs to pull the latest member list of the message receiving group, and traverse the login states of all member accounts in the latest member list. For each online member account in a game online state, a new message push response is generated based on the same manner as step 1302, and the new message push response is sent to the terminal logged in by the online member account in a unicast, multicast or multicast manner. For each offline member account in a game offline state, the new to-be-sent message will be sent when the offline member account logs in for the first time and pulls unread messages in batches, and real-time notification is not required, and no post-processing needs to be performed.
[0472] In some embodiments, the latest member list can be provided by another independent group service API and its business server deployed through a micro-service architecture, or recorded locally on the business server of the message service system, or pulled from the main logic process of the game server, and the source of the latest member list is not specifically limited here.
[0473] In the following, an example of a player newly sending a group message in a message receiving group will be described.
[0474] Figure 15 is an interactive flowchart of a message sending service provided by an embodiment of the present disclosure, as shown in Figure 15 The player triggers a message sending request for a group message in a game application on the terminal side; the object Avatar of the player is maintained on the logic process Logic on the game server side, the message sending request on the terminal side is received through the object Avatar, and an RPC request associated with the message sending request is sent to the main thread ChatService of the business server; then, the main thread ChatService detects that the message type is a group message, requests the latest member list of the message receiving group from the Redis message database; the Redis message database returns the latest member list of the message receiving group to the main thread ChatService; the main thread ChatService detects whether the latest member list is different from the locally cached member list, and if different, covers and caches the latest member list locally, then writes the group message to be sent this time into the group message list of the message receiving group in the Redis message database, that is, sends a write operation of writing the group message into the group message list; the Redis message database returns the operation result of the write operation to the main thread ChatService; in the case where the operation result indicates transaction submission, the main thread ChatService detects the login state of each member account based on the locally updated group member list, generates a new message push response only for the online member accounts in the message receiving group, and pushes the new message push response to other terminals logged in by the online member accounts.
[0475] In steps 1301-1303, a possible implementation of the service server generating a response is provided, that is, the service server additionally generates a new message push response for the online message receiving account or the online member account in the message receiving group, regardless of the individual message or the group message. The ACK message or the new message push response can be returned by the service server to the terminal directly, or sent by the service server to the game server and then forwarded by the game server to the terminal. By detecting the login state of the message receiving account or the member account in the message receiving group, when it is detected that the message receiving account or the member account in the message receiving group is in the game online state, the new message push response is returned to the message receiving account or the online member account, which can effectively avoid the message receiving account or the online member account missing the new message, remind the message receiving account or the online member account to check the new message as soon as possible, and improve the message delivery efficiency and timeliness.
[0476] In the above (four) and (five), the message service system supports various message services such as unread message pulling service, red dot data pulling service and message sending service, and it should be understood that the above several services are only examples of message services, and the message service system also supports other services such as marking read and deleting messages. The processing flow of these services is the same, and will not be enumerated one by one.
[0477] (Six) Account adding service
[0478] Figure 16 is a processing flow diagram of an account adding service provided by an embodiment of the present disclosure, as shown in Figure 16 Taking a game service request initiated by a terminal side account as an account adding request as an example, the processing method of the account adding request is executed by a service server. The service server can be a server integrated to process various non-real-time services, or a relationship chain service server deployed separately. The service server is an exemplary description of a computer device.
[0479] It should be noted that only the processing flow after the service server creates a coroutine for sending the RPC request corresponding to the account adding request to the service server is described, that is, the scheme of the present embodiment is implemented after step 305 in the foregoing embodiment. How the RPC request is sent from the game server to the service server and how the service server creates a coroutine are described in the foregoing embodiment, and will not be described again.
[0480] In step 306-G1, the service server verifies the permissions of the account initiating the account adding request and the target account requested to be added by the account through the coroutine.
[0481] The account add request is used to apply to add the target account to the account relationship chain of the account.
[0482] In some embodiments, a user can initiate an account addition request (e.g., request to add a friend) on the terminal side. This account addition request includes at least the account ID of the initiating account and the account ID of the receiving account (i.e., the target account). These account IDs are encapsulated as business parameters within the account addition request. Upon receiving the account addition request, the game server parses these business parameters and injects them into the message service API. The message service API then initiates an RPC request to the business server, carrying the injected business parameters from the message service API. This allows the business server, after creating a coroutine, to obtain the account IDs of the initiating and target accounts using the business parameters provided by the message service API.
[0483] In some embodiments, after the business server obtains the account IDs of the initiating account and the target account, it can perform a series of permission verifications on both accounts, such as: checking if the initiating account has reached the friend list limit; checking if the target account is on the initiating account's blacklist; checking if the initiating account's own friend request list exceeds the limit; checking if the target account has reached the friend list limit; checking if the initiating account is on the target account's blacklist; and checking if the target account's friend request list exceeds the limit. The above permission verification logic is flexibly configured by technical personnel according to the game's friend service requirements. Here, "friends" refers to a pair of accounts with a bidirectional or unidirectional relationship in the account relationship chain.
[0484] In this embodiment of the disclosure, due to the adoption of coroutine-based development, if the above-mentioned permission verification detection logic is a serial detection, then after starting a detection, the coroutine can be blocked and suspended, and after waiting for the detection result to return, if the detection passes, the next detection can be started and the coroutine can be blocked and suspended again. If the detection fails, the detection logic can be exited directly, and a response notifying the initiating account of the failure to add the account can be returned. With this coroutine-based development approach, when the call chain of the detection logic involved is long, there is no need to define a large number of detection functions and callback functions in a cumbersome manner. It is only necessary to trigger the overall detection logic once and call back once after all the detection logic has been executed, which is very beneficial for business expansion and maintenance.
[0485] The business server initiates the database operation of adding the account relationship record of the initiator account to the target account in the Mango relational database through the transaction.
[0486] In step 306-G2, the business server initiates the database operation of adding the account relationship record of the initiator account to the target account in the Mango relational database through the transaction.
[0487] In some embodiments, the permission verification is considered to be passed only when all the detection logics of the permission verification pass, and then the business server side can maintain the account relationship chain of each account through the Mango relational database and support dynamic change of the account relationship chain. In addition to the Mango relational database, the relationship chain data of the in-game social network can also be stored in the form of a graph database, which will not be described in detail.
[0488] In some embodiments, the business server maintains a friend application list for each account in the Mango relational database, which is used to record which accounts have initiated the account addition request to the account. Then, the friend application list of the target account is queried by taking the account ID of the target account as the index after the permission verification of the current account addition request passes, and a transaction of writing the initiator account (i.e., the account that initiates the account addition request) to the friend application list is created. The database operation of adding the account relationship record of the initiator account to the target account is initiated through the transaction, and the above database operation is implemented as a write operation of writing the initiator account to the friend application list of the target account.
[0489] In steps 306-G1 to 306-G2, a possible implementation of initiating the database operation of the non-real-time business through the coroutine is provided in the case of the account addition business of the non-real-time business, that is, a friend application list is maintained for each account in the Mango relational database, which can simplify the addition operation of the account relationship chain to the write operation of writing the initiator account to the friend application list of the target account. If batch addition of friends is involved, only the initiator account needs to be written to the friend application list of each account, which has low development complexity and is easy to implement. This can provide a general interface for single or batch addition of friends, or provide an interface for single addition of friends and an interface for batch addition of friends respectively, to realize high availability of the account addition business.
[0490] In step 1601, the service server generates an account addition notification response for the target account in the case that the operation result indicates that the record addition write for the account is completed.
[0491] In some embodiments, after the service server performs the write operation of initiating the account of the initiator to the friend application list of the target account, in the case that the operation result of the write operation indicates that the transaction is committed, the service server completes the write operation of the account addition record and has data written to disk, and generates a response (such as an ACK message) to notify the initiator account that the application sending is successful, and no longer needs to be described in detail; in the case that the operation result of the write operation indicates that the transaction is rolled back, the service server directly generates and returns a response to notify the application sending fails.
[0492] Optionally, after generating the ACK message, the service server directly returns the ACK message to the terminal by the service server, which can save communication overhead, or the service server returns the ACK message to the game server through a service API, so that the game server sends the ACK message to the terminal, which can reduce the perceptibility of the terminal, ensure that the terminal is not perceived by the service server, and make the micro-service framework transparent to the user side.
[0493] In some embodiments, the service server can detect the login state of the target account, and when the target account is in a game offline state, the target account can view the new account addition request when the target account logs in and first pulls the friend application list, without the need for post-processing; when the target account is in a game online state, the service server can generate an account addition notification response for the target account and directly or indirectly push the account addition notification response to other terminals where the target account logs in. The account addition notification response is a response to notify the online target account that a new account addition application has been received, and the sending method of the account addition notification response is the same as that of the ACK message, which will not be described in detail.
[0494] In the following, an account addition request initiated by a player A to a player B will be taken as an example for description.
[0495] Figure 17 is an interactive flowchart of an account addition service provided by the embodiments of the present disclosure, as shown in Figure 17As shown, the player A triggers an account adding request for the target account held by the player B in the game application on the terminal side; the main thread FriendService on the business server side receives the RPC request associated with the account adding request through the game server, and starts the pre-check for the accounts of both parties (i.e. the permission verification), such as whether the number of friends exceeds the upper limit, whether the application number reaches the upper limit, whether it is included in the blacklist of the other party, etc.; after the verification, the main thread FriendService initiates a write operation of the player A account to the friend application list of the target account to the Mango relational database; the Mango relational database executes the write operation and returns the operation result of the write operation to the main thread FriendService; then, in the case of transaction submission indicated by the operation result, on the one hand, the terminal logged in by the player A is prompted with the response of the successful sending of the account adding request, and on the other hand, the login state of the target account is detected, and if the target account is in the online state, the account adding notification response is generated for the target account and is sent to the other terminal logged in by the target account.
[0496] In the above step 1601, a possible implementation of the response generated by the business server is provided, i.e. after the initiator account is written to the friend application list of the target account, the business server side returns an ACK message to the initiator account, and the ACK message can be directly returned by the business server to the terminal, or the response is sent by the business server to the game server and then forwarded to the terminal by the game server. Further, by detecting the login state of the target account, when the target account is in the online state, the account adding notification response is also returned to the target account, which can effectively avoid the target account missing the above account adding application, remind the target account to check and process the above account adding application as soon as possible, and improve the delivery efficiency and timeliness of the business request.
[0497] It can be seen that in the mail service system, the message service system, and the relationship chain service system, the group mail for a certain account group is often involved, or the group message is sent in a certain account group, or the account adding request is initiated in batches for a certain group of accounts, which involves group business. However, the members in the group are not fixed, and the old members may exit or new members may join, so the master logic process of the game server can dynamically maintain the group member list. Other businesses interact with the master logic process when necessary, or different business servers dynamically maintain the group member list and synchronize the group member list regularly. In the embodiment of the disclosure, another way of dynamically maintaining the group member list is also involved, that is, a group service API is separately split out and deployed as a business server for providing group services in a micro-service architecture. It can be a separate group business server or a distributed architecture CDN server cluster, which is no longer limited.
[0498] For the group service system (GroupService), it can be used to maintain the latest member list of various temporary or non-temporary account groups, such as game alliances, game guilds, temporary teams, and copy teams. The group service API is used to support the creation, dissolution, member joining, and member exiting of the account group, and provides interface support for a series of business requirements. For the account group, the login state (game online or game offline) of the member account does not affect the member relationship within the account group. Therefore, by separately deploying a group service API and its supporting business server to maintain the latest member list of each account group, other businesses such as mail business or message business can call the group service API to pull the latest member list of the specified group, without the need for the mail business server or the message business server to calculate or maintain the latest member list. Since the maintenance of the latest member list is migrated to the external group service system, the response rate of cross-businesses such as group chat message pulling, group chat red dot data pulling, group mail sending, and batch friend adding can be accelerated. Illustratively, the group relationship database in the group service system is a Redis storage cluster, which records the latest member list of each account group in the form of Key-Value data structure, such as using the group ID of the account group as the Key and the latest member list of the account group as the Value, to maintain the group member relationship.
[0499] Figure 18 is a business flowchart of a group service system provided by the embodiment of the disclosure, as Figure 18As shown, when the group members change (such as old members leaving, new members joining, etc.), the terminal side will send a group change request for the group member change to the main thread GroupService of the service server through the game server RPC request; the main thread GroupService obtains the change operation of the group members of the target group based on the RPC request, and instructs the Redis group relationship database to perform the corresponding change operation on the latest member list of the target group; the Redis group relationship database returns the operation result of the change operation to the main thread GroupService, that is, the latest member list can be dynamically maintained.
[0500] In the above various embodiments, the processing flow of the mail service system, the message service system and the group service system of the server backend in various businesses is introduced in detail. Since these service systems do not have high real-time requirements, and the processing logic is relatively independent compared with the game main business logic, the above several types of service systems are split through the micro-service architecture, and the split service systems are deployed on the remote business server, so that the business server supports the respective business functions, which can greatly reduce the user load of the game server. Moreover, when a certain type of business is upgraded or iterated in the future, the code logic of the business server can be modified alone, without affecting the normal operation of the game main business logic or other irrelevant business logic, which simplifies the development difficulty of the game backend and improves the scalability of the game application. Moreover, since the development mode of the overall architecture of concentrating all businesses in the game server is avoided, the problem of fault cascade is effectively avoided, and the blocking of all business progress due to the unavailability of a single business module is prevented. Moreover, since the split and deployed various service systems have a certain independence, they can be easily migrated to other game products, and have high portability.
[0501] Figure 19 is a logical structure block diagram of a game business request processing apparatus according to an embodiment of the present disclosure. Referring to Figure 19 The apparatus includes a determination unit 1901, a query unit 1902 and a sending unit 1903.
[0502] The determination unit 1901 is configured to determine a business type of a game business request of an account in response to the game business request, the business type indicating a time attribute of a game business associated with the game business request;
[0503] The determination unit 1901 is further configured to determine a service interface matched with the non-real-time business when the business type indicates that the game business is a non-real-time business;
[0504] The query unit 1902 is configured to query an address of a service server for providing the service interface from a service registry, the service registry being configured to record addresses of service servers for various interfaces;
[0505] The sending unit 1903 is configured to send a remote procedure call (RPC) request based on the service interface to the address, the RPC request being configured to instruct the service server to provide a response to the game service to the account.
[0506] The apparatus provided by the embodiments of the present disclosure can, by means of the game service request for requesting a non-real-time service, without real-time processing locally by the game server due to the low real-time requirement, query a service API for processing the non-real-time service from the service registry, and then perform RPC remote calling on the remote service server by means of the service API. In this way, the user load related to the non-real-time service can be migrated from the game server to the service server, the resource configuration of the game server is optimized, and since iteration and update for the non-real-time service only need to modify the code logic in the service server and modify the service API if necessary, the game main service logic is not patched, the development complexity is reduced, the game development efficiency is improved, and different types of non-real-time services can be deployed in different service servers, so that when some service functions are blocked, the normal use of other service functions is not affected, and the game main service logic is also not affected, and the game usability is greatly improved.
[0507] In some embodiments, the query unit 1902 is configured to perform:
[0508] querying, from the service registry, a set of addresses for providing the service interface;
[0509] querying, from the set of addresses, an address of a service server closest to the account in terms of geographical distance.
[0510] In some embodiments, the apparatus is configured to perform: Figure 19 The apparatus further includes:
[0511] The creating unit is configured to create a coroutine of the non-real-time service by means of the service server in response to the RPC request;
[0512] The initiating unit is configured to initiate a database operation of the non-real-time service by means of the coroutine;
[0513] The blocking unit is configured to block and suspend the coroutine before an operation result of the database operation is obtained;
[0514] The returning unit is configured to return a response generated based on the operation result of the database operation after the operation result is obtained.
[0515] In some embodiments, the game service request is a mail list pull request; the initiating unit is configured to perform:
[0516] Through the coroutine, the maximum personal mail sequence number and the maximum system mail sequence number in the pulled mails of the account are obtained from the mail list pull request;
[0517] Based on the maximum personal mail sequence number, a batch read operation of personal mails is initiated to the personal mail set of the account in the database, and the batch read operation is used to read multiple personal mails with mail sequence numbers greater than the maximum personal mail sequence number;
[0518] Based on the maximum system mail sequence number, a batch read operation of system mails is initiated to the system mail set of the database, and the batch read operation is used to read multiple system mails with mail sequence numbers greater than the maximum system mail sequence number.
[0519] In some embodiments, the game service request is a mail list pull request; the initiating unit is configured to perform:
[0520] Through the coroutine, the maximum mail sequence number in the pulled mails of the account carried in the mail list pull request is obtained;
[0521] Based on the maximum mail sequence number, a batch read operation of system mails is initiated to the system mail set of the database, and the batch read operation is used to read multiple system mails with mail sequence numbers greater than the maximum mail sequence number;
[0522] The multiple system mails are stored in the personal mail set of the account in the database;
[0523] Based on the maximum mail sequence number, a batch read operation of mails is initiated to the personal mail set, and the batch read operation is used to read multiple mails with mail sequence numbers greater than the maximum mail sequence number.
[0524] In some embodiments, based on Figure 19 The device is composed of, the device further includes a generating unit configured to perform:
[0525] Based on the operation result returned by the batch read operation, the number of unread mails is determined;
[0526] An information digest of the multiple mails is extracted, and the information digest is used to provide at least one of the following: mail type, mail title, sender information, mail timestamp, and whether containing an attachment;
[0527] A response carrying the information digest and the number of unread mails is generated.
[0528] In some embodiments, the apparatus is configured to perform the method of Figure 19 In some embodiments, the apparatus is configured to perform the method of
[0529] In the case that the number of the plurality of mail list pull requests received within the same time period exceeds the request quantity threshold, the plurality of RPC requests associated with the plurality of mail list pull requests are cached by the service server into a message queue;
[0530] In the message queue, the RPC requests associated with the same mail list pull requests sent by the same initiating account are merged, and a request quantity variable is configured for the initiating account;
[0531] Based on the request quantity variable, the RPC requests in the message queue are reordered;
[0532] At least one RPC request in a current batch in the reordered message queue is processed in batches every target time length.
[0533] In some embodiments, the game service request is a mail detail pull request; the initiating unit is configured to perform:
[0534] The mail type and the mail serial number requested to be pulled by the mail detail pull request are determined by the coroutine;
[0535] A read operation for the mail indicated by the mail serial number is initiated to the mail set indicated by the mail type in the database, the read operation being used to read the mail body of the mail and, in the case that the mail carries an attachment, also read the attachment.
[0536] In some embodiments, the game service request is a mail sending request; the initiating unit is configured to perform:
[0537] The mail type of the to-be-sent mail indicated by the mail sending request is determined by the coroutine;
[0538] In the case that the mail type is a personal mail, a write operation for the to-be-sent mail is initiated to the personal mail set of the account in the database;
[0539] In the case that the mail type is a system mail, a write operation for the to-be-sent mail is initiated to the system mail set in the database.
[0540] In some embodiments, the apparatus is configured to perform the method of Figure 19 In some embodiments, the apparatus is configured to perform the method of
[0541] Based on the operation result of the write operation, a mail serial number is assigned to the to-be-sent mail;
[0542] In a case where the account of the mail receiver of the to-be-sent mail is in a game offline state, a response of informing the account of the mail sending success is generated;
[0543] In a case where the account of the mail receiver of the to-be-sent mail is in a game online state, a response of informing the account of the mail sending success is generated; and a response of pushing the to-be-sent mail to the account of the mail receiver is generated.
[0544] In some embodiments, the game service request is an unread message pulling request; the initiating unit is configured to perform:
[0545] Through the coroutine, an account to be queried and a maximum message identifier are obtained from the unread message pulling request, the maximum message identifier indicating a latest read message in a session of the account and the account to be queried;
[0546] Based on the maximum message identifier, a batch reading operation of unread messages is initiated to a message set of the account and the account to be queried in a database, the batch reading operation being used to read a plurality of messages with message identifiers greater than the maximum message identifier.
[0547] In some embodiments, based on Figure 19 The apparatus is composed of, the apparatus further includes a generating unit configured to perform:
[0548] Based on a plurality of messages returned by an operation result of the batch reading operation, a number of unread messages is determined;
[0549] A response carrying the plurality of unread messages and the number of unread messages is generated.
[0550] In some embodiments, the game service request is a message sending request; the initiating unit is configured to perform:
[0551] Through the coroutine, a message type of a to-be-sent message indicated by the message sending request is determined;
[0552] In a case where the message type is a personal message, a writing operation of the to-be-sent message is initiated to a message set of the account and a message receiving account in a database;
[0553] In a case where the message type is a group message, a writing operation of the to-be-sent message is initiated to a message set of a message receiving group in a database.
[0554] In some embodiments, based on Figure 19 The apparatus is composed of, the apparatus further includes a generating unit configured to perform:
[0555] Based on an operation result of the writing operation, a message identifier is allocated to the to-be-sent message, and a response of informing the account of the message sending success is generated;
[0556] For the personal message, only in the case that the message receiving account is in a game online state, a response of pushing the to-be-sent message to the message receiving account is generated;
[0557] For the group message, a latest member list of the message receiving group is pulled; only for online member accounts in the latest member list, a response of pushing the to-be-sent message to the online member account is generated.
[0558] In some embodiments, the game service request is an account adding request, the account adding request is used to apply to add a target account to an account relationship chain of the account; the initiating unit is configured to perform:
[0559] By the coroutine, permission verification is performed on the account;
[0560] After the verification passes, a database operation of writing a record of account addition of the account to the target account into a database is initiated;
[0561] Based on Figure 19 the device composition, the device further includes a generating unit configured to perform:
[0562] In the case that the operation result indicates that the writing of the record of account addition is completed, an account addition notification response to the target account is generated.
[0563] As to the device in the above embodiments, the specific manner in which each unit performs an operation has been described in detail in the embodiments of the processing method of the game service request, and will not be described in detail here.
[0564] Figure 20 is a structural schematic diagram of a computer device provided by the embodiments of the present disclosure. The computer device 2000 can have great differences due to different configurations or performances, and can include one or more processors (Central Processing Units, CPUs) 2001 and one or more memories 2002. The memory 2002 stores at least one program code, which is loaded and executed by the processor 2001 to implement the processing method of the game service request provided by each of the above embodiments. Of course, the computer device 2000 can also have a wired or wireless network interface, a keyboard, an input and output interface, and other components for realizing the functions of the device, and will not be described here.
[0565] In an example embodiment, a computer readable storage medium comprising at least one instruction, for example, a memory comprising at least one instruction, is also provided, wherein the at least one instruction is executable by a processor in a computer device to implement the processing method of the game service request in the above-mentioned embodiments. Optionally, the computer readable storage medium can be a non-transitory computer readable storage medium, for example, the non-transitory computer readable storage medium can include a ROM (Read-Only Memory), a RAM (Random-Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0566] In an example embodiment, a computer program product is also provided, comprising one or more instructions executable by a processor of a computer device to implement the processing method of the game service request provided by each of the above-mentioned embodiments.
[0567] Other embodiments of the present disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the features disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure following the general principles thereof and including such departures from the present disclosure that come within known, accepted, and / or customary practice in the art to which the present disclosure pertains. The specification and examples are to be regarded as illustrative only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0568] It should be understood that the present disclosure is not limited to the precise structures herein described and illustrated in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the claims that follow.
Claims
1. A method for processing game service requests, characterized in that, include: In response to a game service request from an account, determine the service type of the game service request, wherein the service type indicates the timeliness attribute of the game service associated with the game service request; If the service type indicates that the game service is a non-real-time service, determine the service interface that matches the non-real-time service; The address of the business server that provides the service interface is retrieved from the service registry, which records the addresses of business servers for various types of interfaces. Based on the service interface, a remote procedure call request is sent to the address, and the remote procedure call request is used to instruct the business server to provide the account with a response to the game service; The method further includes: The business server responds to the remote procedure call request and creates a coroutine for the non-real-time business. The game service request is an email list retrieval request; through the coroutine, the maximum personal email sequence number and the maximum system email sequence number from the retrieved emails of the account are obtained from the email list retrieval request; based on the maximum personal email sequence number, a batch read operation is initiated on the personal email set of the account in the database to read multiple personal emails with an email sequence number greater than the maximum personal email sequence number; based on the maximum system email sequence number, a batch read operation is initiated on the system email set of the database to read multiple system emails with an email sequence number greater than the maximum system email sequence number; or... The game service request is an email list retrieval request; the coroutine obtains the maximum email sequence number from the account's retrieved emails carried in the email list retrieval request; based on the maximum email sequence number, a batch read operation is initiated on the system email set in the database to read multiple system emails with email sequence numbers greater than the maximum email sequence number; these multiple system emails are stored in the account's personal email set in the database; based on the maximum email sequence number, a batch read operation is initiated on the personal email set to read multiple emails with email sequence numbers greater than the maximum email sequence number; or... The game service request is an email details retrieval request; the coroutine determines the email type and email sequence number requested in the email details retrieval request; a read operation is initiated on the email indicated by the email sequence number from the email set indicated by the email type in the database, the read operation is used to read the email body of the email, and if the email has attachments, also read the attachments; or, The game service request is an email sending request; the coroutine determines the email type of the email to be sent indicated by the email sending request; if the email type is personal email, a write operation is initiated to the personal email set of the account in the database for the email to be sent; if the email type is system email, a write operation is initiated to the system email set in the database for the email to be sent; or, The game service request is an unread message retrieval request; through the coroutine, the account to be queried and the maximum message identifier are obtained from the unread message retrieval request, where the maximum message identifier indicates the latest read message in the session between the account and the account to be queried; based on the maximum message identifier, a batch read operation for unread messages is initiated from the message sets of the account and the account to be queried in the database, where the batch read operation is used to read multiple messages with message identifiers greater than the maximum message identifier; or... The game service request is a message sending request; the message type of the message to be sent indicated by the message sending request is determined by the coroutine; if the message type is a personal message, a write operation for the message to be sent is initiated to the message set of the account and the message receiving account in the database; if the message type is a group message, a write operation for the message to be sent is initiated to the message set of the message receiving group in the database; or, The game service request is an account addition request, which is used to apply to add the target account to the account relationship chain of the account; the coroutine verifies the permission of the account; after the verification is successful, a database operation is initiated to write the account addition record of the account to the target account.
2. The method for processing game service requests according to claim 1, characterized in that, The step of querying the address of the business server providing the service interface from the service registry includes: From the service registry, query the set of addresses used to provide the service interface; From the set of addresses, query the address of the business server that is geographically closest to the account.
3. The method for processing game service requests according to claim 1, characterized in that, After initiating the database operation for the non-real-time service via the coroutine, the method further includes: Before obtaining the result of the database operation, the coroutine is blocked and suspended; After obtaining the result of the database operation, a response generated based on the operation result is returned.
4. The method for processing game service requests according to claim 1, characterized in that, The method further includes: Based on the multiple emails returned by the batch read operation, determine the number of unread emails; Extract the information digest of the multiple emails, wherein the information digest is used to provide at least one of the following: email type, email title, sender information, email timestamp, and whether it contains attachments; Generate a response carrying the message digest and the number of unread emails.
5. The method for processing game service requests according to claim 1, characterized in that, The method further includes: If the number of multiple email list retrieval requests received within the same time period exceeds the request volume threshold, the business server caches the multiple remote procedure call requests associated with the multiple email list retrieval requests into a message queue. In the message queue, remote procedure call requests associated with the same email list retrieval requests sent multiple times by the same initiating account are merged, and a request count variable is configured for the initiating account. Based on the request count variable, the remote procedure call requests in the message queue are reordered. At each target time interval, at least one remote procedure call request in the current batch of the reordered message queue is processed in batches.
6. The method for processing game service requests according to claim 1, characterized in that, The method further includes: Based on the result of the write operation, an email sequence number is assigned to the email to be sent. If the recipient account of the email to be sent is offline in the game, generate a response to notify the account that the email was successfully sent; If the recipient account of the email to be sent is online in the game, generate a response to notify the account that the email was sent successfully; and generate a response to push the email to be sent to the recipient account.
7. The method for processing game service requests according to claim 1, characterized in that, The method further includes: Based on the multiple messages returned by the batch read operation, determine the number of unread messages; Generate a response carrying multiple unread messages and the number of unread messages.
8. The method for processing game service requests according to claim 1, characterized in that, The method further includes: Based on the result of the write operation, a message identifier is assigned to the message to be sent, and a response is generated to notify the account that the message has been successfully sent. For the personal message, a response to push the message to be sent to the message receiving account is generated only if the message receiving account is online in the game; For the group message, retrieve the latest member list of the message receiving group; generate a response to push the message to be sent to the online member account only for the online member account in the latest member list.
9. The method for processing game service requests according to claim 3, characterized in that, The step of returning a response generated based on the database operation result after obtaining the operation result includes: If the operation result indicates that the record addition for the account has been completed, an account addition notification response for the target account is generated.
10. A device for processing game service requests, characterized in that, include: The determining unit is configured to execute a game service request in response to an account, and determine the service type of the game service request, wherein the service type indicates the timeliness attribute of the game service associated with the game service request; The determining unit is further configured to determine the service interface that matches the non-real-time service when the service type indicates that the game service is a non-real-time service. The query unit is configured to query the address of the business server that provides the service interface from the service registry, which is used to record the addresses of business servers for various types of interfaces. The sending unit is configured to execute a remote procedure call request to the address based on the service interface, the remote procedure call request being used to instruct the service server to provide the account with a response to the game service; The device further includes: The creation unit is configured to execute a coroutine that creates the non-real-time service in response to the remote procedure call request via the business server; The initiating unit is configured to execute: The game service request is an email list retrieval request; through the coroutine, the maximum personal email sequence number and the maximum system email sequence number from the retrieved emails of the account are obtained from the email list retrieval request; based on the maximum personal email sequence number, a batch read operation is initiated on the personal email set of the account in the database to read multiple personal emails with an email sequence number greater than the maximum personal email sequence number; based on the maximum system email sequence number, a batch read operation is initiated on the system email set of the database to read multiple system emails with an email sequence number greater than the maximum system email sequence number; or... The game service request is an email list retrieval request; the coroutine obtains the maximum email sequence number from the account's retrieved emails carried in the email list retrieval request; based on the maximum email sequence number, a batch read operation is initiated on the system email set in the database to read multiple system emails with email sequence numbers greater than the maximum email sequence number; these multiple system emails are stored in the account's personal email set in the database; based on the maximum email sequence number, a batch read operation is initiated on the personal email set to read multiple emails with email sequence numbers greater than the maximum email sequence number; or... The game service request is an email details retrieval request; the coroutine determines the email type and email sequence number requested in the email details retrieval request; a read operation is initiated on the email indicated by the email sequence number from the email set indicated by the email type in the database, the read operation is used to read the email body of the email, and if the email has attachments, also read the attachments; or, The game service request is an email sending request; the coroutine determines the email type of the email to be sent indicated by the email sending request; if the email type is personal email, a write operation is initiated to the personal email set of the account in the database for the email to be sent; if the email type is system email, a write operation is initiated to the system email set in the database for the email to be sent; or, The game service request is an unread message retrieval request; through the coroutine, the account to be queried and the maximum message identifier are obtained from the unread message retrieval request, where the maximum message identifier indicates the latest read message in the session between the account and the account to be queried; based on the maximum message identifier, a batch read operation for unread messages is initiated from the message sets of the account and the account to be queried in the database, where the batch read operation is used to read multiple messages with message identifiers greater than the maximum message identifier; or... The game service request is a message sending request; the message type of the message to be sent indicated by the message sending request is determined by the coroutine; if the message type is a personal message, a write operation for the message to be sent is initiated to the message set of the account and the message receiving account in the database; if the message type is a group message, a write operation for the message to be sent is initiated to the message set of the message receiving group in the database; or, The game service request is an account addition request, which is used to apply to add the target account to the account relationship chain of the account; the coroutine verifies the permission of the account; after the verification is successful, a database operation is initiated to write the account addition record of the account to the target account.
11. A computer device, characterized in that, include: One or more processors; One or more memories for storing the one or more processor-executable instructions; The one or more processors are configured to execute the instructions to implement the method for processing game service requests as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, When at least one instruction in the computer-readable storage medium is executed by one or more processors of a computer device, the computer device is enabled to perform the method for processing game service requests as described in any one of claims 1 to 9.
Citation Information
Patent Citations
A game server architecture and a method for responding to a client by a game server
CN109831523A
Service processing method and device and storage medium
CN110247984A
Remote procedure call implementation method and device, equipment and storage medium
CN112328410A