Distributed game server based on OpenResty platform
By designing a distributed game server architecture on the OpenResty platform, using multi-level communication nodes and processors to optimize information transmission and processing, the game server latency problem caused by communication distance delay is solved, and lower latency and higher performance is achieved.
Patent Information
- Application Number
- CN202310745541.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-21
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2043-06-21
AI Technical Summary
The prior art cannot compensate for the delay caused by communication distance, resulting in delays caused by game servers.
The distributed game server architecture based on the OpenResty platform is adopted, and by setting up several first communication nodes, several second communication nodes and processors, the distribution of balanced and balanced strategies is realized, and information transmission and processing is optimized using scaling strategies and preset response strategies.
It effectively reduces the access time of the user side, delegates the server's permissions, and shortens the time when the server issues information to the user side, thereby reducing the delay generated by the game server.
Smart Images

Figure CN116808570B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of server installation, and in particular to a distributed game server based on an OpenResty platform. Background Art
[0002] In recent years, the popularity of smart phones and the rapid development of mobile online games have brought huge business opportunities, causing more and more game manufacturers to begin producing high-quality online games on smart phones. These games are called mobile games.
[0003] With the development of mobile games and the increase in the number of mobile game players, a single server can no longer support massive amounts of player data and business processing, so distributed game servers came into being. A distributed server is a cluster of multiple servers, but the work content processed by each server is completely different. In detail, a complete system is split into independent subsystems according to business functions. In a distributed structure, each subsystem is called a "service". These subsystems can run independently in web containers, and they communicate with each other through RPC. Distributed systems are very easy to expand. As the business develops, when the current hardware cannot support it, just add another node server. It has the characteristics of high scalability, high availability, load balancing, and high performance.
[0004] OpenResty (also known as ngx_openresty) is a full-featured web application server. It packages the standard nginx core, many commonly used third-party modules, and most of their dependencies. By combining many well-designed nginx modules, OpenResty effectively transforms the nginx server into a powerful web application server. Based on it, developers can use the lua programming language to script the nginx core and various existing nginxC modules to build extremely high-performance web applications that can handle more than 10,000 concurrent requests.
[0005] China Patent Authorization Announcement No.: CN114793245B discloses a flexible and configurable streaming information processing method and system, which sends offline data stored on the server to the message receiving module in batches via HTTP requests, and the offline data is converted into streaming information to be processed and stored in the message receiving module; the message receiving module transmits the HTTP request to the routing selection module, and the routing selection module determines the routing configuration through the URI corresponding to the HTTP request; the routing selection module transmits the determined routing configuration to the message processing module, and the message processing module converts and processes the streaming information to be processed according to the processing strategy in the routing configuration. If the conversion is successful, it sends the backend service, and if the conversion is unsuccessful, the message is discarded. The invention can flexibly and dynamically load configurations, execute customized processing logic, avoid service downtime and updates, and reduce the burden on operators.
[0006] However, the above method has the following problem: it is impossible to compensate for the delay caused by the communication distance. Summary of the invention
[0007] To this end, the present invention provides a distributed game server based on the OpenResty platform to overcome the problem in the prior art that the delay caused by the communication distance cannot be compensated, thereby causing delays in the game server.
[0008] To achieve the above object, the present invention provides a distributed game server based on the OpenResty platform, which is used to provide game connection services to a number of user terminals, wherein the distributed server includes:
[0009] A plurality of first communication nodes, which are connected to each user terminal, are arranged according to a balancing strategy, and are spaced apart from each other by a first preset interval, for receiving and / or sending information to each user terminal;
[0010] A plurality of second communication nodes, which are respectively connected to each first communication node and are arranged according to a balancing strategy, and a single group of second communication nodes and the corresponding first communication node and each second communication node in the group are spaced from each other by a second preset interval, so as to receive and / or send information with the corresponding first communication node;
[0011] a processor connected to each of the second communication nodes, configured to receive information transmitted by the second communication nodes, and transmit returned information to the second communication nodes according to a preset response strategy;
[0012] The second communication node is also provided with a scaling strategy. If the scaling strategy is triggered, the second communication node transmits the returned information to the first communication node according to the preset response strategy;
[0013] The balancing strategy is based on the processor and distributed according to the first interval duration, the balance strategy is based on the corresponding first communication node and distributed according to the second interval duration, the preset response strategy is the preset game information feedback in the game, the first preset spacing is the corresponding spacing of the information transmission duration of the first interval duration within the elastic duration, and the second preset spacing is the corresponding spacing of the information transmission duration of the second interval duration within the accumulated error time;
[0014] The scaling strategy is to determine whether to transmit information to the processor according to the reaction time of the user terminal sending information;
[0015] The first interval duration is the processor reaction duration preset in the response strategy, and the second interval duration is the user terminal reaction duration preset in the response strategy;
[0016] Under a single operation condition, a single user terminal sends a single operation information to the second communication node via the corresponding first communication node, and the second communication node makes a judgment based on the reaction time of the operation information to determine whether to trigger the scaling strategy.
[0017] If the second communication node determines that the response time of the information is not less than the sum of the first interval duration and the processor response duration, the second communication node determines not to enter the scaling strategy and transmits the information to the processor;
[0018] If the second communication node determines that the response time of the information is not less than the difference between the second interval duration and the user terminal response time, and is less than the sum of the first interval duration and the processor response time, the second communication node determines to enter the scaling strategy, processes the information with the preset response strategy, and returns it to the corresponding first communication node;
[0019] The single operation condition is that the user terminal sends information;
[0020] The elastic time is related to the processing capability of the processor, and the accumulated error time is related to the refresh frequency of the user terminal.
[0021] Furthermore, a connection limit strategy is provided in the first communication node. When a single first communication node triggers the connection limit strategy, the first communication node reports to the corresponding second communication node that the connection has reached the limit, and stops accessing new user terminals;
[0022] The connection limit strategy is a maximum number of connections preset in the first communication node. When the number of user terminals connected to the single first communication node reaches the maximum number of connections, the first communication node determines to trigger the connection limit strategy.
[0023] Furthermore, for a single second communication node, if any first communication node among the first communication nodes connected to the second communication node triggers the connection limit strategy, the second communication node determines to add a first communication node at the same physical location of the first communication node.
[0024] Furthermore, for a single user terminal, if the first communication node does not send a return message corresponding to the information to the user terminal within the feedback time after receiving a single message sent by the user terminal, the first communication node determines that there is a system delay and reports the system delay to the corresponding second communication node, and the second communication node triggers the scaling strategy.
[0025] Furthermore, the processor is provided with an interaction strategy. If the user terminal connected to any two of the first communication nodes triggers the interaction strategy, the processor judges each second communication node connected to each first communication node to determine a final decision node.
[0026] If the second communication nodes are the same second communication node, the processor determines that the final decision node is the second communication node;
[0027] If the second communication nodes are not the same second communication nodes, the processor determines that the final decision node is the processor;
[0028] The interaction strategy is the interaction mode set in the preset response strategy, and the final decision node is a server node that processes the information that triggers the interaction strategy.
[0029] Furthermore, a preset receiving time is set in the first communication node. If the time taken for a single first communication node to receive information sent by a single user terminal is longer than the preset receiving time, the first communication node determines that the user terminal has lost connection, and broadcasts to each adjacent first communication node that the user terminal accesses the first communication node that has the shortest time taken to receive information sent by the user terminal.
[0030] The preset receiving time duration is related to the user end response time duration.
[0031] Furthermore, the second communication node stores the response strategy in the processor, and when the processor stops running, any second communication node can operate as a new processor.
[0032] Furthermore, the processor stops running when updating the response strategy. At this time, each second communication node is updated in sequence when the processor completes the update of the response strategy.
[0033] Furthermore, for the second communication node that stops operating, the first communication nodes corresponding thereto are connected to the second communication nodes adjacent to the second communication node.
[0034] Furthermore, the processor and each of the second communication nodes construct a blockchain, and the blockchain directory is stored in the processor.
[0035] Compared with the prior art, the beneficial effect of the present invention lies in that, by setting up a number of first communication nodes, a number of second communication nodes and a processor, the access time of the user terminal is reduced, and the server authority is delegated to a reasonable level, which effectively shortens the server's judgment time on the information sent by the user terminal, thereby effectively reducing the delay generated by the game server.
[0036] Furthermore, by judging the number of users connected to the server, the accuracy of hardware load evaluation is effectively improved while further reducing the delay in the game server.
[0037] Furthermore, by transferring the final decision on the information sent by the user end, the number of information transfers is effectively reduced while improving the information processing efficiency of the server, thereby further reducing the delay generated by the game server.
[0038] Furthermore, by sequentially updating the processor and each second communication node, the robustness of the system is effectively improved while the window period for server updates is effectively reduced, thereby further reducing the delay in the game server. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 This is a schematic diagram of the structure of a distributed game server based on the OpenResty platform of the present invention;
[0040] Figure 2 This is a connection diagram of the second communication node as a decision node in an embodiment of the present invention;
[0041] Figure 3 The figure is a connection diagram of a processor as a decision node in an embodiment of the present invention. DETAILED DESCRIPTION
[0042] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0043] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0044] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.
[0045] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0046] See also Figure 1 As shown in the figure, Nginx is the most widely used high-performance backend server. OpenResty provides it with the flexibility of dynamic languages: relying on the etcd distributed warehouse, a reliable heartbeat mechanism is implemented: decentralization eliminates single point of failure; distributed data warehouse ensures data consistency; file directory-style data storage structure supports classification management; supports data ttl mechanism to eliminate the problem of multi-machine time asynchrony.
[0047] See also Figure 1 As shown, the structural diagram of the distributed game server based on the OpenResty platform of the present invention, the distributed game server based on the OpenResty platform includes:
[0048] A plurality of first communication nodes, which are connected to each user terminal, are arranged according to a balancing strategy, and are spaced apart from each other by a first preset interval, for receiving and / or sending information to each user terminal;
[0049] A plurality of second communication nodes, which are respectively connected to each first communication node and are arranged according to a balancing strategy, and a single group of second communication nodes and the corresponding first communication node and each second communication node in the group are spaced from each other by a second preset interval, so as to receive and / or send information with the corresponding first communication node;
[0050] A processor connected to each second communication node, configured to receive information transmitted by the second communication node, and transmit returned information to the second communication node according to a preset response strategy;
[0051] The second communication node is also provided with a scaling strategy. If the scaling strategy is triggered, the second communication node transmits the returned information to the first communication node according to the preset response strategy;
[0052] Among them, the balance strategy is to distribute based on the processor and the first interval duration, the equilibrium strategy is to distribute based on the corresponding first communication node and the second interval duration, the preset response strategy is the preset game information feedback in the game, the first preset interval is the corresponding interval of the information transmission duration within the elastic duration based on the first interval duration, and the second preset interval is the corresponding interval of the information transmission duration within the accumulated error time based on the second interval duration;
[0053] The scaling strategy is to determine whether to transmit information to the processor based on the response time of the user end sending the information;
[0054] The first interval duration is the processor response duration preset in the response strategy, and the second interval duration is the user terminal response duration preset in the response strategy;
[0055] Under a single operation condition, a single user terminal sends a single operation message to a second communication node via the corresponding first communication node. The second communication node determines whether to trigger the scaling strategy based on the response time of the operation message.
[0056] If the second communication node determines that the response time of the information is not less than the sum of the first interval duration and the processor response duration, the second communication node determines not to enter the scaling strategy and transmits the information to the processor;
[0057] If the second communication node determines that the response time of the information is not less than the difference between the second interval duration and the user end response time, and is less than the sum of the first interval duration and the processor response time, the second communication node determines to enter the scaling strategy, processes the information with the preset response strategy, and returns it to the corresponding first communication node;
[0058] The single operation condition is that the user terminal sends information;
[0059] Among them, the elastic time is related to the processing power of the processor, and the cumulative error time is related to the refresh frequency of the user end.
[0060] For the i-th information, its response time threshold is ΩT, the processor response time is T, and the user end response time is t. The elastic time is For example, where 0<T<t, the reaction time of the i-th information is Ti, Ti=2×(T+t+ ),
[0061] If Ti>ΩT, the second communication node determines to trigger the scaling strategy. At this time, T=0, and Ti=2×(t+ );
[0062] If Ti≤ΩT, the second communication node determines not to trigger the scaling strategy. At this time, Ti=2×(T+t+ )
[0063] Among them, i=1,2,3,…,n, n>0 and n is an integer, and the flexible duration is the processor running speed, and the reaction time threshold ΩT is the user's reaction time, which is 1 / 24s. The data comes from the image recognition rate of the human eye.
[0064] The present invention utilizes a method of setting up a plurality of first communication nodes, a plurality of second communication nodes and a processor to reduce the access time of the user terminal and delegate the server authority to a reasonable level, thereby effectively shortening the server's judgment time on the information sent by the user terminal, thereby effectively reducing the delay generated by the game server.
[0065] Specifically, a connection limit strategy is set in the first communication node. When a single first communication node triggers the connection limit strategy, the first communication node reports to the corresponding second communication node that the connection has reached the limit and stops accessing new user terminals.
[0066] The connection limit strategy is a maximum number of connections preset in the first communication node. When the number of user terminals connected to a single first communication node reaches the maximum number of connections, the first communication node determines to trigger the connection limit strategy.
[0067] Furthermore, by judging the number of users connected to the server, the accuracy of hardware load evaluation is effectively improved while further reducing the delay in the game server.
[0068] Specifically, for a single second communication node, if any first communication node among the first communication nodes connected to the second communication node triggers the connection limit strategy, the second communication node determines to add a first communication node at the same physical location of the first communication node.
[0069] Specifically, for a single user terminal, if the first communication node does not send a return message corresponding to the information to the user terminal within the feedback time after receiving a single message sent by the user terminal, the first communication node determines that there is a system delay and reports the system delay to the corresponding second communication node, and the second communication node triggers the scaling strategy.
[0070] Specifically, an interaction strategy is provided in the processor, and if a user terminal connected to any two first communication nodes triggers the interaction strategy, the processor judges each second communication node connected to each first communication node to determine a final decision node;
[0071] See also Figure 2 As shown, it is a connection diagram of the second communication node as a decision node in an embodiment of the present invention:
[0072] If the second communication nodes are the same second communication node, the processor determines that the final decision node is the second communication node;
[0073] See also Figure 3 As shown, it is a connection diagram of the processor as a decision node in an embodiment of the present invention:
[0074] If the second communication nodes are not the same second communication nodes, the processor determines that the final decision node is the processor;
[0075] Among them, the interaction strategy is the interaction mode set in the preset response strategy, and the final decision node is the server node that processes the information that triggers the interaction strategy;
[0076] Among them, the decision node only records after the judgment is completed, and is used to output the final judgment on the information of a single operation;
[0077] For games, a decision node is the game system's judgment on a single operation, which only records the result of the judgment.
[0078] Furthermore, by transferring the final decision on the information sent by the user end, the number of information transfers is effectively reduced while improving the information processing efficiency of the server, thereby further reducing the delay generated by the game server.
[0079] Specifically, a preset receiving time is set in the first communication node. If the time taken for a single first communication node to receive information sent by a single user terminal is longer than the preset receiving time, the first communication node determines that the user terminal has lost connection, and broadcasts to each adjacent first communication node that the user terminal accesses the first communication node that has the shortest time for receiving information sent by the user terminal.
[0080] The preset receiving time is related to the user end response time.
[0081] Specifically, the second communication node stores the coping strategy in the processor, and when the processor stops running, any second communication node can operate as a new processor.
[0082] Furthermore, by sequentially updating the processor and each second communication node, the robustness of the system is effectively improved while the window period for server updates is effectively reduced, thereby further reducing the delay in the game server.
[0083] Specifically, the processor stops running when updating the response strategy. At this time, each second communication node is updated in sequence when the processor completes the update of the response strategy.
[0084] Specifically, for a second communication node that has stopped operating, each corresponding first communication node is connected to each second communication node adjacent to the second communication node.
[0085] Specifically, the processor and each second communication node construct a blockchain, and the blockchain directory is stored in the processor.
[0086] Take action games as an example:
[0087] For a single operation, the average operation speed of the user is 1s / time. Therefore, the server provides feedback in the time interval between two operations, which can reduce the user's sensitivity to the operation gap. For image changes, the existing technology is set based on 6 frames, while the user's visual capture ability is 60 frames and the visual residual ability is 12 frames, both of which are greater than 6 frames. Therefore, when a single operation is within 6 frames, the game server will determine the time point and the sensory experience of the game differently. At this time, the game experience will be reduced due to the time difference in determination;
[0088] By using the technology of the present application, the user-side response time can be set to within 1 / 24s and the processor response time can be set to within 1 / 30s, thereby shortening the judgment time difference to within 1 / 12s, thereby eliminating the problem of reduced gaming experience due to the judgment time difference.
[0089] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0090] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A distributed game server based on the OpenResty platform, used to provide game connection services to several client terminals, characterized in that: include: A plurality of first communication nodes, which are connected to each user terminal, are arranged according to a balancing strategy, and are spaced apart from each other by a first preset interval, for receiving and / or sending information with each user terminal; A plurality of second communication nodes, which are respectively connected to each first communication node and are arranged according to a balancing strategy, and a single group of second communication nodes and the corresponding first communication node and each second communication node in the group are spaced from each other by a second preset interval, so as to receive and / or send information with the corresponding first communication node; a processor connected to each of the second communication nodes, configured to receive information transmitted by the second communication nodes, and transmit returned information to the second communication nodes according to a preset response strategy; The second communication node is also provided with a scaling strategy. If the scaling strategy is triggered, the second communication node transmits the returned information to the first communication node according to the preset response strategy; The balancing strategy is based on the processor and distributed according to the first interval duration, the balance strategy is based on the corresponding first communication node and distributed according to the second interval duration, the preset response strategy is the preset game information feedback in the game, the first preset interval is the corresponding interval of the information transmission duration within the elastic duration based on the first interval duration, and the second preset interval is the corresponding interval of the information transmission duration within the accumulated error time based on the second interval duration; The scaling strategy is to determine whether to transmit information to the processor according to the reaction time of the user terminal sending information; The first interval duration is the processor reaction duration preset in the response strategy, and the second interval duration is the user terminal reaction duration preset in the response strategy; Under a single operation condition, a single user terminal sends a single operation information to the second communication node via the corresponding first communication node, and the second communication node makes a judgment based on the reaction time of the operation information to determine whether to trigger the scaling strategy. If the second communication node determines that the response time of the information is not less than the sum of the first interval duration and the processor response duration, the second communication node determines not to enter the scaling strategy and transmits the information to the processor; For the i-th information, the response time threshold is ΩT, the processor response time is T, the user end response time is t, and the elastic time is , where 0<T<t, the reaction time of the i-th information is Ti, Ti=2×(T+t+2 ), If Ti>ΩT, the second communication node determines to trigger the scaling strategy. At this time, T=0, and Ti=2×(t+ ); If Ti≤ΩT, the second communication node determines not to trigger the scaling strategy. At this time, Ti=2×(T+t+2 ); Among them, i=1,2,3,…,n, n>0 and n is an integer, and the flexible duration is the processor running speed, and the reaction time threshold ΩT is the user's reaction time, which is 1 / 24s. The data comes from the image recognition rate of the human eye. The single operation condition is that the user terminal sends information; The elastic time is related to the processing capability of the processor, and the accumulated error time is related to the refresh frequency of the user terminal.
2. The distributed game server based on the OpenResty platform according to claim 1, characterized in that: A connection limit strategy is provided in the first communication node. When a single first communication node triggers the connection limit strategy, the first communication node reports to the corresponding second communication node that the connection has reached the limit, and stops accessing new user terminals. The connection limit strategy is a maximum number of connections preset in the first communication node. When the number of user terminals connected to the single first communication node reaches the maximum number of connections, the first communication node determines to trigger the connection limit strategy.
3. The distributed game server based on the OpenResty platform according to claim 2, characterized in that: For a single second communication node, if any first communication node among the first communication nodes connected to the second communication node triggers the connection limit strategy, the second communication node determines to add a first communication node at the same physical location of the first communication node.
4. The distributed game server based on the OpenResty platform according to claim 3, characterized in that: For a single user terminal, if the first communication node does not send a return message corresponding to the information to the user terminal within a feedback time after receiving a single message sent by the user terminal, the first communication node determines that the system is delayed and reports the system delay to the corresponding second communication node, and the second communication node triggers the scaling strategy.
5. The distributed game server based on the OpenResty platform according to claim 4, characterized in that: The processor is provided with an interaction strategy. If the user terminal connected to any two of the first communication nodes triggers the interaction strategy, the processor judges each second communication node connected to each first communication node to determine a final decision node. If the second communication nodes are the same second communication node, the processor determines that the final decision node is the second communication node; If the second communication nodes are not the same second communication nodes, the processor determines that the final decision node is the processor; The interaction strategy is the interaction mode set in the preset response strategy, and the final decision node is a server node that processes the information that triggers the interaction strategy.
6. The distributed game server based on the OpenResty platform according to claim 5, characterized in that: The first communication node is provided with a preset receiving time. If the time taken for a single first communication node to receive information sent by a single user terminal is longer than the preset receiving time, the first communication node determines that the user terminal has lost connection, and broadcasts to each adjacent first communication node that the user terminal accesses the first communication node that has the shortest time for receiving information sent by the user terminal. The preset receiving time duration is related to the user end response time duration.
7. The distributed game server based on the OpenResty platform according to claim 6, characterized in that: The second communication node stores the coping strategy in the processor, and when the processor stops running, any second communication node can run as a new processor.
8. The distributed game server based on the OpenResty platform according to claim 7, characterized in that: The processor stops running when updating the response strategy. At this time, each second communication node is updated in sequence when the processor completes the update of the response strategy.
9. The distributed game server based on the OpenResty platform according to claim 8, characterized in that: For the second communication node that has stopped operating, the first communication nodes corresponding to it are connected to the second communication nodes adjacent to the second communication node.
10. The distributed game server based on the OpenResty platform according to claim 9, characterized in that: The processor and each second communication node construct a blockchain, and the blockchain directory is stored in the processor.
Citation Information
Patent Citations
A flexible and configurable streaming information processing method and system
CN114793245B
Method, device and system used for transmitting messages
CN104158755A
Load balance management method and related device
CN110113399A