Network request reason management method and device, electronic equipment and product
By finding and routing server nodes in the load balancing system and dynamically adjusting network request routing based on load state parameters, the problems of poor load balancing performance and high hardware cost in the prior art are solved, and flexibility and scalability are achieved.
Patent Information
- Application Number
- CN202510078252.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-02
AI Technical Summary
Existing load balancing technologies cannot dynamically adjust based on real-time load conditions, have poor performance, and require high hardware costs, which are not flexible enough.
By finding multiple server nodes recorded in the server list in the router management instance, based on the load status parameters of each server node, the target server node is determined through the load balancing policy, and the network request is routed to the target server node.
Dynamic request routing adjustment based on real-time load situations is realized, load balancing performance and system processing capabilities are improved, hardware costs are reduced, and it has good flexibility and scalability.
Smart Images

Figure CN119922241A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of load balancing, and in particular relates to a method, device, electronic equipment and product for managing network request reasons. Background Art
[0002] With the development of the Internet, the processing capacity of a single server has become increasingly insufficient and unable to meet the growing number of network requests. The emergence of load balancing technology has become the key to solving this problem. The core idea of load balancing technology is to distribute network requests to multiple servers for processing through certain strategies and methods, thereby improving the system's processing capacity and making rational use of resources.
[0003] Currently, most existing load balancing technologies perform URL (Uniform Resource Locator) routing based on configuration files or static rules, and use hardware load balancers to distribute network requests. However, this approach cannot be dynamically adjusted according to real-time load conditions, has poor performance, requires high hardware costs, and is not flexible enough.
[0004] Therefore, how to provide an effective solution to improve load balancing performance and reduce load balancing costs has become a difficult problem to be solved in the prior art. Summary of the invention
[0005] The purpose of the present invention is to provide a network request reason management method, device, electronic device and product to solve the above-mentioned problems existing in the prior art.
[0006] In order to achieve the above object, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides a method for managing network request reasons, comprising:
[0008] When a network request is triggered, multiple server nodes recorded in the server list in the router management instance are searched;
[0009] Based on the load status parameters of each server node among the multiple server nodes, determining a target server node for processing the network request through a load balancing strategy;
[0010] The network request is routed to the target server node so that the target server node processes the network request.
[0011] Based on the above disclosed content, the present invention searches for multiple server nodes recorded in the server list in the router management instance; based on the load status parameters of each server node in the multiple server nodes, determines the target server node for processing the network request through the load balancing strategy; routes the network request to the target server node so that the target server node processes the network request. In this way, the network request routing can be dynamically adjusted based on the load status parameters of each server node to achieve load balancing and performance optimization. At the same time, no additional hardware equipment is required, which reduces the load balancing cost, has good flexibility and scalability, and can be applied to network environments of various sizes.
[0012] In one possible design, determining the target server node for processing the network request by a load balancing strategy includes:
[0013] The target server node for processing the network request is determined by a random strategy, a polling strategy, a least connection strategy, or a strategy based on response time.
[0014] In one possible design, routing the network request to the target server node includes:
[0015] The routeRequest method in the router management instance is called to route the network request to the target server node.
[0016] In one possible design, the method further includes:
[0017] Establishing the router management instance and the server instance, wherein the router management instance includes the server list, and the server list records the state load parameters of the multiple server nodes;
[0018] The server instance records the IP addresses and port numbers of the multiple server nodes, as well as the state load parameters of the multiple server nodes.
[0019] In one possible design, after routing the network request to the target server node, the method further includes:
[0020] Monitoring the processing result of the network request and the operation status of the plurality of server nodes;
[0021] Determining whether there is an abnormality according to the processing result of the network request and the operating status of the multiple server nodes;
[0022] When the judgment result is that an exception exists, an exception handling strategy corresponding to the exception type corresponding to the exception is executed.
[0023] In one possible design, the exception handling strategy includes adjusting configuration parameters of the multiple server nodes, a policy type of the load balancing strategy and / or resource allocation of the multiple server nodes.
[0024] In one possible design, the load status parameters include CPU usage, memory occupancy and / or current number of connections.
[0025] In a second aspect, the present invention provides a network request reason management device, comprising:
[0026] A search unit, used for searching for multiple server nodes recorded in a server list in a router management instance when a network request is triggered;
[0027] a determining unit, configured to determine a target server node for processing the network request through a load balancing strategy based on a load status parameter of each server node among the plurality of server nodes;
[0028] The routing unit is used to route the network request to the target server node so that the target server node processes the network request.
[0029] In a third aspect, the present invention provides an electronic device comprising a memory, a processor and a transceiver which are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive messages, and the processor is used to read the computer program and execute the network request reason management method as described in the first aspect or any possible design of the first aspect.
[0030] In a fourth aspect, the present invention provides a computer-readable storage medium having instructions stored thereon, which, when executed on a computer, executes the network request reason management method described in the first aspect or any possible design of the first aspect.
[0031] In a fifth aspect, the present invention provides a computer program product comprising instructions, which, when executed on a computer, causes the computer to execute the network request reason management method as described in the first aspect or any possible design of the first aspect.
[0032] Beneficial effects:
[0033] The network request reason management method, device, electronic device and product provided by the present invention can dynamically adjust the network request routing based on the load status parameters of each server node to achieve load balancing and performance optimization. At the same time, no additional hardware equipment is required, which reduces the load balancing cost. It has good flexibility and scalability and can be applied to network environments of various sizes, facilitating practical application and promotion. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A flowchart of a method for managing network request reasons provided in an embodiment of the present application;
[0035] Figure 2 A schematic block diagram of a network request reason management device provided in an embodiment of the present application;
[0036] Figure 3 A schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the present invention will be briefly introduced below in combination with the drawings and the description of the embodiments or the prior art. Obviously, the following description of the structure of the drawings is only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. It should be noted that the description of these embodiments is used to help understand the present invention, but does not constitute a limitation of the present invention.
[0038] It should be understood that although the terms first, second, etc. may be used herein to describe various units, these units should not be limited by these terms. These terms are only used to distinguish one unit from another unit. For example, a first unit can be referred to as a second unit, and similarly, a second unit can be referred to as a first unit without departing from the scope of the exemplary embodiments of the present invention.
[0039] It should be understood that the term "and / or" that may appear in this article is merely a description of the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B can represent three situations: A exists alone, B exists alone, and A and B exist at the same time. The term " / and" that may appear in this article describes another type of association object relationship, indicating that two relationships may exist. For example, A / and B can represent two situations: A exists alone, and A and B exist alone. In addition, the character " / " that may appear in this article generally indicates that the previous and next associated objects are in an "or" relationship.
[0040] In order to improve load balancing performance and reduce load balancing costs, the embodiments of the present application provide a network request reason management method, device, electronic device and product, which can achieve load balancing and performance optimization and reduce load balancing costs.
[0041] The network request reason management method provided in the embodiment of the present application can be applied to a user terminal or a server. It can be understood that the execution subject does not constitute a limitation on the embodiment of the present application.
[0042] The network request reason management method provided in the embodiment of the present application will be described in detail below.
[0043] like Figure 1 As shown, it is a flowchart of the network request reason management method provided in the first aspect of the embodiment of the present application. The network request reason management method may include but is not limited to the following steps S101-S103.
[0044] Step S101: When a network request is triggered, multiple server nodes recorded in a server list in a router management instance are searched.
[0045] In the embodiment of the present application, instances such as router management instance and server instance are pre-established. As the core dispatching center of the system, the router management instance is responsible for coordinating the whole process of request routing and load balancing. The router management instance includes a server list List, which is used to store information of multiple server nodes in the whole system, including the state load parameters of multiple server nodes, and can allocate server nodes for network requests according to various load balancing strategies and the real-time load conditions of multiple server nodes.
[0046] The server instance is used to accurately represent each server node in the network. The server instance records the IP (Internet Protocol) addresses and port numbers of multiple server nodes, and also records the state load parameters of multiple server nodes. The load state parameters may include, but are not limited to, CPU (Central Processing Unit) usage, memory occupancy, and / or the current number of connections. It also includes the core method handleRequest for processing requests, in which specific business logic processing for different requests is implemented, and the load state parameters of the server nodes are updated in real time during the processing.
[0047] When creating a server instance, you can set different initial parameters according to the server's hardware configuration and expected load capacity, such as ServerNode server1 = new ServerNode ("192.168.1.101", 8080); ServerNodeserver2 = new ServerNode ("192.168.1.102", 8081), and you can set its initial CPU core number, memory size and other resource information through the server instance method. When creating a router management instance, you can add the created server instance to the server list in the router management instance. At the same time, you can set the initial load balancing strategy of the routing management through the configuration file or command line parameters according to system requirements and operating environment, such as routerManager.setCurrentStrategy (LoadBalancingStrategy.ROUND_ROBIN).
[0048] In the embodiment of the present application, when a network request sent by other devices is received or a network request is generated in response to a user's request to initiate an operation, multiple server nodes recorded in the server list can be found from the server list of the router management instance.
[0049] Step S102: Based on the load status parameters of each server node among the multiple server nodes, a target server node for processing the network request is determined through a load balancing strategy.
[0050] The router management instance introduces a load balancing policy enumeration type to conveniently switch different load balancing policies, including but not limited to random policy, polling policy, least connection policy, or response time-based policy. When determining the target server node for processing network requests, the target server node for processing network requests can be determined by random policy, polling policy, least connection policy, or response time-based policy.
[0051] The random strategy can randomly select a server node from the server list, while excluding server nodes that are in an overloaded state (such as CPU usage exceeding the threshold or the current number of connections exceeding the set threshold). The polling strategy can select server nodes in sequence and adjust them according to the load weight of the server node. The load weight can be calculated based on the CPU idle rate, memory idle rate, etc. The least connection strategy can select the server node with the least current number of connections as the target server node. The response time-based strategy can select the server node with the shortest average response time as the target server node. It is necessary to record the historical response time data of each server node and perform statistical analysis.
[0052] Among them, the getAvailableServers() method can be used to filter out server nodes that are currently in an available state (not overloaded), the adjustServerWeight(ServerNode server) method can be used to dynamically adjust the weight of the server node in the polling strategy according to the load situation of the server node, the findServerWithLeastConnections() method can be used to traverse the server nodes to find the server node with the least current connections, and the findServerWithFastestResponseTime() method can be used to analyze the historical response time data of the server nodes to determine the server node with the shortest average response time.
[0053] In the embodiment of the present application, the getBestServer method written in the router management instance can be called to select the target server node.
[0054] Step S103: Routing the network request to the target server node so that the target server node processes the network request.
[0055] In the embodiment of the present application, a routeRequest method for routing requests to a server node is written in the router management instance, and the routeRequest method in the router management instance can be called to route the network request to the target server node. Routing the request to the server node refers to the process of forwarding the request sent by the client (such as a browser or other application) to the corresponding server for processing according to certain rules and algorithms.
[0056] In one or more embodiments, after routing the network request to the target server node, the processing result of the network request and the running status of multiple server nodes can also be monitored, and whether there is an abnormality is determined based on the processing result of the network request and the running status of multiple server nodes, and when the judgment result is that there is an abnormality, the abnormality handling strategy corresponding to the abnormality type corresponding to the abnormality is executed. For example, after each network request is processed, the network request processing result and the running status of multiple server nodes, such as the routing path of the network request, the processing time, the load change of the server node, etc., can be collected through logs and performance monitoring tools, and the network request can be verified based on the collected information. Whether it is correctly routed and efficiently processed, such as checking whether all network requests have been responded to, whether the response time is within a reasonable range, whether the load of the server node is balanced, etc., if an abnormality is found, the configuration parameters of multiple server nodes, the policy type of the load balancing policy, and / or the resource allocation of multiple server nodes are adjusted according to the type and severity of the abnormality to ensure the stable operation and performance optimization of the system.
[0057] When a server node fails to process a network request, it can decide whether to reroute the request to another server node, or return an error message and record a detailed error log based on the cause of the failure and system configuration. If there are no available server nodes, a degradation strategy can be implemented, such as returning a default error page and recording the system's abnormal status information.
[0058] In summary, the network request reason management method provided by the present invention searches for multiple server nodes recorded in the server list in the router management instance; based on the load status parameters of each server node in the multiple server nodes, the target server node for processing the network request is determined through the load balancing strategy; the network request is routed to the target server node so that the target server node processes the network request. In this way, the network request routing can be dynamically adjusted based on the load status parameters of each server node to achieve load balancing and performance optimization. At the same time, no additional hardware equipment is required, which reduces the load balancing cost, has good flexibility and scalability, and can be applied to network environments of various sizes, which is convenient for practical application and promotion.
[0059] See also Figure 2 According to a second aspect of an embodiment of the present application, a network request reason management device is provided, and the network request reason management device includes:
[0060] A search unit, used for searching for multiple server nodes recorded in a server list in a router management instance when a network request is triggered;
[0061] a determining unit, configured to determine a target server node for processing the network request through a load balancing strategy based on a load status parameter of each server node among the plurality of server nodes;
[0062] The routing unit is used to route the network request to the target server node so that the target server node processes the network request.
[0063] The working process, working details and technical effects of the network request reason management device provided in the second aspect of this embodiment can be found in the first aspect of the embodiment and will not be repeated here.
[0064] like Figure 3 As shown, the third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor and a transceiver that are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive messages, and the processor is used to read the computer program and execute the network request reason management method as described in the first aspect of the embodiment.
[0065] For specific examples, the memory may include but is not limited to random access memory (RAM), read-only memory (ROM), flash memory, first-in-first-out memory (FIFO) and / or first-in-last-out memory (FILO), etc.; the processor may be but is not limited to a microprocessor of the STM32F105 series, an ARM (Advanced RISC-Machines), an X86 or other architecture processor, or a processor with an integrated NPU (neural-network processing units); the transceiver may be but is not limited to a WiFi (Wireless Fidelity) wireless transceiver, a Bluetooth wireless transceiver, a General Packet Radio Service (GPRS) wireless transceiver, a ZigBee protocol (a low-power local area network protocol based on the IEEE802.15.4 standard, ZigBee) wireless transceiver, a 3G transceiver, a 4G transceiver and / or a 5G transceiver, etc.
[0066] The fourth aspect of this embodiment provides a computer-readable storage medium storing instructions including the network request reason management method described in the first aspect of the embodiment, that is, the computer-readable storage medium stores instructions, and when the instructions are executed on a computer, the network request reason management method described in the first aspect is executed. The computer-readable storage medium refers to a carrier for storing data, which may include but is not limited to a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash drive, and / or a memory stick, etc., and the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
[0067] The fifth aspect of this embodiment provides a computer program product comprising instructions, which, when executed on a computer, causes the computer to execute the network request reason management method as described in the first aspect of the embodiment, wherein the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
[0068] It should be understood that certain details are provided in the following description to facilitate a complete understanding of the example embodiments. However, it should be understood by those of ordinary skill in the art that the example embodiments can be implemented without these certain details. For example, the system can be shown in a block diagram to avoid obscuring the example with unnecessary details. In other examples, well-known processes, structures, and techniques may not be shown in unnecessary detail to avoid obscuring the example embodiments.
[0069] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. 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 network request reason management method, characterized in that: include: When a network request is triggered, multiple server nodes recorded in the server list in the router management instance are searched; Based on the load status parameters of each server node among the multiple server nodes, determining a target server node for processing the network request through a load balancing strategy; The network request is routed to the target server node so that the target server node processes the network request.
2. The network request reason management method according to claim 1, characterized in that: Determining the target server node for processing the network request by means of a load balancing strategy includes: The target server node for processing the network request is determined by a random strategy, a polling strategy, a least connection strategy, or a strategy based on response time.
3. The network request reason management method according to claim 1, characterized in that: The routing of the network request to the target server node comprises: The routeRequest method in the router management instance is called to route the network request to the target server node.
4. The network request reason management method according to claim 1, characterized in that: The method further comprises: Establishing the router management instance and the server instance, wherein the router management instance includes the server list, and the server list records the state load parameters of the multiple server nodes; The server instance records the IP addresses and port numbers of the multiple server nodes, as well as the state load parameters of the multiple server nodes.
5. The network request reason management method according to claim 1, characterized in that: After routing the network request to the target server node, the method further includes: Monitoring the processing result of the network request and the operation status of the plurality of server nodes; Determining whether there is an abnormality according to the processing result of the network request and the operating status of the multiple server nodes; When the judgment result is that an exception exists, an exception handling strategy corresponding to the exception type corresponding to the exception is executed.
6. The network request reason management method according to claim 5, characterized in that: The exception handling strategy includes adjusting configuration parameters of the multiple server nodes, a strategy type of the load balancing strategy and / or resource allocation of the multiple server nodes.
7. The network request reason management method according to claim 1, characterized in that: The load status parameters include CPU usage, memory occupancy and / or current number of connections.
8. A network request reason management device, characterized in that: include: A search unit, used for searching for multiple server nodes recorded in a server list in a router management instance when a network request is triggered; a determining unit, configured to determine a target server node for processing the network request through a load balancing strategy based on a load status parameter of each server node among the plurality of server nodes; The routing unit is used to route the network request to the target server node so that the target server node processes the network request.
9. An electronic device, characterized in that: It includes a memory, a processor and a transceiver which are communicatively connected in sequence, wherein the memory is used to store a computer program, the transceiver is used to send and receive messages, and the processor is used to read the computer program to execute the network request reason management method as described in any one of claims 1 to 7.
10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or the instruction is executed by a computer, the network request reason management method according to any one of claims 1 to 7 is implemented.