WO2020211365A1 - Flow load balancing method and apparatus, computer device and storage medium - Google Patents

Flow load balancing method and apparatus, computer device and storage medium Download PDF

Info

Publication number
WO2020211365A1
WO2020211365A1 PCT/CN2019/118386 CN2019118386W WO2020211365A1 WO 2020211365 A1 WO2020211365 A1 WO 2020211365A1 CN 2019118386 W CN2019118386 W CN 2019118386W WO 2020211365 A1 WO2020211365 A1 WO 2020211365A1
Authority
WO
WIPO (PCT)
Prior art keywords
strategy
load
network request
target
preset
Prior art date
Application number
PCT/CN2019/118386
Other languages
French (fr)
Chinese (zh)
Inventor
宋杰
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2020211365A1 publication Critical patent/WO2020211365A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/12Avoiding congestion; Recovering from congestion
    • H04L47/125Avoiding congestion; Recovering from congestion by balancing the load, e.g. traffic engineering

Definitions

  • This application relates to the technical field of data processing, and in particular to a method, device, computer equipment, and storage medium for traffic balancing load.
  • the traditional method uses load balancing equipment to load traffic to multiple servers to achieve simple system high availability, but the stability of the system is not high. Once a failure occurs, it will affect all users.
  • the existing load In the method of balancing the load by strategy, when the load strategy needs to be modified, the process is more complicated and the real-time performance is also poor.
  • the main purpose of this application is to provide a method, device, computer equipment, and storage medium for traffic balancing load, aiming to solve the technical problem of poor system stability when load balancing traffic.
  • this application proposes a load balancing method for traffic, including:
  • the strategy set including a plurality of load strategies
  • This application also provides a flow balancing load device, including:
  • the acquisition request unit is used to acquire the network request initiated by the user through the target system
  • Generating and calling unit for generating a calling instruction according to the network request
  • the invoking strategy unit is configured to invoke a preset strategy set according to the invoking instruction, and the strategy set includes multiple load strategies;
  • a matching strategy unit configured to match a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
  • An obtaining address unit configured to obtain a target service address corresponding to the network request from the target load strategy
  • the forwarding request unit is configured to forward the network request to the server corresponding to the target service address.
  • the present application also provides a computer device, including a memory and a processor, the memory stores computer-readable instructions, and the processor implements the steps of the foregoing method when the computer-readable instructions are executed.
  • the present application also provides a computer-readable storage medium on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of the foregoing method are implemented.
  • the beneficial effects of this application are: forwarding the network request to the load component and forwarding it to the corresponding server through the load strategy, so that different network requests can be forwarded to a suitable server for processing, improving the stability of the system, and when the load needs to be modified
  • forwarding the network request to the load component and forwarding it to the corresponding server through the load strategy so that different network requests can be forwarded to a suitable server for processing, improving the stability of the system, and when the load needs to be modified
  • FIG. 1 is a schematic diagram of steps of a method for balancing load in an embodiment of this application
  • FIG. 2 is a schematic block diagram of the structure of a traffic balancing load device in an embodiment of the application
  • FIG. 3 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
  • the method for traffic balancing load in this embodiment includes:
  • Step S1 Obtain the network request initiated by the user through the target system
  • Step S2 Generate a call instruction according to the network request
  • Step S3 Invoking a preset strategy set according to the invoking instruction, the strategy set including multiple load strategies;
  • Step S4 Match a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
  • Step S5 Obtain the target service address corresponding to the network request from the target load strategy
  • Step S6 Forward the network request to the server corresponding to the target service address.
  • the above method is implemented in a network environment.
  • a set (such as allocating servers, deploying applications) is set up in different areas.
  • New network environment and ensure that the new network environment and the infrastructure used in the old network environment (such as host, network, storage, etc.) are physically separated.
  • the new computer room in Shenzhen is physically separated from the old computer room in Shanghai, but the two share the same system.
  • the other can be used, and the two sets can be used at the same time to further share the load pressure.
  • step S1 and step S2 it is known that an enterprise may have multiple business systems, and each business system has a different function, and the request of each business system must be allocated to a suitable server, so that the system Load balancing.
  • the above-mentioned target system is any business system in this embodiment.
  • the load system receives the network request, it forwards the network request to the load component in the load system. It is a program used to temporarily store network requests and forward them to a suitable server.
  • the load component starts to work. At this time, the load component triggers the generation of a call instruction according to the network request, and the call instruction is used to call a preset strategy set.
  • the load component invokes the strategy set according to the call instruction, such as obtained from the cache or obtained from a preset database.
  • the above strategy set contains multiple load strategies, and these load strategies are used to determine whether the network request Which server to forward to for processing, because different business systems have different load strategies corresponding to the configuration, it is necessary to find the target load strategy corresponding to the network request.
  • the load strategy and network request are preset by The matching rules are matched to find the target load strategy corresponding to the network request in the strategy set.
  • the above matching rule may be that the two are considered to match when the network request meets the preset condition in the load strategy.
  • the load strategy includes policy name, keyword key, request attribute type (any one of request header hd, parameter pm, source org), preset condition cn, routing array, strategy type, etc.
  • the above routing arrays are multiple The collection of service addresses, that is, the routing array contains multiple service addresses, and each service address corresponds to a group of processing servers.
  • These load strategies can be configured in advance through the developer using the command line, or through the user using the online editing page to configure and configure Then store it in the database. When the load strategy needs to be modified, get the load strategy from the database and modify it, and then save the modified load strategy in the database.
  • the routing array in the target load strategy can be obtained. Since there are multiple service addresses in the routing array, it is necessary to select the target corresponding to the network request Service address.
  • the network request includes request line, request header, and request body.
  • the request header includes multiple attributes in the format of "attribute name: attribute value". These attributes include the customer information of the business system that initiated the request (ID) or corresponding client, these can respectively correspond to different target service addresses.
  • the method of selecting the target service address is different. For example, it is selected by preset rules or preset algorithms.
  • the network request can be forwarded to the server corresponding to the target service address.
  • the server processes the aforementioned network requests.
  • the network requests of different business systems are allocated to suitable servers for processing, and the balance is reasonable.
  • the system can run more quickly and stably, and on the other hand, the load strategy can be modified in real time, which is simple and convenient for immediate use.
  • multiple load components are deployed in a cluster manner, that is, a load cluster composed of multiple load components is set up.
  • the service discovery program can be used randomly It is forwarded to any load component in the load cluster.
  • the aforementioned service discovery program is a preset program for randomly selecting load components from the load cluster. After the service discovery program selects one of the load components in the load cluster, it forwards the above network request to the load component for further distribution and forwarding.
  • it can also be distributed according to the current flow (workload) of the load components. First, obtain the current flow of each load component and compare it to find the load component with the smallest flow, and then forward the network request to this Load components.
  • step S3 includes:
  • Step S31 Load the policy set in the preset database into the local memory according to the call instruction to call the policy set.
  • the policy set in order to improve the operating speed of the system, can be cached from the database to redis (Redis is an open source Key-Value storage system written in ANSIC language). It is known that the above policy set is stored in a preset database When the load component is started, the above strategy set is loaded into the local memory according to the calling instruction, so that it can be called during subsequent work, which improves work efficiency.
  • the strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems.
  • the above step S4 includes:
  • Step S41 Match the private load policy with the network request
  • Step S42 If the target load strategy cannot be matched, the public load strategy is matched with the network request to find the target load strategy.
  • the above-mentioned load strategy includes two types of strategies, namely, a private load strategy and a public load strategy.
  • the private load strategy corresponds to a designated business system, that is, it is configured for a certain business system, such as a verification code system. Only the load strategy corresponding to the verification code system can be used; the public load strategy corresponds to most business systems.
  • the load strategy can be used first, that is, the load strategy will The network request is forwarded to the corresponding server. If the private load policy cannot be matched, the public policy is matched with the network request to find the target load policy, and then the network request is forwarded to the corresponding server through the load policy.
  • the load strategy includes the strategy name, keywords, request attributes, preset conditions, routing array, and strategy type.
  • the above step S4 includes:
  • Step S43 Obtain the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy;
  • Step S44 sequentially determine whether the attribute value meets the preset condition of the corresponding load strategy, until the target load strategy whose attribute value meets the preset condition is found.
  • the above-mentioned load policy includes policy name, keyword key, request attribute type (any of request header hd, parameter pm, source org), preset condition (cn condition), routing array, policy type (whether Global st(0 ⁇ 1), global is public, non-global is private), etc.
  • the request attributes and preset conditions of each load strategy configuration may be different. When configuring, start with the request header hd and parameters of the request attributes choose any configuration from pm and source org, and then obtain the attribute value of the requested attribute corresponding to the network request according to the request attribute, determine whether the attribute value meets the preset conditions of the load strategy, and judge each load strategy in turn according to the above method. Until the target load strategy that meets the preset conditions is found.
  • the request attribute of the first load strategy is configured as the parameter pm.
  • the parameter pm value that is, the attribute value
  • the parameter pm value is calculated according to the preset calculation in the preset conditions To check whether the parameter pm value meets the preset condition. For example, if the parameter pm value is equal to 0 for 1000, the network request satisfies the preset condition.
  • the first load strategy defaults to Target load strategy; if the value of the parameter pm is not equal to 0 for 1000, that is, the preset condition is not met, the second load strategy in the strategy set needs to be judged again, and the request attribute of the second load strategy is configured as request Head hd, then get the hd value (attribute value) of the request header of the network request.
  • the preset condition of the second load strategy is that if the hd value is equal to 0 after the remainder of 10, the network request meets the preset condition.
  • the second load strategy is the target load strategy by default, otherwise continue to judge the third load strategy until the target load strategy is found.
  • step S5 includes:
  • Step S51 Obtain the mobile phone number of the user and the system ID of the target system;
  • Step S52 calculating the mobile phone number and the system ID through a hash function to obtain a first value
  • Step S53 Obtain the number of all service addresses in the routing array
  • Step S54 Calculate the first value and the number through a preset formula to obtain the target service address.
  • the target load strategy also includes a routing array.
  • the process of selecting the target service address from the routing array can be as follows: first obtain the user’s mobile phone number and the system ID of the target system, since the network request includes For user information and target system information, the corresponding system ID can be obtained according to the network request, and the corresponding user can be found according to the network request to obtain the mobile phone number. Then, the mobile phone number and the system ID are calculated through a hash function to obtain the first value.
  • the above hash function is a hash function, also known as a "hash" function.
  • step S5 includes:
  • Step S50 Select the target service address from the routing array of the target load strategy through a random algorithm.
  • each service address corresponds to a group of processing servers.
  • the service address of the server needs to be selected from multiple service addresses.
  • the selection is made by a random algorithm, and one of multiple service addresses is randomly selected.
  • the above random algorithm can be any of the known numerical probability algorithm, Monte Carlo algorithm, Sherwood algorithm, and Sherwood algorithm.
  • the calculation process is In the prior art, which will not be repeated here, a service address in the routing array is calculated through a random algorithm, and the service address is the aforementioned target service address.
  • the flow balancing load device in this embodiment includes:
  • the obtaining request unit 100 is configured to obtain a network request initiated by a user through a target system
  • the generating and calling unit 200 is configured to generate a calling instruction according to the network request
  • the invoking strategy unit 300 is configured to invoke a preset strategy set according to the invoking instruction, and the strategy set includes multiple load strategies;
  • the matching strategy unit 400 is configured to match a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
  • An address obtaining unit 500 configured to obtain a target service address corresponding to the network request from the target load policy
  • the forwarding request unit 600 is configured to forward the network request to the server corresponding to the target service address.
  • the above-mentioned device is applied in a network environment.
  • a set of devices such as allocating servers, deploying applications
  • New network environment and ensure that the new network environment and the infrastructure used in the old network environment (such as host, network, storage, etc.) are physically separated.
  • the new computer room in Shenzhen is physically separated from the old computer room in Shanghai, but the two share the same system.
  • the other can be used, and the two sets can be used at the same time to further share the load pressure.
  • the server makes the system load balanced.
  • the above-mentioned target system is any business system in this embodiment.
  • the acquisition request unit 100 in the load system obtains the network request, it forwards the network request to the load system.
  • Load component the above load component is a program for temporarily storing network requests, and distributing and forwarding network requests to a suitable server.
  • the load component starts to work.
  • the load component triggers the generation of a call instruction according to the network request, and the call instruction is used to call a preset strategy set.
  • the invoking strategy unit 300 of the load component invokes the strategy set according to the invocation instruction, such as obtained from a cache or a preset database, the strategy set includes multiple load strategies, These load strategies are used to determine which server to forward the network request distribution to for processing. Since different business systems have different load strategies corresponding to the configuration, it is necessary to find the target load strategy corresponding to the network request.
  • match The policy unit 400 matches the load policy with the network request according to a preset matching rule, thereby finding a target load policy corresponding to the network request in the policy set.
  • the matching rule may satisfy the preset condition in the load policy for the network request, namely It can be considered that the two match.
  • the load strategy includes policy name, keyword key, request attribute type (any one of request header hd, parameter pm, source org), preset condition cn, routing array, strategy type, etc.
  • the above routing arrays are multiple The collection of service addresses, that is, the routing array contains multiple service addresses, and each service address corresponds to a group of processing servers.
  • These load strategies can be configured in advance through the developer using the command line, or through the user using the online editing page to configure and configure Then store it in the database, and when the load strategy needs to be modified, get the load strategy from the database and modify it, and then save the modified load strategy in the database.
  • the routing array in the target load strategy can be obtained. Since there are multiple service addresses in the routing array, it is necessary to select a network
  • the target service address corresponding to the request includes the request line, the request header, and the request body.
  • the request header includes multiple attributes in the format of "attribute name: attribute value". These attributes include the business that initiated the request
  • the customer information (ID) of the system or the corresponding client which can respectively correspond to different target service addresses.
  • the method of selecting the target service address is different. For example, the selection is made by preset rules or preset algorithms.
  • the forwarding request unit 600 can forward the network request to the corresponding target service address.
  • the server which processes the above network request.
  • multiple load components are deployed in a cluster manner, that is, a load cluster composed of multiple load components is set up.
  • the service discovery program can be used randomly It is forwarded to any load component in the load cluster.
  • the above service discovery program is a preset program for randomly selecting load components from the load cluster. After the service discovery program selects one of the load components in the load cluster, it forwards the above network request to the load component for further distribution and forwarding.
  • it can also be distributed according to the current flow (workload) of the load components. First, obtain the current flow of each load component and compare it to find the load component with the smallest flow, and then forward the network request to this Load components.
  • the above-mentioned calling strategy unit 300 includes:
  • the loading strategy subunit is configured to load the strategy set in the preset database to the local memory according to the calling instruction to invoke the strategy set.
  • the policy set in order to improve the operating speed of the system, can be cached from the database to redis (Redis is an open source Key-Value storage system written in ANSIC language). It is known that the above policy set is stored in a preset database When the load component is started, the above strategy set is loaded into the local memory according to the calling instruction, so that it can be called during subsequent work, and work efficiency is improved.
  • the strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems.
  • the above-mentioned matching strategy unit 400 includes:
  • the first matching subunit is used to match the private load policy with the network request
  • the second matching subunit is configured to match the public load strategy with the network request when the target load strategy cannot be matched to find the target load strategy.
  • the above-mentioned load strategy includes two types of strategies, namely, a private load strategy and a public load strategy.
  • the private load strategy corresponds to a designated business system, that is, it is configured for a certain business system, such as a verification code system. Only the load strategy corresponding to the verification code system can be used; the public load strategy corresponds to most business systems.
  • the load strategy can be used first, that is, the load strategy will The network request is forwarded to the corresponding server. If the private load policy cannot be matched, the public policy is matched with the network request to find the target load policy, and then the network request is forwarded to the corresponding server through the load policy.
  • the load strategy includes a strategy name, keywords, request attributes, preset conditions, routing arrays, and strategy types.
  • the above matching strategy unit 400 includes:
  • the acquiring attribute subunit is configured to acquire the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy;
  • the judgment condition subunit is used to sequentially judge whether the attribute value meets the corresponding preset condition of the load strategy, until the target load strategy whose attribute value meets the preset condition is found.
  • the above-mentioned load policy includes policy name, keyword key, request attribute type (any of request header hd, parameter pm, source org), preset condition (cn condition), routing array, policy type (whether Global st(0 ⁇ 1), global is public, non-global is private), etc.
  • the request attributes and preset conditions of each load strategy configuration may be different. When configuring, start with the request header hd and parameters of the request attributes choose any configuration from pm and source org, and then obtain the attribute value of the requested attribute corresponding to the network request according to the request attribute, determine whether the attribute value meets the preset conditions of the load strategy, and judge each load strategy in turn according to the above method. Until the target load strategy that meets the preset conditions is found.
  • the request attribute of the first load strategy is configured as the parameter pm.
  • the parameter pm value that is, the attribute value
  • the parameter pm value is calculated according to the preset calculation in the preset conditions To check whether the parameter pm value meets the preset condition. For example, if the parameter pm value is equal to 0 for 1000, the network request satisfies the preset condition.
  • the first load strategy defaults to Target load strategy; if the value of the parameter pm is not equal to 0 for 1000, that is, the preset condition is not met, the second load strategy in the strategy set needs to be judged again, and the request attribute of the second load strategy is configured as request Head hd, then get the hd value (attribute value) of the request header of the network request.
  • the preset condition of the second load strategy is that if the hd value is equal to 0 after the remainder of 10, the network request meets the preset condition.
  • the second load strategy is the target load strategy by default, otherwise continue to judge the third load strategy until the target load strategy is found.
  • obtaining the address unit 500 above includes:
  • the number obtaining subunit is used to obtain the mobile phone number of the user and the system ID of the target system;
  • the quantity obtaining subunit is used to obtain the quantity of all service addresses in the routing array
  • the address calculation subunit is configured to calculate the first value and the number through a preset calculation formula to obtain the target service address.
  • the target load strategy also includes a routing array.
  • the process of selecting the target service address from the routing array can be as follows: first obtain the user’s mobile phone number and the system ID of the target system, since the network request includes For user information and target system information, the corresponding system ID can be obtained according to the network request, and the corresponding user can be found according to the network request to obtain the mobile phone number. Then, the mobile phone number and the system ID are calculated through a hash function to obtain the first value.
  • the above hash function is a hash function, also known as a "hash" function.
  • obtaining the address unit 500 above includes:
  • the address selection subunit is used to select the target service address from the routing array of the target load strategy through a random algorithm.
  • an embodiment of the present application also provides a computer device.
  • the computer device may be a server, and its internal structure may be as shown in FIG. 3.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer readable instructions, and a database.
  • the memory provides an environment for the operation of the operating system and computer readable instructions in the non-volatile storage medium.
  • the database of the computer equipment is used to store all the data required for the flow load process.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer-readable instruction is executed by the processor to realize a method of traffic balancing load.
  • the above-mentioned processor executes the steps of the above-mentioned traffic balancing load method: acquiring a network request initiated by a user through a target system; generating a calling instruction according to the network request; calling a preset policy set according to the calling instruction, and the policy set includes a plurality of Load strategy; a plurality of load strategies in the strategy group are matched with the network request according to a preset matching rule to find the target load strategy corresponding to the network request; and the target load strategy is obtained from the target load strategy.
  • the target service address corresponding to the network request ; forwarding the network request to the server corresponding to the target service address.
  • the step of invoking a preset strategy set according to the invoking instruction includes: loading the strategy set in the preset database to a local memory according to the invoking instruction to invoke the strategy set.
  • the above-mentioned strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems, and the plurality of load strategies in the strategy set are matched one by one with the network request according to a preset
  • the step of matching rules to find the target load strategy corresponding to the network request includes: matching the private load strategy with the network request; if the target load strategy cannot be matched, then the public load The strategy is matched with the network request to find the target load strategy.
  • the aforementioned load strategy includes request attributes and preset conditions, and the multiple load strategies in the strategy set are matched one by one with the network request according to a preset matching rule to find the corresponding network request
  • the step of the target load strategy includes: obtaining the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy; sequentially determining whether the attribute value meets the corresponding load strategy The preset condition is reached until the target load strategy whose attribute value meets the preset condition is found.
  • the above-mentioned target load strategy further includes a routing array, the routing array includes a plurality of service addresses, and the step of obtaining a target service address corresponding to the network request from the target load strategy , Including: obtaining the mobile phone number of the user and the system ID of the target system; calculating the mobile phone number and the system ID through a hash function to obtain the first value; obtaining the number of all service addresses in the routing array; The first value and the number are calculated by a preset formula to obtain the target service address.
  • the above step of obtaining the target service address corresponding to the network request from the target load strategy includes: selecting the target service address from the routing array of the target load strategy through a random algorithm .
  • FIG. 3 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
  • An embodiment of the present application further provides a computer-readable storage medium.
  • the computer-readable storage medium is, for example, a non-volatile computer-readable storage medium or a volatile computer-readable storage medium on which Stored with computer-readable instructions, when the computer-readable instructions are executed by the processor, a method for traffic balancing load is realized, specifically: obtaining a network request initiated by a user through the target system; generating a call instruction according to the network request; The instruction calls a preset strategy set, the strategy set includes a plurality of load strategies; the plurality of load strategies in the strategy set are matched with the network request according to the preset matching rule to find the corresponding network request Target load strategy; obtain the target service address corresponding to the network request from the target load strategy; forward the network request to the server corresponding to the target service address.
  • the step of invoking a preset strategy set according to the invoking instruction includes: loading the strategy set in a preset database to a local memory according to the invoking instruction to invoke the strategy set .
  • the above-mentioned strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems, and the plurality of load strategies in the strategy set are matched one by one with the network request according to a preset
  • the step of matching rules to find the target load strategy corresponding to the network request includes: matching the private load strategy with the network request; if the target load strategy cannot be matched, then the public load The strategy is matched with the network request to find the target load strategy.
  • the aforementioned load strategy includes request attributes and preset conditions, and the multiple load strategies in the strategy set are matched one by one with the network request according to a preset matching rule to find the corresponding network request
  • the step of the target load strategy includes: obtaining the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy; sequentially determining whether the attribute value meets the corresponding load strategy The preset condition is reached until the target load strategy whose attribute value meets the preset condition is found.
  • the above-mentioned target load strategy further includes a routing array, the routing array includes a plurality of service addresses, and the step of obtaining a target service address corresponding to the network request from the target load strategy , Including: obtaining the mobile phone number of the user and the system ID of the target system; calculating the mobile phone number and the system ID through a hash function to obtain the first value; obtaining the number of all service addresses in the routing array; The first value and the number are calculated by a preset formula to obtain the target service address.
  • the above step of obtaining the target service address corresponding to the network request from the target load strategy includes: selecting the target service address from the routing array of the target load strategy through a random algorithm .

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

