Traffic scheduling method, device and equipment and computer readable storage medium
By dynamically adjusting service traffic within the RPC framework, the problem of fixed load balancing strategies in existing technologies is solved, enabling flexible allocation in the event of data center anomalies and improving service availability and responsiveness.
Patent Information
- Application Number
- CN202411012375.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2044-07-26
AI Technical Summary
In existing RPC frameworks, service traffic load balancing strategies are relatively fixed, which cannot respond promptly to special situations that occur in instances or data centers, affecting the normal provision and use of services and lacking flexibility.
A traffic allocation method is provided, which dynamically adjusts service traffic to the main data center and backup data center by obtaining the traffic allocation policy and available instance list of the target service. This includes switching or allocating traffic to the backup data center when an anomaly occurs in the main data center, and flexibly allocating traffic using factors such as traffic weight and response success rate.
It improves service availability and flexibility, reduces downtime, and ensures that services can continue to operate normally even in abnormal situations.
Smart Images

Figure CN118784652B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of microservices technology, and in particular to a traffic allocation method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] Remote Procedure Call (RPC) is a communication protocol that allows a program on a remote computer to request services over a network without needing to understand the underlying network details. RPC simplifies the development of distributed systems and is widely used in microservice architectures.
[0003] During the service request process, in order to ensure service quality, it is usually necessary to load balance the service traffic to prevent a single instance or data center from bearing too much service traffic. Existing RPC frameworks provide load balancing strategies such as round-robin, random, and least connections.
[0004] However, existing service traffic load balancing strategies are relatively fixed and cannot respond in a timely manner when special circumstances occur in the service instances or data centers, affecting the normal provision and use of services. Therefore, existing traffic allocation methods lack a certain degree of flexibility. Summary of the Invention
[0005] To address the aforementioned technical problems, this disclosure provides a flow allocation method, apparatus, device, and computer-readable storage medium to improve the flexibility of the flow allocation method.
[0006] In a first aspect, embodiments of this disclosure provide a traffic allocation method, including:
[0007] Obtain the traffic allocation strategy and available instance list corresponding to the target service. The traffic allocation strategy includes information on at least one main data center and at least one backup data center corresponding to the target service. The available instance list includes data center information corresponding to each available instance.
[0008] According to the traffic allocation strategy, a target instance is selected from the list of available instances for invocation, so that the target instance provides the target service, and the target instance is located in the data center;
[0009] When any of the main data centers experiences an abnormal situation, the service traffic in the main data center is allocated to one or more backup data centers according to the traffic allocation policy.
[0010] In some embodiments, when any of the main data centers experiences an abnormal situation, allocating service traffic from the main data center to one or more backup data centers according to the traffic allocation policy includes:
[0011] switching service traffic in the primary hosting room to at least one backup hosting room when the primary hosting room is unable to respond to the service traffic.
[0012] In some embodiments, the switching service traffic in the primary hosting room to one or more backup hosting rooms according to the traffic allocation strategy when any of the primary hosting rooms has an abnormal condition comprises:
[0013] setting at least one backup hosting room as a new primary hosting room if new traffic of the primary hosting room exceeds a preset threshold within a preset time period;
[0014] allocating a first preset proportion of the new traffic to the new primary hosting room.
[0015] In some embodiments, the traffic allocation strategy further comprises a traffic weight corresponding to each backup hosting room, and the allocating a first preset proportion of the new traffic to the new primary hosting room comprises:
[0016] determining a traffic weight corresponding to each new primary hosting room according to a traffic weight corresponding to each backup hosting room;
[0017] allocating the first preset proportion of the new traffic to the new primary hosting room according to a traffic weight corresponding to each new primary hosting room.
[0018] In some embodiments, the switching service traffic in the primary hosting room to one or more backup hosting rooms according to the traffic allocation strategy when any of the primary hosting rooms has an abnormal condition comprises:
[0019] allocating service traffic in the primary hosting room to at least one backup hosting room when a response success rate of the target service in the primary hosting room is lower than a preset success rate.
[0020] In some embodiments, the allocating service traffic in the primary hosting room to at least one backup hosting room when a response success rate of the target service in the primary hosting room is lower than a preset success rate comprises:
[0021] determining a second preset proportion according to the response success rate, the response success rate and the second preset proportion being inversely related;
[0022] allocating a second preset proportion of service traffic in the primary hosting room to at least one backup hosting room.
[0023] In some embodiments, the traffic allocation strategy further comprises a traffic weight corresponding to each primary hosting room, and the selecting a target instance from the list of available instances for calling according to the traffic allocation strategy comprises:
[0024] According to the traffic weight corresponding to each of the host rooms, the service traffic corresponding to the target service is distributed to each of the host rooms.
[0025] In some embodiments, the traffic distribution strategy further includes a traffic weight corresponding to each of the backup rooms, and the distribution of the service traffic in the host room to one or more backup rooms according to the traffic distribution strategy includes:
[0026] According to the traffic weight corresponding to each of the backup rooms, the service traffic in the host room is distributed to each of the backup rooms.
[0027] In some embodiments, the obtaining of the traffic distribution strategy corresponding to the target service and the list of available instances includes:
[0028] According to the information of at least one host room and at least one backup room, a list of available instances in the at least one host room and the at least one backup room is obtained.
[0029] In a second aspect, the embodiments of the present disclosure provide a traffic distribution device, including:
[0030] The obtaining module is configured to obtain a traffic distribution strategy corresponding to a target service and a list of available instances, the traffic distribution strategy including information of at least one host room and at least one backup room corresponding to the target service, and the list of available instances including room information corresponding to each available instance.
[0031] The calling module is configured to select a target instance from the list of available instances according to the traffic distribution strategy to call the target instance, so that the target instance provides the target service, and the target instance is located in the host room.
[0032] The distribution module is configured to, when any of the host rooms has an abnormal condition, distribute service traffic in the host room to one or more backup rooms according to the traffic distribution strategy.
[0033] In a third aspect, the embodiments of the present disclosure provide an electronic device, including:
[0034] a memory;
[0035] a processor; and
[0036] a computer program;
[0037] The computer program is stored in the memory and is configured to be executed by the processor to implement the method of the first aspect.
[0038] In a fourth aspect, the embodiments of the present disclosure provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the method in the first aspect.
[0039] In a fifth aspect, the embodiments of the present disclosure also provide a computer program product, which includes a computer program or instructions. The computer program or instructions are executed by a processor to implement the traffic allocation method as described above.
[0040] The traffic allocation method, device, equipment and computer readable storage medium provided by the embodiments of the present disclosure can improve the availability of the target service, reduce the fault time, and improve the flexibility of the traffic allocation method by configuring a traffic allocation strategy for each service respectively, and timely allocating service traffic to the backup data center according to the traffic allocation strategy when the target service corresponding host room appears abnormal condition. BRIEF DESCRIPTION OF DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and serve to explain the principles of the present disclosure together with the specification.
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0043] Figure 1 A flowchart of the traffic allocation method provided by the embodiments of the present disclosure is shown in the figure.
[0044] Figure 2 A schematic diagram of an application scenario provided by the embodiments of the present disclosure is shown in the figure.
[0045] Figure 3 A structural schematic diagram of the traffic allocation device provided by the embodiments of the present disclosure is shown in the figure.
[0046] Figure 4 A structural schematic diagram of the electronic equipment provided by the embodiments of the present disclosure is shown in the figure. DETAILED DESCRIPTION
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0048] Numerous specific details are set forth in the following description in order to provide a full understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only some, and not all, of the embodiments of this disclosure.
[0049] This disclosure provides a traffic allocation method, which will be described below with reference to specific embodiments.
[0050] Figure 1 A flowchart illustrating the traffic allocation method provided in this embodiment of the disclosure. This method can be applied to... Figure 2 The application scenario shown includes a registry center 21, a service provider 22, a service consumer 23, and a configuration center 24. The registry center 21 manages service registration and discovery; commonly used registry centers include Zookeeper, Nacos, and Etcd. The configuration center 21 is an important component in the distributed system for centralized management and dynamic updating of configurations, and can manage traffic allocation strategies; examples include Spring Cloud Config, Zookeeper, and Consul.
[0051] It is understood that the traffic allocation method provided in this disclosure can also be applied in other scenarios.
[0052] The following is combined Figure 2 The application scenarios shown are for Figure 1 The flow allocation method shown is described below, and the specific steps of this method are as follows:
[0053] S101. Obtain the traffic allocation strategy and available instance list corresponding to the target service. The traffic allocation strategy includes information on at least one main data center and at least one backup data center corresponding to the target service. The available instance list includes data center information corresponding to each available instance.
[0054] The target service is the service that service consumer 23 needs to invoke.
[0055] In an RPC framework, the service provider is the called party. It implements specific business logic or functionality and exposes these service interfaces to the outside world through the RPC framework. The service provider listens for network requests, and when it receives an RPC call request from a service consumer, it executes the corresponding business logic processing and returns the result to the service consumer. The service consumer calls the service interfaces provided by the service provider through the RPC framework, enabling cross-process or cross-network communication. The service consumer does not directly implement the specific business logic; instead, it completes business processing by calling the services provided by the service provider.
[0056] In this step, the traffic allocation strategy is configured by the developer for each service pair via the configuration center 24, each service pair corresponds to a traffic allocation strategy, and the service consumer obtains the traffic allocation strategy corresponding to the target strategy from the configuration center when the service consumer needs to call the target service.
[0057] The available instance list is a list of instances capable of providing the target service and their related information. The service provider 22 registers the service, instance information and data center information in the registration center 21 at startup, so that the service consumer 23 can obtain the service list and the corresponding available instance list from the registration center 21 when needed, and the available instance list includes the data center information corresponding to each available instance.
[0058] Correspondingly, the service consumer 23 pulls the service list and the available instance list from the registration center 21.
[0059] S102, according to the traffic allocation strategy, a target instance is selected from the available instance list for calling, so that the target instance provides the target service, and the target instance is located in the host data center.
[0060] The traffic allocation strategy can specify that the instances in a certain data center of the service consumer 23 access the instances in one or more data centers of the service provider 22.
[0061] Specifically, the traffic allocation strategy specifies at least one host data center capable of providing the target service.
[0062] In the normal service calling process, the service consumer 23 realizes the target service by accessing the target instance in the host data center.
[0063] S103, when any of the host data centers has an abnormal condition, the service traffic in the host data center is allocated to one or more backup data centers according to the traffic allocation strategy.
[0064] The abnormal conditions that may occur in the host data center include: the service response of the host data center becomes slow, the service traffic of the host data center increases sharply, the host data center cannot respond to the service traffic, the service response success rate of the host data center decreases, etc.
[0065] Among them, the slow service response of the host data center and the decrease of the service response success rate will cause the quality and efficiency of the target service to decrease; the sharp increase of the service traffic of the host data center will cause the load of the instances in the host data center to be too large, affecting the normal provision of the target service; the host data center cannot respond to the service traffic, which means that the host data center cannot provide the target service temporarily.
[0066] As described above, the traffic allocation strategy further includes information of backup machine rooms. Specifically, the backup machine room information includes a result of setting whether each main machine room is enabled for backup, and can further include address information of multiple backup machine rooms. The backup machine rooms can also provide the target service.
[0067] When an abnormal condition occurs in any main machine room, the service traffic of the target service is allocated to the backup machine room, specifically including allocating a certain proportion of service traffic to the backup machine room, or switching all service traffic in the main machine room to the backup machine room.
[0068] To implement traffic allocation in the machine room dimension, the service consumer 23 needs to be able to identify the machine room information of itself and the target instance. One possible implementation is to identify according to the IP of the target instance and the IP network segment information of the machine room; another possible implementation is that the service provider 22 registers the machine room information to the registration center 21, and the service consumer can directly obtain the machine room information of the service provider 22. At the same time, the service consumer 23 can identify the machine room information of the machine instance of itself through environment variables, configuration files, etc.
[0069] Secondly, when traffic allocation is performed, the service consumer 23 needs to obtain the instance information of the service provider 22 in the machine room that can provide the target service. In the scenario of a small-scale application instance, the service consumer 23 can pull the full service provider instance information from the registration center 21, which can be achieved by configuring or developing a synchronization tool based on the cluster mode of the registration center 21 itself.
[0070] Optionally, the obtaining of the traffic allocation strategy corresponding to the target service and the list of available instances includes: obtaining a list of available instances in at least one main machine room and at least one backup machine room according to information of the at least one main machine room and the at least one backup machine room.
[0071] For the scenario of a large-scale application instance, the main machine room and the backup machine room are determined by parsing the traffic allocation strategy, and the instance information of the main machine room and the backup machine room is further pulled from the registration center to obtain the list of available instances.
[0072] Optionally, the traffic allocation strategy further includes a priority corresponding to each backup machine room. In the process of allocating service traffic to the backup machine room, the priority corresponding to each backup machine room is followed. For example, the priority of the backup machine room in the same region as the main machine room is higher than the priority of the backup machine room in a different region from the main machine room, and in the process of traffic allocation, the service traffic in the main machine room is preferentially allocated to the backup machine room in the same region as the main machine room.
[0073] The embodiments of the present disclosure obtain a traffic allocation strategy corresponding to a target service and a list of available instances, the traffic allocation strategy including information of at least one host room and at least one backup host room corresponding to the target service, and the list of available instances including host room information corresponding to each available instance; a target instance is selected from the list of available instances according to the traffic allocation strategy to call the target instance to provide the target service, and the target instance is located in the host room; when any of the host rooms has an abnormal condition, the service traffic in the host room is allocated to one or more backup host rooms according to the traffic allocation strategy, the traffic allocation strategy is configured for each service respectively, and when the target host room has an abnormal condition, the service traffic is allocated to the backup host room in time according to the traffic allocation strategy, so that the availability of the target service is improved, the fault time is reduced, and the flexibility of the traffic allocation method is improved.
[0074] Meanwhile, in the scenario of a large number of application instances, the embodiments of the present disclosure pull instance information of a corresponding host room by analyzing the traffic allocation strategy, so that the amount of information obtained in the process is reduced, and the rationality of the traffic allocation method is further improved.
[0075] On the basis of the above-mentioned embodiments, the method further includes: updating the list of available instances and / or the traffic allocation strategy every preset period.
[0076] Specifically, the service consumer regularly pulls the latest list of available instances from the registration center 21 and obtains the latest traffic allocation strategy from the configuration center 24 to ensure the real-time performance and accuracy of the system.
[0077] In some embodiments, when any of the host rooms has an abnormal condition, the service traffic in the host room is allocated to one or more backup host rooms according to the traffic allocation strategy, including: when the host room cannot respond to the service traffic, the service traffic in the host room is switched to at least one backup host room.
[0078] For any host room, when the host room cannot respond to the service traffic, the host room cannot provide the target service, and at this time, the service traffic in the host room needs to be switched to other backup host rooms.
[0079] For example, when the A-site host room cannot respond, the service traffic of the A-site host room can be switched to the B-site backup host room, and the B-site backup host room continues to provide the target service.
[0080] In some embodiments, the method further includes: if the new traffic of the host room exceeds a preset threshold within a preset time period, setting at least one backup room as a new host room; and distributing a first preset proportion of the new traffic to the new host room.
[0081] The new traffic of the host room exceeding a preset threshold within a preset time period means that the service traffic of the host room increases sharply, which represents that the host room will process more requests and data transmission and bear higher load pressure, which may cause the service response time to be prolonged or even the service to be interrupted. To avoid the above situation, a first preset proportion of the new traffic is distributed to other backup rooms.
[0082] In one possible implementation, at least one backup room is determined as a new host room, and a first preset proportion of the new traffic is distributed to the new host room.
[0083] The first preset proportion can be 100%, that is, all the new traffic is distributed to the new host room, or the first preset proportion is not 100%, and the new traffic is borne by the original host room and the new host room together.
[0084] Optionally, the first preset proportion is configured by a developer in the traffic distribution strategy.
[0085] In the above embodiments, the traffic distribution strategy further includes a traffic weight corresponding to each backup room, and the method of distributing a first preset proportion of the new traffic to the new host room includes: determining a traffic weight corresponding to each new host room according to the traffic weight corresponding to each backup room; and distributing the first preset proportion of the new traffic to the new host room according to the traffic weight corresponding to each new host room.
[0086] The new host room is the original backup room, and thus the traffic weight of the new host room is the traffic weight of the backup room corresponding to the new host room. When the first preset proportion of the new traffic is distributed, each new host room is allocated a corresponding proportion of traffic according to the traffic weight of the new host room.
[0087] In some embodiments, the method further includes: when a response success rate of the target service in the host room is lower than a preset success rate, distributing the service traffic in the host room to at least one backup room.
[0088] When the response success rate of the target service in the host room is lower than the preset success rate, it may represent that the resources of the instances in the host room are insufficient or the performance of the instances in the host room is decreased, or the network bandwidth is insufficient.
[0089] The response success rate of the target service is reduced, which affects the service consumers to complete the business process. Therefore, when the response success rate of the target service is lower than the preset success rate, the service flow in the host room needs to be distributed to at least one backup room. Specifically, part of the service flow in the host room can be distributed to at least one backup room, or all the service flow in the host room can be distributed to at least one backup room, which is determined according to the actual situation and the setting of the developer.
[0090] Optionally, when the response success rate of the target service in the host room is lower than the preset success rate threshold, a preset proportion of the service flow in the host room is distributed to the backup room, and the response success rate of the target service in the host room is continued to be monitored. If the response success rate in the host room is still lower than the preset success rate threshold, all the service flow in the host room is switched to the backup room.
[0091] Optionally, a second preset proportion is determined according to the response success rate, the response success rate and the second preset proportion are inversely related, and a second preset proportion of the service flow in the host room is distributed to at least one backup room.
[0092] The lower the response success rate of the service flow in the host room is, the more serious the abnormal situation in the host room is, and more service flow needs to be distributed to the backup room. Therefore, the response success rate and the second preset proportion are inversely related, the higher the response success rate is, the lower the second preset proportion is.
[0093] Further, the flow distribution strategy includes the flow weight corresponding to each backup room respectively, and the second preset proportion of the service flow is distributed according to the flow weight of each backup room.
[0094] The embodiments of the present disclosure can realize different coping strategies through the flow distribution strategy under multiple abnormal situations of the host room, so that the flow distribution method can cope with multiple abnormal situations, and further improve the flexibility of the flow distribution method.
[0095] In some embodiments, the configuration example of the load balancing strategy is as follows:
[0096]
[0097] The configuration adopts the JSON format.
[0098] The configuration field consumer-az is the machine room where the instance of the service consumer is located; the configuration field provider-az is the machine room where the instance of the service provider is located, supporting the configuration of multiple machine rooms, for example, the main machine room where the target instance is located in the above embodiment; weight is the traffic weight, which is used to support the weighted round robin strategy to realize proportional allocation of service traffic, and the corresponding traffic weight of the main machine room and the backup machine room can be configured; backup represents whether the machine room is a backup machine room, if the value is true, the machine room is a backup machine room.
[0099] On the basis of the above embodiment, the traffic allocation strategy further includes a traffic weight corresponding to each of the main machine rooms, and the target instance is selected from the available instance list according to the traffic allocation strategy, including: according to the traffic weight corresponding to each of the main machine rooms, the service traffic corresponding to the target service is allocated to each of the main machine rooms.
[0100] For the same target service, if there are multiple main machine rooms, the traffic can be allocated according to the traffic weight corresponding to each of the main machine rooms in the traffic allocation strategy. The traffic weight of the main machine room reflects how much service traffic each main machine room bears. The higher the traffic weight, the more service traffic will be allocated to the main machine room under the same conditions; the lower the traffic weight, the less service traffic will be allocated to the main machine room under the same conditions.
[0101] Specifically, the first main machine room corresponds to a first traffic weight, and the second main machine room corresponds to a second traffic weight, so that when the target service is called, the service traffic corresponding to the first traffic weight is allocated to the first main machine room, and the service traffic corresponding to the second traffic weight is allocated to the second main machine room; correspondingly, the target instance in the first main machine room is responsible for loading the service traffic corresponding to the first traffic weight, and the target instance in the second main machine room is responsible for loading the service traffic corresponding to the second traffic weight.
[0102] For example, in the above configuration instance, the traffic weight corresponding to the "az-a" main machine room is 7, and the traffic weight corresponding to the "az-b" main machine room is 3, so that 70% of the service traffic is allocated to the "az-a" main machine room, and 30% of the service traffic is allocated to the "az-b" main machine room.
[0103] Specifically, 70% of the service traffic is loaded by the target instance in the "az-a" main machine room, and 30% of the service traffic is loaded by the target instance in the "az-b" main machine room.
[0104] On the basis of the above-mentioned embodiments, the traffic allocation strategy further comprises a traffic weight corresponding to each of the backup machine rooms, and the allocation of the service traffic in the host machine room to one or more backup machine rooms according to the traffic allocation strategy comprises: allocating the service traffic in the host machine room to each of the backup machine rooms according to the traffic weight corresponding to each of the backup machine rooms.
[0105] When any host machine room has an abnormal situation and needs to share the service traffic with the backup machine rooms, the service traffic is allocated according to the traffic weight corresponding to each of the backup machine rooms. The traffic weight of the backup machine room reflects how much service traffic each backup machine room bears. The higher the traffic weight, the more service traffic will be allocated to the backup machine room under the same conditions; the lower the traffic weight, the less service traffic will be allocated to the backup machine room under the same conditions.
[0106] For example, the host machine room corresponds to a first backup machine room and a second backup machine room, the first backup machine room is configured with a third traffic weight, and the second backup machine room is configured with a fourth traffic weight.
[0107] When the host machine room cannot respond and needs to switch the service traffic in the host machine room to at least one backup machine room, the service traffic corresponding to the third traffic weight in the host machine room is allocated to the first backup machine room, and the service traffic corresponding to the fourth traffic weight in the host machine room is allocated to the second backup machine room.
[0108] When the added traffic of the host machine room exceeds a preset threshold within a preset time period, at least one backup machine room needs to be set as a new host machine room, and the traffic weight of the new host machine room is the same as that of the original backup machine room. For example, when the first backup machine room is set as a first new host machine room, the first new host machine room has the third traffic weight corresponding to the original first backup machine room; when the second backup machine room is set as a second new host machine room, the second new host machine room has the fourth traffic weight corresponding to the original second backup machine room. Further, the allocation of the added traffic to the new host machine room comprises: allocating the added traffic corresponding to the third traffic weight to the first new host machine room and allocating the added traffic corresponding to the fourth traffic weight to the second new host machine room.
[0109] When the response success rate of the target service in the host machine room is lower than a preset success rate, the service traffic in the host machine room is allocated to at least one backup machine room according to the traffic weight corresponding to each of the backup machine rooms. Specifically, among the service traffic that needs to be allocated in the host machine room, the service traffic corresponding to the third traffic weight is allocated to the first backup machine room, and the service traffic corresponding to the fourth traffic weight is allocated to the second backup machine room.
[0110] The embodiments of the present disclosure further improve the flexibility of the traffic allocation method by allocating service traffic of a target service to multiple host rooms according to traffic weights in a traffic allocation strategy and allocating traffic to multiple backup host rooms according to the traffic weights in the traffic allocation process.
[0111] Figure 3 A structural schematic diagram of a traffic allocation device provided by the embodiments of the present disclosure is shown. The traffic allocation device provided by the embodiments of the present disclosure can execute the processing procedure provided by the traffic allocation method embodiments, as shown in Figure 3 The traffic allocation device 30 includes an acquisition module 31, a calling module 32, and an allocation module 33. The acquisition module 31 is configured to acquire a traffic allocation strategy corresponding to a target service and a list of available instances, wherein the traffic allocation strategy includes information of at least one host room and at least one backup host room corresponding to the target service, and the list of available instances includes room information corresponding to each available instance. The calling module 32 is configured to select a target instance from the list of available instances according to the traffic allocation strategy to call the target instance to provide the target service, wherein the target instance is located in the host room. The allocation module 33 is configured to allocate service traffic in the host room to one or more backup host rooms according to the traffic allocation strategy when an abnormal condition occurs in any of the host rooms.
[0112] Optionally, the allocation module 33 includes a first allocation unit 331 configured to switch service traffic in the host room to at least one backup host room when the host room cannot respond to the service traffic.
[0113] Optionally, the allocation module 33 includes a second allocation unit 332 configured to, within a preset time period, set at least one backup host room as a new host room if new traffic of the host room exceeds a preset threshold, and allocate a first preset proportion of the new traffic to the new host room.
[0114] Optionally, the traffic allocation strategy further includes a traffic weight corresponding to each backup host room, and the second allocation unit 332 is configured to determine a traffic weight corresponding to each new host room according to the traffic weight corresponding to each backup host room, and allocate the first preset proportion of the new traffic to the new host room according to the traffic weight corresponding to each new host room.
[0115] Optionally, the allocation module 33 includes a third allocation unit 333 configured to allocate service traffic in the host room to at least one backup host room when a response success rate of the target service in the host room is lower than a preset success rate.
[0116] Optionally, the third allocation unit 333 is configured to determine a second preset proportion according to the response success rate, the response success rate being inversely related to the second preset proportion; and allocate service traffic of the second preset proportion in the main machine room to at least one backup machine room.
[0117] Optionally, the traffic allocation strategy further includes a traffic weight corresponding to each of the main machine rooms, and the calling module 32 is specifically configured to allocate service traffic corresponding to the target service to each of the main machine rooms according to the traffic weight corresponding to each of the main machine rooms.
[0118] Optionally, the traffic allocation strategy further includes a traffic weight corresponding to each of the backup machine rooms, and the allocation module 33 is specifically configured to allocate service traffic in the main machine room to each of the backup machine rooms according to the traffic weight corresponding to each of the backup machine rooms.
[0119] Optionally, the obtaining module 31 is specifically configured to obtain a list of available instances in the at least one main machine room and the at least one backup machine room according to information of the at least one main machine room and the at least one backup machine room.
[0120] Figure 3 The traffic allocation apparatus of the embodiment can be used to execute the technical solutions of the method embodiments, and has similar implementation principles and technical effects, which will not be described here.
[0121] Figure 4 The electronic device provided by the embodiment of the present disclosure is shown in a structural schematic diagram. The electronic device provided by the embodiment of the present disclosure can execute the processing flow provided by the traffic allocation method embodiment, as shown in Figure 4 As shown, the electronic device 40 includes a memory 41, a processor 42, a computer program, and a communication interface 43; wherein the computer program is stored in the memory 41 and is configured to be executed by the processor 42 to execute the traffic allocation method as described above.
[0122] In addition, the embodiment of the present disclosure further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the traffic allocation method described in the above embodiments.
[0123] The computer readable storage medium can be embodied as one or more combinations of a readable medium and a computer readable communication medium. The computer readable storage medium can be a readable storage medium or a computer readable communication medium. The readable storage medium can include, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0124] Further, the disclosure embodiments provide a computer program product, which includes a computer program or instructions, and the computer program or instructions are executed by a processor to implement the traffic steering method as described above. The computer program product can be written in any combination of one or more programming languages, including an object-oriented programming language such as Java, C++, etc., and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server.
[0125] It should be noted that, in this document, the terms such as "first" and "second" are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0126] The foregoing is merely illustrative of the various implementations of the present disclosure and the general principles thereof. Numerous modifications can be made to these illustrations, and equivalents can be substituted therefor, without departing from the scope of the present disclosure. The specific embodiments commensurate with the specific application are intended to be illustrative only and not limiting of the scope of the application as set forth in the following claims.
Claims
1. A method of flow conditioning, characterized by, The method comprises: acquiring a traffic allocation strategy corresponding to a target service and a list of available instances, the traffic allocation strategy comprising information of at least one host room and at least one backup host room corresponding to the target service, and the list of available instances comprising host room information corresponding to each available instance; selecting a target instance from the list of available instances according to the traffic allocation strategy to call the target instance, so that the target instance provides the target service, the target instance being located in the host room; when any of the host rooms has an abnormal condition, allocating service traffic in the host room to one or more backup host rooms according to the traffic allocation strategy; wherein the traffic allocation strategy further comprises a traffic weight corresponding to each backup host room respectively, and the allocating of service traffic in the host room to one or more backup host rooms according to the traffic allocation strategy when any of the host rooms has an abnormal condition comprises: if new traffic of the host room exceeds a preset threshold within a preset time period, setting at least one backup host room as a new host room; determining a traffic weight corresponding to each new host room respectively according to the traffic weight corresponding to each backup host room respectively; allocating a first preset proportion of new traffic to the new host room according to the traffic weight corresponding to each new host room respectively.
2. The method of claim 1, wherein, the allocating of service traffic in the host room to one or more backup host rooms according to the traffic allocation strategy when any of the host rooms has an abnormal condition comprises: when the host room cannot respond to the service traffic, switching the service traffic in the host room to at least one backup host room.
3. The method of claim 1, wherein, the allocating of service traffic in the host room to one or more backup host rooms according to the traffic allocation strategy when any of the host rooms has an abnormal condition comprises: when a response success rate of the target service in the host room is lower than a preset success rate, allocating service traffic in the host room to at least one backup host room.
4. The method of claim 3, wherein, the allocating of service traffic in the host room to at least one backup host room when the response success rate of the target service in the host room is lower than the preset success rate comprises: determining a second preset proportion according to the response success rate, the response success rate being inversely related to the second preset proportion; allocating a second preset proportion of service traffic in the host room to at least one backup host room.
5. The method of claim 1, wherein, the traffic allocation strategy further comprises a traffic weight corresponding to each host room respectively, and the calling of a target instance from the list of available instances according to the traffic allocation strategy comprises: allocating service traffic corresponding to the target service to each host room according to the traffic weight corresponding to each host room respectively.
6. The method of claim 1, wherein, the traffic allocation strategy further comprises a traffic weight corresponding to each backup host room respectively, and the allocating of service traffic in the host room to one or more backup host rooms according to the traffic allocation strategy comprises: allocating service traffic in the host room to each backup host room according to the traffic weight corresponding to each backup host room respectively.
7. The method of claim 1, wherein, The traffic allocation strategy corresponding to the target service and the list of available instances are acquired, including: According to the information of at least one host room and at least one backup host room, a list of available instances in the at least one host room and the at least one backup host room is acquired.
8. A flow conditioning device, characterized by Including: An acquisition module is configured to acquire a traffic allocation strategy corresponding to a target service and a list of available instances, the traffic allocation strategy including information of at least one host room and at least one backup host room corresponding to the target service, and the list of available instances including host room information corresponding to each available instance. A calling module is configured to select a target instance from the list of available instances according to the traffic allocation strategy to call the target instance to provide the target service, the target instance being located in the host room. An allocation module is configured to allocate service traffic in the host room to one or more backup host rooms according to the traffic allocation strategy when any of the host rooms has an abnormal condition. The traffic allocation strategy further includes a traffic weight corresponding to each backup host room, and the allocation module includes a second allocation unit configured to, within a preset time period, set at least one backup host room as a new host room if new traffic of the host room exceeds a preset threshold; determine a traffic weight corresponding to each new host room according to the traffic weight corresponding to each backup host room; and allocate a first preset proportion of new traffic to the new host room according to the traffic weight corresponding to each new host room. Including:
9. An electronic device, comprising: A memory; A processor; And A computer program; The computer program is stored in the memory and is configured to be executed by the processor to implement the method of any one of claims 1-7. The computer program is executed by the processor to implement the method of any one of claims 1-7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that,
Citation Information
Patent Citations
Load balancing method and device based on micro-service, equipment and storage medium
CN111464592A
Automatic traffic scheduling method, system and device and storage medium
CN112910798A