Provided by the present application are a flow load balancing method and apparatus based on data processing, a computer device and a storage medium. The method comprises: obtaining a network request initiated by a user through a target system, and sending a call instruction; calling a preset strategy set according to the call instruction, the strategy set comprising a plurality of load strategies; matching a plurality of load strategies in the strategy set with the network request one by one according to a preset matching rule to find a target load strategy corresponding to the network request; obtaining a target service address corresponding to the network request from the target load strategy; and forwarding the network request to a server corresponding to the target service address. The method enables different network requests to be forwarded to appropriate servers for processing, improves the stability of the system, and realizes direct and immediately effective on-line modification of the load strategy as needed.

Description

流量均衡负载方法、装置、计算机设备和存储介质Flow balance load method, device, computer equipment and storage medium
本申请要求于2019年4月19日提交中国专利局、申请号为2019103190689,申请名称为“流量均衡负载方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on April 19, 2019 with the application number 2019103190689 and the application titled "Flow Balanced Load Method, Device, Computer Equipment and Storage Medium", the entire content of which is by reference Incorporated in this application.
技术领域Technical field
本申请涉及到数据处理的技术领域,特别是涉及到一种流量均衡负载方法、装置、计算机设备和存储介质。This application relates to the technical field of data processing, and in particular to a method, device, computer equipment, and storage medium for traffic balancing load.
背景技术Background technique
随着业务的发展,用户对各个业务系统的使用量也逐渐增长,当网络请求不断地增加,系统的负荷量变大,其响应延时也会随之不断增加,甚至会产生的数据拥塞、流量失衡等问题,所以让系统稳定性变得更加重要。With the development of business, the usage of various business systems by users has gradually increased. When network requests continue to increase and the load on the system increases, the response delay will also increase, and even data congestion and traffic will occur. Problems such as imbalance, so system stability becomes more important.
而传统的方式通过负载均衡设备将流量负载到多个服务器,来实现简单的系统高可用,但是这样系统的稳定性并不高,一旦出现故障,则会影响所有用户使用,另外现有使用负载策略来进行均衡负载的方法中,当需要修改负载策略时,其过程较复杂,实时性也差。The traditional method uses load balancing equipment to load traffic to multiple servers to achieve simple system high availability, but the stability of the system is not high. Once a failure occurs, it will affect all users. In addition, the existing load In the method of balancing the load by strategy, when the load strategy needs to be modified, the process is more complicated and the real-time performance is also poor.
技术问题technical problem
本申请的主要目的为提供一种流量均衡负载方法、装置、计算机设备和存储介质,旨在解决现有负载均衡流量时系统稳定性较差的技术问题。The main purpose of this application is to provide a method, device, computer equipment, and storage medium for traffic balancing load, aiming to solve the technical problem of poor system stability when load balancing traffic.
技术解决方案Technical solutions
基于上述发明目的,本申请提出一种流量均衡负载方法,包括:Based on the above-mentioned purpose of the invention, this application proposes a load balancing method for traffic, including:
获取用户通过目标系统发起的网络请求;Get the network request initiated by the user through the target system;
依据所述网络请求生成调用指令;Generating a call instruction according to the network request;
依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;Calling a preset strategy set according to the calling instruction, the strategy set including a plurality of load strategies;
将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;Matching a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
从所述目标负载策略中得到与所述网络请求对应的目标服务地址;Obtaining the target service address corresponding to the network request from the target load strategy;
将所述网络请求转发到所述目标服务地址对应的服务器。Forward the network request to the server corresponding to the target service address.
本申请还提供一种流量均衡负载装置,包括:This application also provides a flow balancing load device, including:
获取请求单元,用于获取用户通过目标系统发起的网络请求;The acquisition request unit is used to acquire the network request initiated by the user through the target system;
生成调用单元,用于依据所述网络请求生成调用指令;Generating and calling unit for generating a calling instruction according to the network request;
调用策略单元,用于依据所述调用指令调用预设的策略集,所述策略集包 括多个负载策略;The invoking strategy unit is configured to invoke a preset strategy set according to the invoking instruction, and the strategy set includes multiple load strategies;
匹配策略单元,用于将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;A matching strategy unit, configured to match a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
得到地址单元,用于从所述目标负载策略中得到与所述网络请求对应的目标服务地址;An obtaining address unit, configured to obtain a target service address corresponding to the network request from the target load strategy;
转发请求单元,用于将所述网络请求转发到所述目标服务地址对应的服务器。The forwarding request unit is configured to forward the network request to the server corresponding to the target service address.
本申请还提供一种计算机设备,包括存储器和处理器,所述存储器存储有计算机可读指令,所述处理器执行所述计算机可读指令时实现上述方法的步骤。The present application also provides a computer device, including a memory and a processor, the memory stores computer-readable instructions, and the processor implements the steps of the foregoing method when the computer-readable instructions are executed.
本申请还提供了一种计算机可读存储介质,其上存储有计算机可读指令,所述计算机可读指令被处理器执行时实现上述方法的步骤。The present application also provides a computer-readable storage medium on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of the foregoing method are implemented.
有益效果Beneficial effect
本申请的有益效果为:将网络请求转发到负载组件并通过负载策略转发到对应的服务器,以使得不同的网络请求均可以转发到适合的服务器处理,提高系统的稳定性,且当需要修改负载策略时,直接在线修改策略,实时生效。The beneficial effects of this application are: forwarding the network request to the load component and forwarding it to the corresponding server through the load strategy, so that different network requests can be forwarded to a suitable server for processing, improving the stability of the system, and when the load needs to be modified When making a strategy, directly modify the strategy online and take effect in real time.
附图说明Description of the drawings
图1为本申请一实施例中流量均衡负载方法的步骤示意图;FIG. 1 is a schematic diagram of steps of a method for balancing load in an embodiment of this application;
图2为本申请一实施例中流量均衡负载装置的结构示意框图;2 is a schematic block diagram of the structure of a traffic balancing load device in an embodiment of the application;
图3为本申请一实施例的计算机设备的结构示意框图。FIG. 3 is a schematic block diagram of the structure of a computer device according to an embodiment of the application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics, and advantages of the purpose of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
本发明的最佳实施方式The best mode of the invention
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It should be understood that the specific embodiments described here are only used to explain the application, and are not used to limit the application.
参照图1,本实施例中的流量均衡负载方法,包括:Referring to Figure 1, the method for traffic balancing load in this embodiment includes:
步骤S1:获取用户通过目标系统发起的网络请求;Step S1: Obtain the network request initiated by the user through the target system;
步骤S2:依据所述网络请求生成调用指令;Step S2: Generate a call instruction according to the network request;
步骤S3:依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;Step S3: Invoking a preset strategy set according to the invoking instruction, the strategy set including multiple load strategies;
步骤S4:将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;Step S4: Match a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
步骤S5:从所述目标负载策略中得到与所述网络请求对应的目标服务地址;Step S5: Obtain the target service address corresponding to the network request from the target load strategy;
步骤S6:将所述网络请求转发到所述目标服务地址对应的服务器。Step S6: Forward the network request to the server corresponding to the target service address.
本实施例中,上述方法在网络环境中实现,为了使网络出现故障时,用户之间不会干扰,系统工作不会被打断,在不同的区域搭建(例如分配服务器、部署应用)一套新网络环境,且保证新网络环境以及旧网络环境使用的基础设施(如主机、网络、存储等)物理隔离,例如深圳新机房与上海旧机房物理隔离,但两者共用一个系统,当其中一个出现障碍,另一个还能使用,两套同时使用,进一步分担负载压力。In this embodiment, the above method is implemented in a network environment. In order to prevent users from interfering with each other when the network fails, and the system work will not be interrupted, a set (such as allocating servers, deploying applications) is set up in different areas. New network environment, and ensure that the new network environment and the infrastructure used in the old network environment (such as host, network, storage, etc.) are physically separated. For example, the new computer room in Shenzhen is physically separated from the old computer room in Shanghai, but the two share the same system. When obstacles occur, the other can be used, and the two sets can be used at the same time to further share the load pressure.
如上述步骤S1以及步骤S2所述,已知的是,一个企业可能有多个业务系统,每个业务系统作用不一样,而处理每个业务系统的请求则得分配到适合的服务器,使得系统负载均衡。上述目标系统即为本实施例中的任意一种业务系统,当用户通过目标系统发起网络请求,负载系统接收到该网络请求之后,将该网络请求转发到负载系统中的负载组件,上述负载组件为用于暂存网络请求,并将网络请求分配转发至适合的服务器的程序。当将网络请求转发到负载组件时,负载组件开始启动进行工作,这时负载组件会根据网络请求触发生成调用指令,该调用指令用于调用预设的策略集。As mentioned in step S1 and step S2 above, it is known that an enterprise may have multiple business systems, and each business system has a different function, and the request of each business system must be allocated to a suitable server, so that the system Load balancing. The above-mentioned target system is any business system in this embodiment. When a user initiates a network request through the target system, and the load system receives the network request, it forwards the network request to the load component in the load system. It is a program used to temporarily store network requests and forward them to a suitable server. When the network request is forwarded to the load component, the load component starts to work. At this time, the load component triggers the generation of a call instruction according to the network request, and the call instruction is used to call a preset strategy set.
如上述步骤S3以及步骤S4所述,负载组件依据调用指令调用策略集,如从缓存中获取或者从预设数据库中获取,上述策略集包含多个负载策略,这些负载策略用于判断将网络请求分配转发到哪个服务器进行处理,由于不同的业务系统,对应配置的负载策略也不一样,故而需要找到与网络请求对应的目标负载策略,本实施例中,通过将负载策略与网络请求按预设匹配规则进行匹配,从而在策略集中找到与网络请求对应的目标负载策略,上述匹配规则可以为上述网络请求满足负载策略中预设的条件时即认为两者匹配。其中,负载策略包括策略名称name、关键字key、请求属性type(请求头hd、参数pm、来源org中任一个)、预设条件cn、路由数组、策略类型等内容,上述路由数组是多个服务地址的集合,即路由数组包含有多个服务地址,每个服务地址对应一组处理服务器,这些负载策略可以事先通过开发人员使用命令行进行配置,或通过用户使用在线编辑页面进行配置,配置之后将其存储至数据库中,当需要修改负载策略时,从数据库中获取负载策略并修改,然后再将修改后的负载策略存至数据库即可。As described in the above steps S3 and S4, the load component invokes the strategy set according to the call instruction, such as obtained from the cache or obtained from a preset database. The above strategy set contains multiple load strategies, and these load strategies are used to determine whether the network request Which server to forward to for processing, because different business systems have different load strategies corresponding to the configuration, it is necessary to find the target load strategy corresponding to the network request. In this embodiment, the load strategy and network request are preset by The matching rules are matched to find the target load strategy corresponding to the network request in the strategy set. The above matching rule may be that the two are considered to match when the network request meets the preset condition in the load strategy. Among them, the load strategy includes policy name, keyword key, request attribute type (any one of request header hd, parameter pm, source org), preset condition cn, routing array, strategy type, etc. The above routing arrays are multiple The collection of service addresses, that is, the routing array contains multiple service addresses, and each service address corresponds to a group of processing servers. These load strategies can be configured in advance through the developer using the command line, or through the user using the online editing page to configure and configure Then store it in the database. When the load strategy needs to be modified, get the load strategy from the database and modify it, and then save the modified load strategy in the database.
如上述步骤S5以及步骤S6所述,找到对应的目标负载策略之后,即可以得到目标负载策略中的路由数组,由于路由数组中有多个服务地址,故而需要从中选出与网络请求对应的目标服务地址,已知的是,网络请求包括请求行、请求头以及请求体,请求头包括多项属性,其格式为“属性名:属性值”,这些属性当中包括发起请求的业务系统的客户信息(ID)或对应的客户端,这些均可分别对应不同的目标服务地址。对于不同的业务系统,选出目标服务地址的方法不一样,例如通过预设规则或者预设算法来选择,当找到目标服务地址后,即可将网络请求转发到目标服务地址对应的服务器,由该服务器处理上述网络请求。通过该方法将不同业务系统的网络请求分配到适合的服务器处理,均衡合理,一方面可以使系统运行更快速稳定,一方面能实时修改负载策略,即时使用,简单方便。As described in the above steps S5 and S6, after finding the corresponding target load strategy, the routing array in the target load strategy can be obtained. Since there are multiple service addresses in the routing array, it is necessary to select the target corresponding to the network request Service address. It is known that the network request includes request line, request header, and request body. The request header includes multiple attributes in the format of "attribute name: attribute value". These attributes include the customer information of the business system that initiated the request (ID) or corresponding client, these can respectively correspond to different target service addresses. For different business systems, the method of selecting the target service address is different. For example, it is selected by preset rules or preset algorithms. When the target service address is found, the network request can be forwarded to the server corresponding to the target service address. The server processes the aforementioned network requests. Through this method, the network requests of different business systems are allocated to suitable servers for processing, and the balance is reasonable. On the one hand, the system can run more quickly and stably, and on the other hand, the load strategy can be modified in real time, which is simple and convenient for immediate use.
在一个实施例中,为了保证负载组件的高可用性,采用集群的方式部署多个负载组件,即设置由多个负载组件组成的负载集群,当获取到网络请求后,即可通过服务发现程序随机地将其转发到负载集群中的任一个负载组件。上述服务发现程序为预设的用于从负载集群中随机选择负载组件的程序。当服务发现程序选出负载集群中其中一个负载组件之后,将上述网络请求转发到该负载组件,以便进一步分配转发。In one embodiment, in order to ensure the high availability of load components, multiple load components are deployed in a cluster manner, that is, a load cluster composed of multiple load components is set up. After the network request is obtained, the service discovery program can be used randomly It is forwarded to any load component in the load cluster. The aforementioned service discovery program is a preset program for randomly selecting load components from the load cluster. After the service discovery program selects one of the load components in the load cluster, it forwards the above network request to the load component for further distribution and forwarding.
在另一个例子,还可以根据负载组件当前的流量(工作量)大小来进行分配,首先获得各个负载组件的当前流量,并进行对比,以找出流量最小的负载组件,然后网络请求转发到该负载组件。In another example, it can also be distributed according to the current flow (workload) of the load components. First, obtain the current flow of each load component and compare it to find the load component with the smallest flow, and then forward the network request to this Load components.
在一个实施例中,上述步骤S3,包括:In an embodiment, the above step S3 includes:
步骤S31:依据所述调用指令将预设数据库中的所述策略集加载至本地内存,以调用所述策略集。Step S31: Load the policy set in the preset database into the local memory according to the call instruction to call the policy set.
本实施例中,为了提高系统运行速度,可将策略集先从数据库缓存到redis(Redis是一个开源的使用ANSIC语言编写的Key-Value存储系统),已知上述策略集存储在预设数据库中,负载组件启动的同时依据调用指令上述策略集加载到本地内存中,以便后续工作时调用,提高工作效率。In this embodiment, in order to improve the operating speed of the system, the policy set can be cached from the database to redis (Redis is an open source Key-Value storage system written in ANSIC language). It is known that the above policy set is stored in a preset database When the load component is started, the above strategy set is loaded into the local memory according to the calling instruction, so that it can be called during subsequent work, which improves work efficiency.
在一个实施例中,所述策略集中包括对应指定业务系统的私有负载策略以及对应所有业务系统的公有负载策略,上述步骤S4,包括:In one embodiment, the strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems. The above step S4 includes:
步骤S41:将所述私有负载策略与所述网络请求进行匹配;Step S41: Match the private load policy with the network request;
步骤S42:若匹配不到所述目标负载策略,则将所述公有负载策略与所述 网络请求进行匹配,以找到所述目标负载策略。Step S42: If the target load strategy cannot be matched, the public load strategy is matched with the network request to find the target load strategy.
本实施例中,上述负载策略的策略类型包含两类,分别为私有负载策略以及公有负载策略,私有负载策略对应指定的业务系统,即是针对某个业务系统而配置的,例如验证码系统,则只能使用对应验证码系统的负载策略;公有负载策略对应大部分的业务系统。匹配的时候,先将私有负载策略进行匹配,若在私有负载策略中找到目标负载策略,表明该业务系统对应设置有针对性的负载策略,则可以优先使用该负载策略,即通过该负载策略将网络请求转发至对应的服务器,若匹配不到私有负载策略,则将公有策略与网络请求进行匹配,从中找到目标负载策略,然后通过该负载策略将网络请求转发至对应的服务器。In this embodiment, the above-mentioned load strategy includes two types of strategies, namely, a private load strategy and a public load strategy. The private load strategy corresponds to a designated business system, that is, it is configured for a certain business system, such as a verification code system. Only the load strategy corresponding to the verification code system can be used; the public load strategy corresponds to most business systems. When matching, first match the private load strategy. If the target load strategy is found in the private load strategy, it indicates that the business system has set a targeted load strategy, then the load strategy can be used first, that is, the load strategy will The network request is forwarded to the corresponding server. If the private load policy cannot be matched, the public policy is matched with the network request to find the target load policy, and then the network request is forwarded to the corresponding server through the load policy.
在一个实施例中,所述负载策略包括策略名称、关键词、请求属性、预设条件、路由数组以及策略类型,上述步骤S4,包括:In one embodiment, the load strategy includes the strategy name, keywords, request attributes, preset conditions, routing array, and strategy type. The above step S4 includes:
步骤S43:依据每个所述负载策略的请求属性从所述网络请求中获取对应所述负载策略的属性值;Step S43: Obtain the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy;
步骤S44:依次判断所述属性值是否满足对应的所述负载策略的预设条件,直到找到所述属性值满足所述预设条件的所述目标负载策略。Step S44: sequentially determine whether the attribute value meets the preset condition of the corresponding load strategy, until the target load strategy whose attribute value meets the preset condition is found.
本实施例中,上述负载策略包括策略名称name、关键字key、请求属性type(请求头hd、参数pm、来源org中任一个)、预设条件(cn条件)、路由数组、策略类型(是否全局st(0\1),全局即为公有、非全局即为私有)等内容,每个负载策略配置的请求属性以及预设条件可能都不一样,配置时从请求属性的请求头hd、参数pm、来源org中选择任一个配置,然后依据该请求属性获取网络请求对应该请求属性的属性值,判断属性值是否满足该负载策略的预设条件,将每一个负载策略依次按照上述方法判断,直至找到满足预设条件的目标负载策略。In this embodiment, the above-mentioned load policy includes policy name, keyword key, request attribute type (any of request header hd, parameter pm, source org), preset condition (cn condition), routing array, policy type (whether Global st(0\1), global is public, non-global is private), etc. The request attributes and preset conditions of each load strategy configuration may be different. When configuring, start with the request header hd and parameters of the request attributes Choose any configuration from pm and source org, and then obtain the attribute value of the requested attribute corresponding to the network request according to the request attribute, determine whether the attribute value meets the preset conditions of the load strategy, and judge each load strategy in turn according to the above method. Until the target load strategy that meets the preset conditions is found.
举例地,第一个负载策略的请求属性配置的为参数pm,在匹配的时候,获取网络请求的参数pm值(即属性值),将该参数pm值按照预设条件中的预设算式计算,以此查看该参数pm值是否满足预设条件,例如,预设条件是若参数pm值对1000求余等于0,则网络请求满足该预设条件,这时第一个负载策略即默认为目标负载策略;若参数pm值对1000求余不等于0,即不满足预设条件,则需要将策略集中的第二个负载策略再次进行判断,第二个负载策略的请求属性配置的为请求头hd,则这时获取网络请求的请求头的hd值(属性值),第二个负载策略的预设条件是若hd值对10求余等于0,则网络请求 满足预设条件,这时第二个负载策略即默认为目标负载策略,否则继续判断第三个负载策略,直至找到目标负载策略。For example, the request attribute of the first load strategy is configured as the parameter pm. When matching, the parameter pm value (that is, the attribute value) of the network request is obtained, and the parameter pm value is calculated according to the preset calculation in the preset conditions To check whether the parameter pm value meets the preset condition. For example, if the parameter pm value is equal to 0 for 1000, the network request satisfies the preset condition. At this time, the first load strategy defaults to Target load strategy; if the value of the parameter pm is not equal to 0 for 1000, that is, the preset condition is not met, the second load strategy in the strategy set needs to be judged again, and the request attribute of the second load strategy is configured as request Head hd, then get the hd value (attribute value) of the request header of the network request. The preset condition of the second load strategy is that if the hd value is equal to 0 after the remainder of 10, the network request meets the preset condition. The second load strategy is the target load strategy by default, otherwise continue to judge the third load strategy until the target load strategy is found.
例如可如下配置一个负载策略:名称p1,关键字为ip,请求属性为参数pm,预设条件为参数的值对1000求余等于0,路由数组包括两个服务地址,分别是100.78.98.111以及100.78.98.11,策略类型为私有负载策略,则表达如下:{"name":"p1","key":"ip","type":"pm","cn":"$var%1000==0","tar":"100.78.98.111|||100.78.98.112||||4344|||433","st":"1"}For example, a load strategy can be configured as follows: the name p1, the keyword ip, the request attribute is the parameter pm, the preset condition is that the value of the parameter is equal to 0 for 1000, and the routing array includes two service addresses, 100.78.98.111 and 100.78.98.111 respectively. 100.78.98.11, the policy type is a private load policy, which is expressed as follows: {"name":"p1","key":"ip","type":"pm","cn":"$var%1000= =0","tar":"100.78.98.111|||100.78.98.112||||4344|||433","st":"1"}
在一个实施例中,上述步骤S5,包括:In an embodiment, the above step S5 includes:
步骤S51:获取所述用户的手机号码以及所述目标系统的系统ID;Step S51: Obtain the mobile phone number of the user and the system ID of the target system;
步骤S52:将所述手机号码以及系统ID通过hash函数运算得到第一数值;Step S52: calculating the mobile phone number and the system ID through a hash function to obtain a first value;
步骤S53:获取所述路由数组中所有服务地址的数量;Step S53: Obtain the number of all service addresses in the routing array;
步骤S54:将所述第一数值以及所述数量通过预设算式计算得到所述目标服务地址。Step S54: Calculate the first value and the number through a preset formula to obtain the target service address.
本实施例中,已知目标负载策略中还包括路由数组,从路由数组中选择出目标服务地址的过程可如下:先获取用户的手机号码,以及目标系统的系统ID,由于网络请求中包括有用户信息以及目标系统信息,则可依据网络请求获得对应的系统ID,以及依据网络请求查找对应的用户以获取其手机号码。然后将手机号码以及系统ID通过hash函数运算得到第一数值,上述hash函数即是散列函数,又称“哈希”函数。本实施例中,该hash函数的表达式为n=hash(phone+id),将手机号码以及系统ID拼接通过hash函数运算得到0~31间的第一数值n,然后获取目标负载策略的路由数组中所有服务地址的数量。In this embodiment, it is known that the target load strategy also includes a routing array. The process of selecting the target service address from the routing array can be as follows: first obtain the user’s mobile phone number and the system ID of the target system, since the network request includes For user information and target system information, the corresponding system ID can be obtained according to the network request, and the corresponding user can be found according to the network request to obtain the mobile phone number. Then, the mobile phone number and the system ID are calculated through a hash function to obtain the first value. The above hash function is a hash function, also known as a "hash" function. In this embodiment, the expression of the hash function is n=hash(phone+id), the mobile phone number and the system ID are spliced through the hash function operation to obtain the first value n between 0 and 31, and then the route of the target load strategy is obtained The number of all service addresses in the array.
上述步骤S54中,预设算式可以为:add=g[n%l],其中,add为所述目标服务地址,n为所述第一数值,l为所述路由数组中服务地址的数量,g为所述路由数组,g[n%l]为取所述路由数组中第n%l个服务地址,具体而言,首先求得第一数值除以数量的余数m,即m=n%l,而g[m]则为路由数组中第m个服务地址,例如,当求得m为5时,即上述目标服务地址为路由数组中的第五个服务地址。In the above step S54, the preset calculation formula may be: add=g[n%l], where add is the target service address, n is the first value, and l is the number of service addresses in the routing array, g is the routing array, and g[n%l] is the n%l service address in the routing array. Specifically, first obtain the remainder m of the first value divided by the number, that is, m=n% l, and g[m] is the m-th service address in the routing array. For example, when m is found to be 5, the above-mentioned target service address is the fifth service address in the routing array.
在一个实施例中,上述步骤S5,包括:In an embodiment, the above step S5 includes:
步骤S50:通过随机算法从所述目标负载策略的路由数组中选择出所述目标服务地址。Step S50: Select the target service address from the routing array of the target load strategy through a random algorithm.
由于路由数组包含有多个服务地址,每个服务地址对应一组处理服务器,当要将网络请求转发到服务器时,则需要从多个服务地址中选择该服务器的服务地址,本实施例中,通过随机算法进行选择,随机选择多个服务地址中的一个,上述随机算法可以为已知的数值概率算法、蒙特卡洛算法Monte Carlo、舍伍德算法Sherwood等算法中的任一种,计算过程为现有技术,这里不再赘述,通过随机算法计算得到该路由数组中的一个服务地址,该服务地址即为上述目标服务地址。Since the routing array contains multiple service addresses, each service address corresponds to a group of processing servers. When the network request is to be forwarded to the server, the service address of the server needs to be selected from multiple service addresses. In this embodiment, The selection is made by a random algorithm, and one of multiple service addresses is randomly selected. The above random algorithm can be any of the known numerical probability algorithm, Monte Carlo algorithm, Sherwood algorithm, and Sherwood algorithm. The calculation process is In the prior art, which will not be repeated here, a service address in the routing array is calculated through a random algorithm, and the service address is the aforementioned target service address.
参照图2,本实施例中流量均衡负载装置,包括:Referring to Figure 2, the flow balancing load device in this embodiment includes:
获取请求单元100,用于获取用户通过目标系统发起的网络请求;The obtaining request unit 100 is configured to obtain a network request initiated by a user through a target system;
生成调用单元200,用于依据所述网络请求生成调用指令;The generating and calling unit 200 is configured to generate a calling instruction according to the network request;
调用策略单元300,用于依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;The invoking strategy unit 300 is configured to invoke a preset strategy set according to the invoking instruction, and the strategy set includes multiple load strategies;
匹配策略单元400,用于将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;The matching strategy unit 400 is configured to match a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
得到地址单元500,用于从所述目标负载策略中得到与所述网络请求对应的目标服务地址;An address obtaining unit 500, configured to obtain a target service address corresponding to the network request from the target load policy;
转发请求单元600,用于将所述网络请求转发到所述目标服务地址对应的服务器。The forwarding request unit 600 is configured to forward the network request to the server corresponding to the target service address.
本实施例中,上述装置应用在网络环境中,为了使网络出现故障时,用户之间不会干扰,系统工作不会被打断,在不同的区域搭建(例如分配服务器、部署应用)一套新网络环境,且保证新网络环境以及旧网络环境使用的基础设施(如主机、网络、存储等)物理隔离,例如深圳新机房与上海旧机房物理隔离,但两者共用一个系统,当其中一个出现障碍,另一个还能使用,两套同时使用,进一步分担负载压力。In this embodiment, the above-mentioned device is applied in a network environment. In order to prevent interference between users when the network fails, and the system work will not be interrupted, a set of devices (such as allocating servers, deploying applications) is built in different areas. New network environment, and ensure that the new network environment and the infrastructure used in the old network environment (such as host, network, storage, etc.) are physically separated. For example, the new computer room in Shenzhen is physically separated from the old computer room in Shanghai, but the two share the same system. When obstacles occur, the other can be used, and the two sets can be used at the same time to further share the load pressure.
如上述获取请求单元100以及生成调用单元200所述,已知的是,一个企业可能有多个业务系统,每个业务系统作用不一样,而处理每个业务系统的请求则得分配到适合的服务器,使得系统负载均衡。上述目标系统即为本实施例中的任意一种业务系统,当用户通过目标系统发起网络请求,负载系统中的获取请求单元100获取到该网络请求之后,将该网络请求转发到负载系统中的负载组件,上述负载组件为用于暂存网络请求,并将网络请求分配转发至适合的服务器的程序。当将网络请求转发到负载组件时,负载组件开始启动进行工作, 这时负载组件会根据网络请求触发生成调用指令,该调用指令用于调用预设的策略集。As described in the above-mentioned acquisition request unit 100 and the generation and invocation unit 200, it is known that an enterprise may have multiple business systems, and each business system has a different function, and the request for processing each business system must be allocated to a suitable The server makes the system load balanced. The above-mentioned target system is any business system in this embodiment. When a user initiates a network request through the target system, after the acquisition request unit 100 in the load system obtains the network request, it forwards the network request to the load system. Load component, the above load component is a program for temporarily storing network requests, and distributing and forwarding network requests to a suitable server. When the network request is forwarded to the load component, the load component starts to work. At this time, the load component triggers the generation of a call instruction according to the network request, and the call instruction is used to call a preset strategy set.
如上述调用策略单元300以及匹配策略单元400所述,负载组件的调用策略单元300依据调用指令调用策略集,如从缓存中获取或者从预设数据库中获取,上述策略集包含多个负载策略,这些负载策略用于判断将网络请求分配转发到哪个服务器进行处理,由于不同的业务系统,对应配置的负载策略也不一样,故而需要找到与网络请求对应的目标负载策略,本实施例中,匹配策略单元400通过将负载策略与网络请求按预设匹配规则进行匹配,从而在策略集中找到与网络请求对应的目标负载策略,上述匹配规则可以为上述网络请求满意负载策略中预设的条件,即可以认为两者匹配。其中,负载策略包括策略名称name、关键字key、请求属性type(请求头hd、参数pm、来源org中任一个)、预设条件cn、路由数组、策略类型等内容,上述路由数组是多个服务地址的集合,即路由数组包含有多个服务地址,每个服务地址对应一组处理服务器,这些负载策略可以事先通过开发人员使用命令行进行配置,或通过用户使用在线编辑页面进行配置,配置然后之后将其存储至数据库中,当需要修改负载策略时,从数据库中获取负载策略并修改,然后再将修改后的负载策略存至数据库即可。As described in the invoking strategy unit 300 and the matching strategy unit 400, the invoking strategy unit 300 of the load component invokes the strategy set according to the invocation instruction, such as obtained from a cache or a preset database, the strategy set includes multiple load strategies, These load strategies are used to determine which server to forward the network request distribution to for processing. Since different business systems have different load strategies corresponding to the configuration, it is necessary to find the target load strategy corresponding to the network request. In this embodiment, match The policy unit 400 matches the load policy with the network request according to a preset matching rule, thereby finding a target load policy corresponding to the network request in the policy set. The matching rule may satisfy the preset condition in the load policy for the network request, namely It can be considered that the two match. Among them, the load strategy includes policy name, keyword key, request attribute type (any one of request header hd, parameter pm, source org), preset condition cn, routing array, strategy type, etc. The above routing arrays are multiple The collection of service addresses, that is, the routing array contains multiple service addresses, and each service address corresponds to a group of processing servers. These load strategies can be configured in advance through the developer using the command line, or through the user using the online editing page to configure and configure Then store it in the database, and when the load strategy needs to be modified, get the load strategy from the database and modify it, and then save the modified load strategy in the database.
如上述得到地址单元500以及转发请求单元600所述,找到对应的目标负载策略之后,即可以得到目标负载策略中的路由数组,由于路由数组中有多个服务地址,故而需要从中选出与网络请求对应的目标服务地址,已知的是,网络请求包括请求行、请求头以及请求体,请求头包括多项属性,其格式为“属性名:属性值”,这些属性当中包括发起请求的业务系统的客户信息(ID)或对应的客户端,这些均可分别对应不同的目标服务地址。对于不同的业务系统,选出目标服务地址的方法不一样,例如通过预设规则或者预设算法来选择,当找到目标服务地址后,转发请求单元600可将网络请求转发到目标服务地址对应的服务器,由该服务器处理上述网络请求。通过将不同业务系统的网络请求分配到适合的服务器处理,均衡合理,一方面可以使系统运行更快速稳定,一方面能实时修改负载策略,即时使用,简单方便。As described in the address unit 500 and the forwarding request unit 600 described above, after finding the corresponding target load strategy, the routing array in the target load strategy can be obtained. Since there are multiple service addresses in the routing array, it is necessary to select a network The target service address corresponding to the request. It is known that the network request includes the request line, the request header, and the request body. The request header includes multiple attributes in the format of "attribute name: attribute value". These attributes include the business that initiated the request The customer information (ID) of the system or the corresponding client, which can respectively correspond to different target service addresses. For different business systems, the method of selecting the target service address is different. For example, the selection is made by preset rules or preset algorithms. When the target service address is found, the forwarding request unit 600 can forward the network request to the corresponding target service address. The server, which processes the above network request. By distributing the network requests of different business systems to suitable servers for processing, balanced and reasonable, on the one hand, the system can run faster and more stable, on the other hand, the load strategy can be modified in real time, which is simple and convenient for immediate use.
在一个实施例中,为了保证负载组件的高可用性,采用集群的方式部署多个负载组件,即设置由多个负载组件组成的负载集群,当获取到网络请求后,即可通过服务发现程序随机地将其转发到负载集群中的任一个负载组件。上述 服务发现程序为预设的用于从负载集群中随机选择负载组件的程序。当服务发现程序选出负载集群中其中一个负载组件之后,将上述网络请求转发到该负载组件,以便进一步分配转发。In one embodiment, in order to ensure the high availability of load components, multiple load components are deployed in a cluster manner, that is, a load cluster composed of multiple load components is set up. After the network request is obtained, the service discovery program can be used randomly It is forwarded to any load component in the load cluster. The above service discovery program is a preset program for randomly selecting load components from the load cluster. After the service discovery program selects one of the load components in the load cluster, it forwards the above network request to the load component for further distribution and forwarding.
在另一个例子,还可以根据负载组件当前的流量(工作量)大小来进行分配,首先获得各个负载组件的当前流量,并进行对比,以找出流量最小的负载组件,然后网络请求转发到该负载组件。In another example, it can also be distributed according to the current flow (workload) of the load components. First, obtain the current flow of each load component and compare it to find the load component with the smallest flow, and then forward the network request to this Load components.
在一个实施例中,上述调用策略单元300,包括:In an embodiment, the above-mentioned calling strategy unit 300 includes:
加载策略子单元,用于依据所述调用指令将预设数据库中的所述策略集加载至本地内存,以调用所述策略集。The loading strategy subunit is configured to load the strategy set in the preset database to the local memory according to the calling instruction to invoke the strategy set.
本实施例中,为了提高系统运行速度,可将策略集先从数据库缓存到redis(Redis是一个开源的使用ANSIC语言编写的Key-Value存储系统),已知上述策略集存储在预设数据库中,负载组件启动的同时依据调用指令将上述策略集加载到本地内存中,以便后续工作时调用,提高工作效率。In this embodiment, in order to improve the operating speed of the system, the policy set can be cached from the database to redis (Redis is an open source Key-Value storage system written in ANSIC language). It is known that the above policy set is stored in a preset database When the load component is started, the above strategy set is loaded into the local memory according to the calling instruction, so that it can be called during subsequent work, and work efficiency is improved.
在一个实施例中,所述策略集中包括对应指定业务系统的私有负载策略以及对应所有业务系统的公有负载策略,上述匹配策略单元400,包括:In one embodiment, the strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems. The above-mentioned matching strategy unit 400 includes:
第一匹配子单元,用于将所述私有负载策略与所述网络请求进行匹配;The first matching subunit is used to match the private load policy with the network request;
第二匹配子单元,用于匹配不到所述目标负载策略时,将所述公有负载策略与所述网络请求进行匹配,以找到所述目标负载策略。The second matching subunit is configured to match the public load strategy with the network request when the target load strategy cannot be matched to find the target load strategy.
本实施例中,上述负载策略的策略类型包含两类,分别为私有负载策略以及公有负载策略,私有负载策略对应指定的业务系统,即是针对某个业务系统而配置的,例如验证码系统,则只能使用对应验证码系统的负载策略;公有负载策略对应大部分的业务系统。匹配的时候,先将私有负载策略进行匹配,若在私有负载策略中找到目标负载策略,表明该业务系统对应设置有针对性的负载策略,则可以优先使用该负载策略,即通过该负载策略将网络请求转发至对应的服务器,若匹配不到私有负载策略,则将公有策略与网络请求进行匹配,从中找到目标负载策略,然后通过该负载策略将网络请求转发至对应的服务器。In this embodiment, the above-mentioned load strategy includes two types of strategies, namely, a private load strategy and a public load strategy. The private load strategy corresponds to a designated business system, that is, it is configured for a certain business system, such as a verification code system. Only the load strategy corresponding to the verification code system can be used; the public load strategy corresponds to most business systems. When matching, first match the private load strategy. If the target load strategy is found in the private load strategy, it indicates that the business system has set a targeted load strategy, then the load strategy can be used first, that is, the load strategy will The network request is forwarded to the corresponding server. If the private load policy cannot be matched, the public policy is matched with the network request to find the target load policy, and then the network request is forwarded to the corresponding server through the load policy.
在一个实施例中,所述负载策略包括策略名称、关键词、请求属性、预设条件、路由数组以及策略类型,上述匹配策略单元400,包括:In one embodiment, the load strategy includes a strategy name, keywords, request attributes, preset conditions, routing arrays, and strategy types. The above matching strategy unit 400 includes:
获取属性子单元,用于依据每个所述负载策略的请求属性从所述网络请求中获取对应所述负载策略的属性值;The acquiring attribute subunit is configured to acquire the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy;
判断条件子单元,用于依次判断所述属性值是否满足对应的所述负载策略 的预设条件,直到找到所述属性值满足所述预设条件的所述目标负载策略。The judgment condition subunit is used to sequentially judge whether the attribute value meets the corresponding preset condition of the load strategy, until the target load strategy whose attribute value meets the preset condition is found.
本实施例中,上述负载策略包括策略名称name、关键字key、请求属性type(请求头hd、参数pm、来源org中任一个)、预设条件(cn条件)、路由数组、策略类型(是否全局st(0\1),全局即为公有、非全局即为私有)等内容,每个负载策略配置的请求属性以及预设条件可能都不一样,配置时从请求属性的请求头hd、参数pm、来源org中选择任一个配置,然后依据该请求属性获取网络请求对应该请求属性的属性值,判断属性值是否满足该负载策略的预设条件,将每一个负载策略依次按照上述方法判断,直至找到满足预设条件的目标负载策略。In this embodiment, the above-mentioned load policy includes policy name, keyword key, request attribute type (any of request header hd, parameter pm, source org), preset condition (cn condition), routing array, policy type (whether Global st(0\1), global is public, non-global is private), etc. The request attributes and preset conditions of each load strategy configuration may be different. When configuring, start with the request header hd and parameters of the request attributes Choose any configuration from pm and source org, and then obtain the attribute value of the requested attribute corresponding to the network request according to the request attribute, determine whether the attribute value meets the preset conditions of the load strategy, and judge each load strategy in turn according to the above method. Until the target load strategy that meets the preset conditions is found.
举例地,第一个负载策略的请求属性配置的为参数pm,在匹配的时候,获取网络请求的参数pm值(即属性值),将该参数pm值按照预设条件中的预设算式计算,以此查看该参数pm值是否满足预设条件,例如,预设条件是若参数pm值对1000求余等于0,则网络请求满足该预设条件,这时第一个负载策略即默认为目标负载策略;若参数pm值对1000求余不等于0,即不满足预设条件,则需要将策略集中的第二个负载策略再次进行判断,第二个负载策略的请求属性配置的为请求头hd,则这时获取网络请求的请求头的hd值(属性值),第二个负载策略的预设条件是若hd值对10求余等于0,则网络请求满足预设条件,这时第二个负载策略即默认为目标负载策略,否则继续判断第三个负载策略,直至找到目标负载策略。For example, the request attribute of the first load strategy is configured as the parameter pm. When matching, the parameter pm value (that is, the attribute value) of the network request is obtained, and the parameter pm value is calculated according to the preset calculation in the preset conditions To check whether the parameter pm value meets the preset condition. For example, if the parameter pm value is equal to 0 for 1000, the network request satisfies the preset condition. At this time, the first load strategy defaults to Target load strategy; if the value of the parameter pm is not equal to 0 for 1000, that is, the preset condition is not met, the second load strategy in the strategy set needs to be judged again, and the request attribute of the second load strategy is configured as request Head hd, then get the hd value (attribute value) of the request header of the network request. The preset condition of the second load strategy is that if the hd value is equal to 0 after the remainder of 10, the network request meets the preset condition. The second load strategy is the target load strategy by default, otherwise continue to judge the third load strategy until the target load strategy is found.
在一个实施例中,上述得到地址单元500,包括:In an embodiment, obtaining the address unit 500 above includes:
获取号码子单元,用于获取所述用户的手机号码以及所述目标系统的系统ID;The number obtaining subunit is used to obtain the mobile phone number of the user and the system ID of the target system;
运算数值子单元,用于将所述手机号码以及系统ID通过hash函数运算得到第一数值;An arithmetic value subunit for calculating the mobile phone number and system ID through a hash function to obtain the first value;
获取数量子单元,用于获取所述路由数组中所有服务地址的数量;The quantity obtaining subunit is used to obtain the quantity of all service addresses in the routing array;
计算地址子单元,用于将所述第一数值以及所述数量通过预设算式计算得到所述目标服务地址。The address calculation subunit is configured to calculate the first value and the number through a preset calculation formula to obtain the target service address.
本实施例中,已知目标负载策略中还包括路由数组,从路由数组中选择出目标服务地址的过程可如下:先获取用户的手机号码,以及目标系统的系统ID,由于网络请求中包括有用户信息以及目标系统信息,则可依据网络请求获得对应的系统ID,以及依据网络请求查找对应的用户以获取其手机号码。然后将 手机号码以及系统ID通过hash函数运算得到第一数值,上述hash函数即是散列函数,又称“哈希”函数。本实施例中,该hash函数的表达式为n=hash(phone+id),将手机号码以及系统ID拼接通过hash函数运算得到0~31间的第一数值n,然后获取目标负载策略的路由数组中所有服务地址的数量。In this embodiment, it is known that the target load strategy also includes a routing array. The process of selecting the target service address from the routing array can be as follows: first obtain the user’s mobile phone number and the system ID of the target system, since the network request includes For user information and target system information, the corresponding system ID can be obtained according to the network request, and the corresponding user can be found according to the network request to obtain the mobile phone number. Then, the mobile phone number and the system ID are calculated through a hash function to obtain the first value. The above hash function is a hash function, also known as a "hash" function. In this embodiment, the expression of the hash function is n=hash(phone+id), the mobile phone number and the system ID are spliced through the hash function operation to obtain the first value n between 0 and 31, and then the route of the target load strategy is obtained The number of all service addresses in the array.
上述计算地址子单元中,预设算式可以为:add=g[n%l],其中,add为所述目标服务地址,n为所述第一数值,l为所述路由数组中服务地址的数量,g为所述路由数组,g[n%l]为取所述路由数组中第n%l个服务地址,具体而言,首先求得第一数值除以数量的余数m,即m=n%l,而g[m]则为路由数组中第m个服务地址,例如,当求得m为5时,即上述目标服务地址为路由数组中的第五个服务地址。In the above calculation address subunit, the preset calculation formula may be: add=g[n%l], where add is the target service address, n is the first value, and l is the value of the service address in the routing array Number, g is the routing array, g[n%l] is the n%l service address in the routing array. Specifically, first obtain the remainder m of the first value divided by the number, that is, m= n%l, and g[m] is the m-th service address in the routing array. For example, when m is found to be 5, the above-mentioned target service address is the fifth service address in the routing array.
在一个实施例中,上述得到地址单元500,包括:In an embodiment, obtaining the address unit 500 above includes:
选择地址子单元,用于通过随机算法从所述目标负载策略的路由数组中选择出所述目标服务地址。The address selection subunit is used to select the target service address from the routing array of the target load strategy through a random algorithm.
参照图3,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图3所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储流量负载过程所需的所有数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种流量均衡负载方法。3, an embodiment of the present application also provides a computer device. The computer device may be a server, and its internal structure may be as shown in FIG. 3. The computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer readable instructions, and a database. The memory provides an environment for the operation of the operating system and computer readable instructions in the non-volatile storage medium. The database of the computer equipment is used to store all the data required for the flow load process. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer-readable instruction is executed by the processor to realize a method of traffic balancing load.
上述处理器执行上述流量均衡负载方法的步骤:获取用户通过目标系统发起的网络请求;依据所述网络请求生成调用指令;依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;从所述目标负载策略中得到与所述网络请求对应的目标服务地址;将所述网络请求转发到所述目标服务地址对应的服务器。The above-mentioned processor executes the steps of the above-mentioned traffic balancing load method: acquiring a network request initiated by a user through a target system; generating a calling instruction according to the network request; calling a preset policy set according to the calling instruction, and the policy set includes a plurality of Load strategy; a plurality of load strategies in the strategy group are matched with the network request according to a preset matching rule to find the target load strategy corresponding to the network request; and the target load strategy is obtained from the target load strategy. The target service address corresponding to the network request; forwarding the network request to the server corresponding to the target service address.
上述计算机设备,上述依据所述调用指令调用预设的策略集的步骤,包括:依据所述调用指令将预设数据库中的所述策略集加载至本地内存,以调用所述策略集。In the above computer device, the step of invoking a preset strategy set according to the invoking instruction includes: loading the strategy set in the preset database to a local memory according to the invoking instruction to invoke the strategy set.
在一个实施例中,上述策略集中包括对应指定业务系统的私有负载策略以及对应所有业务系统的公有负载策略,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:将所述私有负载策略与所述网络请求进行匹配;若匹配不到所述目标负载策略,则将所述公有负载策略与所述网络请求进行匹配,以找到所述目标负载策略。In one embodiment, the above-mentioned strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems, and the plurality of load strategies in the strategy set are matched one by one with the network request according to a preset The step of matching rules to find the target load strategy corresponding to the network request includes: matching the private load strategy with the network request; if the target load strategy cannot be matched, then the public load The strategy is matched with the network request to find the target load strategy.
在一个实施例中,上述负载策略包括请求属性以及预设条件,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:依据每个所述负载策略的请求属性从所述网络请求中获取对应所述负载策略的属性值;依次判断所述属性值是否满足对应的所述负载策略的预设条件,直到找到所述属性值满足所述预设条件的所述目标负载策略。In one embodiment, the aforementioned load strategy includes request attributes and preset conditions, and the multiple load strategies in the strategy set are matched one by one with the network request according to a preset matching rule to find the corresponding network request The step of the target load strategy includes: obtaining the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy; sequentially determining whether the attribute value meets the corresponding load strategy The preset condition is reached until the target load strategy whose attribute value meets the preset condition is found.
在一个实施例中,上述目标负载策略中还包括有路由数组,所述路由数组中包括多个服务地址,所述从所述目标负载策略中得到与所述网络请求对应的目标服务地址的步骤,包括:获取所述用户的手机号码以及所述目标系统的系统ID;将所述手机号码以及系统ID通过hash函数运算得到第一数值;获取所述路由数组中所有服务地址的数量;将所述第一数值以及所述数量通过预设算式计算得到所述目标服务地址。In an embodiment, the above-mentioned target load strategy further includes a routing array, the routing array includes a plurality of service addresses, and the step of obtaining a target service address corresponding to the network request from the target load strategy , Including: obtaining the mobile phone number of the user and the system ID of the target system; calculating the mobile phone number and the system ID through a hash function to obtain the first value; obtaining the number of all service addresses in the routing array; The first value and the number are calculated by a preset formula to obtain the target service address.
在一个实施例中,上述将所述第一数值以及上述数量通过预设算式计算得到所述目标服务地址的步骤,包括:利用以下预设算式计算得到所述目标服务地址:add=g[n%l],其中,add为所述目标服务地址,n为所述第一数值,l为所述路由数组中服务地址的数量,g为所述路由数组,g[n%l]为取所述路由数组中第n%l个服务地址。In one embodiment, the step of calculating the first value and the number to obtain the target service address through a preset formula includes: calculating the target service address using the following preset formula: add=g[n %L], where add is the target service address, n is the first value, l is the number of service addresses in the routing array, g is the routing array, and g[n%l] is the value The n%lth service address in the routing array.
在一个实施例中,上述从所述目标负载策略中得到与所述网络请求对应的目标服务地址的步骤,包括:通过随机算法从所述目标负载策略的路由数组中选择出所述目标服务地址。In an embodiment, the above step of obtaining the target service address corresponding to the network request from the target load strategy includes: selecting the target service address from the routing array of the target load strategy through a random algorithm .
本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。Those skilled in the art can understand that the structure shown in FIG. 3 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
本申请一实施例还提供一种计算机可读存储介质,所述计算机可读存储介质,例如为非易失性的计算机可读存储介质,或者为易失性的计算机可读存储介质,其上存储有计算机可读指令,计算机可读指令被处理器执行时实现一种 流量均衡负载方法,具体为:获取用户通过目标系统发起的网络请求;依据所述网络请求生成调用指令;依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;从所述目标负载策略中得到与所述网络请求对应的目标服务地址;将所述网络请求转发到所述目标服务地址对应的服务器。An embodiment of the present application further provides a computer-readable storage medium. The computer-readable storage medium is, for example, a non-volatile computer-readable storage medium or a volatile computer-readable storage medium on which Stored with computer-readable instructions, when the computer-readable instructions are executed by the processor, a method for traffic balancing load is realized, specifically: obtaining a network request initiated by a user through the target system; generating a call instruction according to the network request; The instruction calls a preset strategy set, the strategy set includes a plurality of load strategies; the plurality of load strategies in the strategy set are matched with the network request according to the preset matching rule to find the corresponding network request Target load strategy; obtain the target service address corresponding to the network request from the target load strategy; forward the network request to the server corresponding to the target service address.
上述计算机可读存储介质,上述依据所述调用指令调用预设的策略集的步骤,包括:依据所述调用指令将预设数据库中的所述策略集加载至本地内存,以调用所述策略集。In the computer-readable storage medium, the step of invoking a preset strategy set according to the invoking instruction includes: loading the strategy set in a preset database to a local memory according to the invoking instruction to invoke the strategy set .
在一个实施例中,上述策略集中包括对应指定业务系统的私有负载策略以及对应所有业务系统的公有负载策略,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:将所述私有负载策略与所述网络请求进行匹配;若匹配不到所述目标负载策略,则将所述公有负载策略与所述网络请求进行匹配,以找到所述目标负载策略。In one embodiment, the above-mentioned strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems, and the plurality of load strategies in the strategy set are matched one by one with the network request according to a preset The step of matching rules to find the target load strategy corresponding to the network request includes: matching the private load strategy with the network request; if the target load strategy cannot be matched, then the public load The strategy is matched with the network request to find the target load strategy.
在一个实施例中,上述负载策略包括请求属性以及预设条件,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:依据每个所述负载策略的请求属性从所述网络请求中获取对应所述负载策略的属性值;依次判断所述属性值是否满足对应的所述负载策略的预设条件,直到找到所述属性值满足所述预设条件的所述目标负载策略。In one embodiment, the aforementioned load strategy includes request attributes and preset conditions, and the multiple load strategies in the strategy set are matched one by one with the network request according to a preset matching rule to find the corresponding network request The step of the target load strategy includes: obtaining the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy; sequentially determining whether the attribute value meets the corresponding load strategy The preset condition is reached until the target load strategy whose attribute value meets the preset condition is found.
在一个实施例中,上述目标负载策略中还包括有路由数组,所述路由数组中包括多个服务地址,所述从所述目标负载策略中得到与所述网络请求对应的目标服务地址的步骤,包括:获取所述用户的手机号码以及所述目标系统的系统ID;将所述手机号码以及系统ID通过hash函数运算得到第一数值;获取所述路由数组中所有服务地址的数量;将所述第一数值以及所述数量通过预设算式计算得到所述目标服务地址。In an embodiment, the above-mentioned target load strategy further includes a routing array, the routing array includes a plurality of service addresses, and the step of obtaining a target service address corresponding to the network request from the target load strategy , Including: obtaining the mobile phone number of the user and the system ID of the target system; calculating the mobile phone number and the system ID through a hash function to obtain the first value; obtaining the number of all service addresses in the routing array; The first value and the number are calculated by a preset formula to obtain the target service address.
在一个实施例中,上述将所述第一数值以及上述数量通过预设算式计算得到所述目标服务地址的步骤,包括:利用以下预设算式计算得到所述目标服务地址:add=g[n%l],其中,add为所述目标服务地址,n为所述第一数值,l为所述路由数组中服务地址的数量,g为所述路由数组,g[n%l]为取所述路由 数组中第n%l个服务地址。In one embodiment, the step of calculating the first value and the number to obtain the target service address through a preset formula includes: calculating the target service address using the following preset formula: add=g[n %L], where add is the target service address, n is the first value, l is the number of service addresses in the routing array, g is the routing array, and g[n%l] is the value The n%lth service address in the routing array.
在一个实施例中,上述从所述目标负载策略中得到与所述网络请求对应的目标服务地址的步骤,包括:通过随机算法从所述目标负载策略的路由数组中选择出所述目标服务地址。In an embodiment, the above step of obtaining the target service address corresponding to the network request from the target load strategy includes: selecting the target service address from the routing array of the target load strategy through a random algorithm .
以上所述仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only the preferred embodiments of this application, and do not limit the scope of this application. Any equivalent structure or equivalent process transformation made using the content of this application description and drawings, or directly or indirectly applied to other related The technical field is equally included in the scope of patent protection of this application.

Claims (20)

  1. 一种流量均衡负载方法,其特征在于,包括:A load balancing method for traffic, characterized in that it comprises:
    获取用户通过目标系统发起的网络请求;Get the network request initiated by the user through the target system;
    依据所述网络请求生成调用指令;Generating a call instruction according to the network request;
    依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;Calling a preset strategy set according to the calling instruction, the strategy set including a plurality of load strategies;
    将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;Matching a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
    从所述目标负载策略中得到与所述网络请求对应的目标服务地址;Obtaining the target service address corresponding to the network request from the target load strategy;
    将所述网络请求转发到所述目标服务地址对应的服务器。Forward the network request to the server corresponding to the target service address.
  2. 根据权利要求1所述的流量均衡负载方法,其特征在于,所述依据所述调用指令调用预设的策略集的步骤,包括:The traffic balancing load method according to claim 1, wherein the step of invoking a preset policy set according to the invoking instruction comprises:
    依据所述调用指令将预设数据库中的所述策略集加载至本地内存,以调用所述策略集。The strategy set in the preset database is loaded into the local memory according to the calling instruction to invoke the strategy set.
  3. 根据权利要求1所述的流量均衡负载方法,其特征在于,所述策略集中包括对应指定业务系统的私有负载策略以及对应所有业务系统的公有负载策略,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:The traffic balancing load method according to claim 1, wherein the strategy set includes a private load strategy corresponding to a designated business system and a public load strategy corresponding to all business systems, and the strategy is grouped into multiple load strategies The step of matching the network request according to the preset matching rule to find the target load strategy corresponding to the network request includes:
    将所述私有负载策略与所述网络请求进行匹配;Matching the private load policy with the network request;
    若匹配不到所述目标负载策略,则将所述公有负载策略与所述网络请求进行匹配,以找到所述目标负载策略。If the target load strategy cannot be matched, the public load strategy is matched with the network request to find the target load strategy.
  4. 根据权利要求1所述的流量均衡负载方法,其特征在于,所述负载策略包括请求属性以及预设条件,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:The method for traffic balancing load according to claim 1, wherein the load strategy includes request attributes and preset conditions, and the plurality of load strategies in the strategy group are matched with the network request according to the preset conditions. The step of matching the rules to find the target load strategy corresponding to the network request includes:
    依据每个所述负载策略的请求属性从所述网络请求中获取对应所述负载策略的属性值;Obtaining the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy;
    依次判断所述属性值是否满足对应的所述负载策略的预设条件,直到找到所述属性值满足所述预设条件的所述目标负载策略。It is determined in turn whether the attribute value meets the corresponding preset condition of the load strategy, until the target load strategy with the attribute value meeting the preset condition is found.
  5. 根据权利要求1所述的流量均衡负载方法,其特征在于,所述目标负载策略中还包括有路由数组,所述路由数组中包括多个服务地址,所述从所述 目标负载策略中得到与所述网络请求对应的目标服务地址的步骤,包括:The method of traffic balancing load according to claim 1, wherein the target load strategy further includes a routing array, the routing array includes a plurality of service addresses, and the data obtained from the target load strategy and The step of the network requesting the corresponding target service address includes:
    获取所述用户的手机号码以及所述目标系统的系统ID;Acquiring the mobile phone number of the user and the system ID of the target system;
    将所述手机号码以及系统ID通过hash函数运算得到第一数值;Calculating the mobile phone number and the system ID through a hash function to obtain the first value;
    获取所述路由数组中所有服务地址的数量;Obtaining the number of all service addresses in the routing array;
    将所述第一数值以及所述数量通过预设算式计算得到所述目标服务地址。The target service address is obtained by calculating the first value and the number through a preset calculation formula.
  6. 根据权利要求5所述的流量均衡负载方法,其特征在于,所述将所述第一数值以及所述数量通过预设算式计算得到所述目标服务地址的步骤,包括:The method of traffic balancing load according to claim 5, wherein the step of calculating the first value and the number to obtain the target service address through a preset calculation formula comprises:
    利用以下预设算式计算得到所述目标服务地址:The target service address is calculated using the following preset formula:
    add=g[n%l]add=g[n%l]
    其中,add为所述目标服务地址,n为所述第一数值,l为所述路由数组中服务地址的数量,g为所述路由数组,g[n%l]为取所述路由数组中第n%l个服务地址。Where add is the target service address, n is the first value, l is the number of service addresses in the routing array, g is the routing array, and g[n%l] is the number of The n%l service address.
  7. 根据权利要求1所述的流量均衡负载方法,其特征在于,所述从所述目标负载策略中得到与所述网络请求对应的目标服务地址的步骤,包括:The traffic balancing load method according to claim 1, wherein the step of obtaining a target service address corresponding to the network request from the target load strategy comprises:
    通过随机算法从所述目标负载策略的路由数组中选择出所述目标服务地址。The target service address is selected from the routing array of the target load strategy through a random algorithm.
  8. 一种流量均衡负载装置,其特征在于,包括:A flow balancing load device, characterized in that it comprises:
    获取请求单元,用于获取用户通过目标系统发起的网络请求Obtaining request unit for obtaining network requests initiated by users through the target system
    生成调用单元,用于依据所述网络请求生成调用指令;Generating and calling unit for generating a calling instruction according to the network request;
    调用策略单元,用于依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;The invoking strategy unit is configured to invoke a preset strategy set according to the invoking instruction, and the strategy set includes multiple load strategies;
    匹配策略单元,用于将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;A matching strategy unit, configured to match a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
    得到地址单元,用于从所述目标负载策略中得到与所述网络请求对应的目标服务地址;An obtaining address unit, configured to obtain a target service address corresponding to the network request from the target load strategy;
    转发请求单元,用于将所述网络请求转发到所述目标服务地址对应的服务器。The forwarding request unit is configured to forward the network request to the server corresponding to the target service address.
  9. 根据权利要求8所述的流量均衡负载装置,其特征在于,所述调用策略单元,包括:The traffic balancing load device according to claim 8, wherein the invoking policy unit comprises:
    加载策略子单元,用于依据所述调用指令将预设数据库中的所述策略集加载至本地内存,以调用所述策略集。The loading strategy subunit is configured to load the strategy set in the preset database to the local memory according to the calling instruction to invoke the strategy set.
  10. 根据权利要求8所述的流量均衡负载装置,其特征在于,所述匹配策略单元,包括:The traffic balancing load device according to claim 8, wherein the matching strategy unit comprises:
    第一匹配子单元,用于将所述私有负载策略与所述网络请求进行匹配;The first matching subunit is used to match the private load policy with the network request;
    第二匹配子单元,用于匹配不到所述目标负载策略时,将所述公有负载策略与所述网络请求进行匹配,以找到所述目标负载策略。The second matching subunit is configured to match the public load strategy with the network request when the target load strategy cannot be matched to find the target load strategy.
  11. 根据权利要求8所述的流量均衡负载装置,其特征在于,所述匹配策略单元:The traffic balancing load device according to claim 8, wherein the matching strategy unit:
    获取属性子单元,用于依据每个所述负载策略的请求属性从所述网络请求中获取对应所述负载策略的属性值;The acquiring attribute subunit is configured to acquire the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy;
    判断条件子单元,用于依次判断所述属性值是否满足对应的所述负载策略的预设条件,直到找到所述属性值满足所述预设条件的所述目标负载策略。The judgment condition subunit is used to sequentially judge whether the attribute value meets the corresponding preset condition of the load strategy, until the target load strategy whose attribute value meets the preset condition is found.
  12. 根据权利要求8所述的流量均衡负载装置,其特征在于,所述得到地址单元,包括:The traffic balancing load device according to claim 8, wherein the obtaining address unit comprises:
    获取号码子单元,用于获取所述用户的手机号码以及所述目标系统的系统ID;The number obtaining subunit is used to obtain the mobile phone number of the user and the system ID of the target system;
    运算数值子单元,用于将所述手机号码以及系统ID通过hash函数运算得到第一数值;An arithmetic value subunit for calculating the mobile phone number and system ID through a hash function to obtain the first value;
    获取数量子单元,用于获取所述路由数组中所有服务地址的数量;The quantity obtaining subunit is used to obtain the quantity of all service addresses in the routing array;
    计算地址子单元,用于将所述第一数值以及所述数量通过预设算式计算得到所述目标服务地址。The address calculation subunit is configured to calculate the first value and the number through a preset calculation formula to obtain the target service address.
  13. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现流量均衡负载方法,该流量均衡负载方法包括:A computer device includes a memory and a processor, the memory stores computer-readable instructions, and is characterized in that when the processor executes the computer-readable instructions, a traffic balancing load method is implemented, and the traffic balancing load method includes:
    获取用户通过目标系统发起的网络请求;Get the network request initiated by the user through the target system;
    依据所述网络请求生成调用指令;Generating a call instruction according to the network request;
    依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;Calling a preset strategy set according to the calling instruction, the strategy set including a plurality of load strategies;
    将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;Matching a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
    从所述目标负载策略中得到与所述网络请求对应的目标服务地址;Obtaining the target service address corresponding to the network request from the target load strategy;
    将所述网络请求转发到所述目标服务地址对应的服务器。Forward the network request to the server corresponding to the target service address.
  14. 根据权利要求13所述的计算机设备,其特征在于,所述依据所述调 用指令调用预设的策略集的步骤,包括:The computer device according to claim 13, wherein the step of invoking a preset strategy set according to the calling instruction comprises:
    依据所述调用指令将预设数据库中的所述策略集加载至本地内存,以调用所述策略集。The strategy set in the preset database is loaded into the local memory according to the calling instruction to invoke the strategy set.
  15. 根据权利要求13所述的计算机设备,其特征在于,所述策略集中包括对应指定业务系统的私有负载策略以及对应所有业务系统的公有负载策略,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:The computer device according to claim 13, wherein the strategy set includes a private load strategy corresponding to a specified business system and a public load strategy corresponding to all business systems, and the strategy is set to a plurality of load strategies one by one. The step of matching the network request according to a preset matching rule to find the target load strategy corresponding to the network request includes:
    将所述私有负载策略与所述网络请求进行匹配;Matching the private load policy with the network request;
    若匹配不到所述目标负载策略,则将所述公有负载策略与所述网络请求进行匹配,以找到所述目标负载策略。If the target load strategy cannot be matched, the public load strategy is matched with the network request to find the target load strategy.
  16. 根据权利要求13所述的计算机设备,其特征在于,所述负载策略包括请求属性以及预设条件,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:The computer device according to claim 13, wherein the load strategy includes request attributes and preset conditions, and the grouping of multiple load strategies one by one in the strategy is performed according to a preset matching rule with the network request The step of matching to find the target load strategy corresponding to the network request includes:
    依据每个所述负载策略的请求属性从所述网络请求中获取对应所述负载策略的属性值;Obtaining the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy;
    依次判断所述属性值是否满足对应的所述负载策略的预设条件,直到找到所述属性值满足所述预设条件的所述目标负载策略。It is determined in turn whether the attribute value meets the corresponding preset condition of the load strategy, until the target load strategy with the attribute value meeting the preset condition is found.
  17. 一种计算机可读存储介质,其上存储有计算机可读指令,其特征在于,所述计算机可读指令被处理器执行时实现流量均衡负载方法,该流量均衡负载方法包括:A computer-readable storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions are executed by a processor to implement a flow balancing load method, and the flow balancing load method includes:
    获取用户通过目标系统发起的网络请求;Get the network request initiated by the user through the target system;
    依据所述网络请求生成调用指令;Generating a call instruction according to the network request;
    依据所述调用指令调用预设的策略集,所述策略集包括多个负载策略;Calling a preset strategy set according to the calling instruction, the strategy set including a plurality of load strategies;
    将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略;Matching a plurality of load strategies in the strategy set one by one with the network request according to a preset matching rule to find a target load strategy corresponding to the network request;
    从所述目标负载策略中得到与所述网络请求对应的目标服务地址;Obtaining the target service address corresponding to the network request from the target load strategy;
    将所述网络请求转发到所述目标服务地址对应的服务器。Forward the network request to the server corresponding to the target service address.
  18. 根据权利要求17所述的计算机可读存储介质,其特征在于,所述依据所述调用指令调用预设的策略集的步骤,包括:18. The computer-readable storage medium of claim 17, wherein the step of invoking a preset strategy set according to the invoking instruction comprises:
    依据所述调用指令将预设数据库中的所述策略集加载至本地内存,以调用 所述策略集。The strategy set in the preset database is loaded into the local memory according to the calling instruction to invoke the strategy set.
  19. 根据权利要求17所述的计算机可读存储介质,其特征在于,所述策略集中包括对应指定业务系统的私有负载策略以及对应所有业务系统的公有负载策略,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:The computer-readable storage medium according to claim 17, wherein the strategy set includes a private load strategy corresponding to a specified business system and a public load strategy corresponding to all business systems, and the strategy is centralized to multiple loads The step of matching the strategy one by one with the network request according to a preset matching rule to find the target load strategy corresponding to the network request includes:
    将所述私有负载策略与所述网络请求进行匹配;Matching the private load policy with the network request;
    若匹配不到所述目标负载策略,则将所述公有负载策略与所述网络请求进行匹配,以找到所述目标负载策略。If the target load strategy cannot be matched, the public load strategy is matched with the network request to find the target load strategy.
  20. 根据权利要求17所述的计算机可读存储介质,其特征在于,所述负载策略包括请求属性以及预设条件,所述将所述策略集中多个负载策略一一与所述网络请求按照预设匹配规则进行匹配,以找到对应所述网络请求的目标负载策略的步骤,包括:The computer-readable storage medium according to claim 17, wherein the load strategy includes request attributes and preset conditions, and the plurality of load strategies are combined with the network request according to a preset condition. The step of matching the matching rules to find the target load strategy corresponding to the network request includes:
    依据每个所述负载策略的请求属性从所述网络请求中获取对应所述负载策略的属性值;Obtaining the attribute value corresponding to the load strategy from the network request according to the request attribute of each load strategy;
    依次判断所述属性值是否满足对应的所述负载策略的预设条件,直到找到所述属性值满足所述预设条件的所述目标负载策略。It is determined in turn whether the attribute value meets the corresponding preset condition of the load strategy, until the target load strategy with the attribute value meeting the preset condition is found.
PCT/CN2019/118386 2019-04-19 2019-11-14 Flow load balancing method and apparatus, computer device and storage medium WO2020211365A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910319068.9A CN110011928B (en) 2019-04-19 2019-04-19 Flow balancing load method and device, computer equipment and storage medium
CN201910319068.9 2019-04-19

Publications (1)

Publication Number Publication Date
WO2020211365A1 true WO2020211365A1 (en) 2020-10-22

Family

ID=67173167

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/118386 WO2020211365A1 (en) 2019-04-19 2019-11-14 Flow load balancing method and apparatus, computer device and storage medium

Country Status (2)

Country Link
CN (1) CN110011928B (en)
WO (1) WO2020211365A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113452800A (en) * 2021-08-31 2021-09-28 深圳市信润富联数字科技有限公司 Method for realizing load balance based on multiple Broker in MQTT protocol
CN114978951A (en) * 2022-06-07 2022-08-30 武汉大学 Cloud platform load balancing method
CN115037803A (en) * 2022-06-09 2022-09-09 云南电网有限责任公司信息中心 Service calling method, electronic equipment and storage medium

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110011928B (en) * 2019-04-19 2022-08-19 平安科技(深圳)有限公司 Flow balancing load method and device, computer equipment and storage medium
CN110740164B (en) * 2019-09-04 2021-01-08 华云数据控股集团有限公司 Server determination method, regulation and control method, device, equipment and storage medium
CN110944067B (en) * 2019-12-27 2021-07-16 华为技术有限公司 Load balancing method and server
CN114143269A (en) * 2021-11-12 2022-03-04 上海途虎信息技术有限公司 HTTP request distribution method, device, equipment and medium
CN114466019B (en) * 2022-04-11 2022-09-16 阿里巴巴(中国)有限公司 Distributed computing system, load balancing method, device and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060143283A1 (en) * 2004-12-23 2006-06-29 Douglas Makofka Method and apparatus for providing decentralized load distribution
US7512702B1 (en) * 2002-03-19 2009-03-31 Cisco Technology, Inc. Method and apparatus providing highly scalable server load balancing
CN104852934A (en) * 2014-02-13 2015-08-19 阿里巴巴集团控股有限公司 Method for realizing flow distribution based on front-end scheduling, device and system thereof
CN105376334A (en) * 2015-12-14 2016-03-02 曙光信息产业(北京)有限公司 Load balancing method and device
CN110011928A (en) * 2019-04-19 2019-07-12 平安科技(深圳)有限公司 Flow equalization carrying method, device, computer equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9602380B2 (en) * 2014-03-28 2017-03-21 Futurewei Technologies, Inc. Context-aware dynamic policy selection for load balancing behavior
CN104468823B (en) * 2014-12-24 2018-02-06 浪潮(北京)电子信息产业有限公司 A kind of cluster load balance dispatching method and system
CN108123888A (en) * 2016-11-29 2018-06-05 中兴通讯股份有限公司 Load-balancing method, the apparatus and system of message
CN108965381B (en) * 2018-05-31 2023-03-21 康键信息技术(深圳)有限公司 Nginx-based load balancing implementation method and device, computer equipment and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7512702B1 (en) * 2002-03-19 2009-03-31 Cisco Technology, Inc. Method and apparatus providing highly scalable server load balancing
US20060143283A1 (en) * 2004-12-23 2006-06-29 Douglas Makofka Method and apparatus for providing decentralized load distribution
CN104852934A (en) * 2014-02-13 2015-08-19 阿里巴巴集团控股有限公司 Method for realizing flow distribution based on front-end scheduling, device and system thereof
CN105376334A (en) * 2015-12-14 2016-03-02 曙光信息产业(北京)有限公司 Load balancing method and device
CN110011928A (en) * 2019-04-19 2019-07-12 平安科技(深圳)有限公司 Flow equalization carrying method, device, computer equipment and storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113452800A (en) * 2021-08-31 2021-09-28 深圳市信润富联数字科技有限公司 Method for realizing load balance based on multiple Broker in MQTT protocol
CN114978951A (en) * 2022-06-07 2022-08-30 武汉大学 Cloud platform load balancing method
CN114978951B (en) * 2022-06-07 2023-08-18 武汉大学 Cloud platform load balancing method
CN115037803A (en) * 2022-06-09 2022-09-09 云南电网有限责任公司信息中心 Service calling method, electronic equipment and storage medium
CN115037803B (en) * 2022-06-09 2024-03-22 云南电网有限责任公司信息中心 Service calling method, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN110011928A (en) 2019-07-12
CN110011928B (en) 2022-08-19

Similar Documents

Publication Publication Date Title
WO2020211365A1 (en) Flow load balancing method and apparatus, computer device and storage medium
CN108829459B (en) Nginx server-based configuration method and device, computer equipment and storage medium
US8713186B2 (en) Server-side connection resource pooling
US20150213134A1 (en) Data query method and system and storage medium
US8914502B2 (en) System and method for dynamic discovery of origin servers in a traffic director environment
US20100169442A1 (en) Apparatus and method for providing peer-to-peer proxy service with temporary storage management and traffic load balancing in peer-to-peer communications
CN111240763A (en) Configuration updating method, device, equipment and storage medium
US20060123121A1 (en) System and method for service session management
US10171612B2 (en) Caching service with client-enabled routing
WO2019237594A1 (en) Session persistence method and apparatus, and computer device and storage medium
WO2019210580A1 (en) Access request processing method, apparatus, computer device, and storage medium
JP2014534537A (en) System and method for managing a dedicated cache
WO2021042784A1 (en) Domain name management system employing blockchain
WO2022111313A1 (en) Request processing method and micro-service system
JP2015503158A (en) Role instance reachability in the data center
US10700925B2 (en) Dedicated endpoints for network-accessible services
US20220318071A1 (en) Load balancing method and related device
US9760370B2 (en) Load balancing using predictable state partitioning
WO2021017907A1 (en) Method and device for optimized inter-microservice communication
WO2019034091A1 (en) Distribution method for distributed data computing, device, server and storage medium
CN111314114A (en) Deployment method and system for improving high availability of RabbitMQ
US7876748B1 (en) Stable hash-based mapping computation for a dynamically varying target set
US20190373053A1 (en) Ranked session affinity to improve load balancing efficiency for stateful requests
CN114650221A (en) Method and system for quickly calling service interface
US20080140687A1 (en) Socket structure simultaneously supporting both toe and ethernet network interface card and method of forming the socket structure

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19925380

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19925380

Country of ref document: EP

Kind code of ref document: A1