Traffic allocation method, device and equipment and computer readable storage medium
By obtaining the traffic allocation policy and available instance list in the RPC framework, the service traffic is automatically allocated to the backup computer room when the computer room is abnormal, which solves the problem of fixed load balancing strategies in the existing technology and improves service availability and deployment flexibility. sex.
Patent Information
- Application Number
- CN202411012375.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-07-26
AI Technical Summary
The service traffic load balancing strategy in the existing RPC framework is relatively fixed and cannot respond to special circumstances of service instances or computer rooms in a timely manner, resulting in an impact on service quality and a lack of flexibility.
Provide a traffic allocation method. By obtaining the traffic allocation policy and available instance list of the target service, the service traffic will be allocated to the backup computer room according to the policy when an abnormality occurs in the computer room, including when the computer room cannot respond, new traffic exceeds the threshold, and response When the success rate is low, the traffic is switched to the backup computer room and distributed according to the traffic weight.
It improves service availability, reduces downtime, enhances the flexibility of traffic allocation methods, and can cope with a variety of abnormal situations.
Smart Images

Figure CN118784652A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of microservice technology, and in particular to a traffic allocation method, device, equipment, and computer-readable storage medium. Background Art
[0002] Remote Procedure Call (RPC) is a communication protocol that requests services from a remote computer program over a network without having to understand the underlying details of the network. RPC simplifies the development of distributed systems and is widely used in microservice architectures.
[0003] In the process of requesting services, in order to ensure the quality of service, it is usually necessary to perform load balancing control on the service traffic to prevent one instance or one computer room from carrying too much service traffic. In the existing RPC framework, load balancing strategies such as polling, random, and minimum number of connections are provided.
[0004] However, the existing service traffic load balancing strategy is relatively fixed, and cannot respond in time when special circumstances occur in the instance or computer room providing the service, affecting the normal provision and use of the service. Therefore, the existing traffic allocation method lacks certain flexibility. Summary of the invention
[0005] In order to solve the above technical problems, the present disclosure provides a traffic allocation method, device, equipment and computer-readable storage medium to improve the flexibility of the traffic allocation method.
[0006] In a first aspect, an embodiment of the present disclosure provides a flow allocation method, including:
[0007] Obtaining a traffic allocation strategy and an available instance list corresponding to a target service, wherein the traffic allocation strategy includes information of at least one main computer room and at least one backup computer room corresponding to the target service, and the available instance list includes computer room information corresponding to each available instance;
[0008] Selecting a target instance from the available instance list 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 computer room;
[0009] When an abnormal situation occurs in any of the main computer rooms, the service traffic in the main computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy.
[0010] In some embodiments, when an abnormal condition occurs in any of the computer rooms, the service traffic in the computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including:
[0011] When the main computer room cannot respond to the service traffic, the service traffic in the main computer room is switched to at least one backup computer room.
[0012] In some embodiments, when an abnormal condition occurs in any of the computer rooms, the service traffic in the computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including:
[0013] Within a preset time period, if the new traffic of the main computer room exceeds a preset threshold, at least one backup computer room is set as a new main computer room;
[0014] A first preset proportion of the newly added traffic is distributed to the newly added computer room.
[0015] In some embodiments, the traffic allocation strategy further includes a traffic weight corresponding to each backup computer room, and the allocating of the first preset proportion of the newly added traffic to the newly added main computer room includes:
[0016] Determine the traffic weight corresponding to each of the newly added main computer rooms according to the traffic weight corresponding to each of the backup computer rooms;
[0017] According to the traffic weights corresponding to each of the newly added computer rooms, the first preset proportion of the newly added traffic is allocated to the newly added computer rooms.
[0018] In some embodiments, when an abnormal condition occurs in any of the computer rooms, the service traffic in the computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including:
[0019] When the response success rate of the target service in the main computer room is lower than a preset success rate, the service traffic in the main computer room is distributed to at least one backup computer room.
[0020] In some embodiments, when the response success rate of the target service in the main computer room is lower than a preset success rate, allocating the service traffic in the main computer room to at least one backup computer room includes:
[0021] Determine a second preset ratio according to the response success rate, wherein the response success rate is inversely correlated with the second preset ratio;
[0022] Distribute a second preset proportion of service traffic in the main computer room to at least one backup computer room.
[0023] In some embodiments, the traffic allocation strategy also includes a traffic weight corresponding to each of the computer rooms, and selecting a target instance from the available instance list for calling according to the traffic allocation strategy includes:
[0024] According to the flow weight corresponding to each of the computer rooms, the service flow corresponding to the target service is distributed to each of the computer rooms.
[0025] In some embodiments, the traffic allocation strategy also includes a traffic weight corresponding to each backup computer room, and allocating the service traffic in the main computer room to one or more backup computer rooms according to the traffic allocation strategy includes:
[0026] According to the flow weight corresponding to each backup computer room, the service flow in the main computer room is allocated to each backup computer room.
[0027] In some embodiments, obtaining the traffic allocation strategy and the available instance list corresponding to the target service includes:
[0028] According to the information of at least one main computer room and at least one backup computer room, a list of available instances in the at least one main computer room and at least one backup computer room is obtained.
[0029] In a second aspect, an embodiment of the present disclosure provides a flow allocation device, comprising:
[0030] An acquisition module, used to acquire a traffic allocation strategy and an available instance list corresponding to a target service, wherein the traffic allocation strategy includes information of at least one main computer room and at least one backup computer room corresponding to the target service, and the available instance list includes computer room information corresponding to each available instance;
[0031] A calling module, configured to select a target instance from the available instance list for calling according to the traffic allocation strategy, so that the target instance provides the target service, and the target instance is located in the computer room;
[0032] The allocation module is used to allocate the service traffic in the main computer room to one or more backup computer rooms according to the traffic allocation strategy when an abnormal situation occurs in any of the main computer rooms.
[0033] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0034] Memory;
[0035] Processor; and
[0036] Computer programs;
[0037] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0038] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.
[0039] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the traffic allocation method as described above is implemented.
[0040] The traffic allocation method, apparatus, device and computer-readable storage medium provided by the embodiments of the present disclosure improve the availability of the target service and reduce the failure time by configuring a traffic allocation strategy for each service respectively, and promptly allocate the service traffic to the backup computer room according to the traffic allocation strategy when an abnormal condition occurs in the main computer room corresponding to the target service, thereby improving the flexibility of the traffic allocation method. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0043] Figure 1 A flow chart of a flow allocation method provided in an embodiment of the present disclosure;
[0044] Figure 2 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;
[0045] Figure 3 A schematic diagram of the structure of a flow rate allocation device provided in an embodiment of the present disclosure;
[0046] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0047] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0048] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0049] The present disclosure provides a flow allocation method, which is described below in conjunction with a specific embodiment.
[0050] Figure 1 A flow chart of the flow allocation method provided in the embodiment of the present disclosure. The method can be applied to Figure 2 The application scenario shown includes a registration center 21, a service provider 22, a service consumer 23, and a configuration center 24. The registration center 21 manages the registration and discovery of services. Common registration centers include Zookeeper, Nacos, and Etcd. The configuration center 21 is an important component for centralized management and dynamic configuration updates in a distributed system, and can manage traffic allocation strategies, such as SpringCloud Config, Zookeeper, and Consul.
[0051] It is understandable that the traffic allocation method provided in the embodiments of the present disclosure can also be applied in other scenarios.
[0052] Combine the following Figure 2 The application scenario shown is Figure 1 The traffic allocation method shown in the figure is introduced, and the specific steps of the method are as follows:
[0053] S101. Obtain a traffic allocation strategy and a list of available instances corresponding to a target service, wherein the traffic allocation strategy includes information of at least one main computer room and at least one backup computer room corresponding to the target service, and the list of available instances includes computer room information corresponding to each available instance.
[0054] The target service is the service that the service consumer 23 needs to call.
[0055] In the RPC framework, the service provider is the party being called. It implements specific business logic or functions and exposes these service interfaces through the RPC framework. The service provider is responsible for monitoring network requests. When receiving an RPC call request from a service consumer, it will execute the corresponding business logic processing and return the processing result to the service consumer. The service consumer calls the service interface provided by the service provider through the RPC framework to achieve cross-process or cross-network communication. The service consumer does not directly implement specific business logic, but 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 through the configuration center 24. Each service corresponds to a traffic allocation strategy. When the service consumer needs to call the target service, the traffic allocation strategy corresponding to the target strategy is obtained from the configuration center.
[0057] The available instance list is a list consisting of instances that can provide the target service and their related information. The service provider 22 registers the service, instance information and computer room information to the registration center 21 when it is started, so that the service consumer 23 can obtain the service list from the registration center 21 when needed, and obtain the corresponding available instance list, which includes the computer room information corresponding to each available instance.
[0058] Accordingly, the service consumer 23 pulls the service list and the available instance list from the registration center 21 .
[0059] S102: Select a target instance from the available instance list according to the traffic allocation strategy and call it, so that the target instance provides the target service, and the target instance is located in the computer room.
[0060] The traffic allocation strategy can specify an instance of a certain computer room of the service consumer 23 to access instances of one or more computer rooms of the service provider 22.
[0061] Specifically, the traffic allocation strategy specifies at least one computer room that can provide target services.
[0062] In a normal service invocation process, the service consumer 23 implements the target service by accessing the target instance in the main computer room.
[0063] S103. When an abnormal condition occurs in any of the main computer rooms, the service traffic in the main computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy.
[0064] Abnormal situations that may occur in the computer room include: slow service response in the computer room, a surge in service traffic in the computer room, the inability of the computer room to respond to service traffic, a decrease in the success rate of service response in the computer room, etc.
[0065] Among them, the slower service response and lower service response success rate of the main computer room will cause the service quality and efficiency of the target service to decline; the surge in service traffic in the main computer room will cause the instance in the main computer room to be overloaded, affecting the normal provision of the target service; the inability of the main computer room to respond to the service traffic means that the main computer room is temporarily unable to provide the target service.
[0066] As mentioned above, the traffic allocation strategy also includes information about the backup computer room. Specifically, the backup computer room information includes the setting result of whether each main computer room has enabled backup, and may also include address information of multiple backup computer rooms, which can also provide the target service.
[0067] When an abnormal situation occurs in any main computer room, the service traffic of the target service will be allocated to the backup computer room, including allocating a certain proportion of service traffic to the backup computer room, or switching all service traffic in the main computer room to the backup computer room.
[0068] To implement traffic allocation in the computer room dimension, the service consumer 23 needs to be able to identify the computer room information of itself and the target instance. One possible implementation method is to identify it based on the IP of the target instance and the IP network segment information of the computer room; another possible implementation method is that the service provider 22 registers the computer room information to the registration center 21, and the service consumer can directly obtain the computer room information of the service provider 22. At the same time, the service consumer 23 can identify the computer room information of its own machine instance through environment variables, configuration files, etc.
[0069] Secondly, when performing traffic allocation, the service consumer 23 needs to obtain the instance information of the service provider 22 in the computer room that can provide the target service. In the scenario of small-scale application instances, the service consumer 23 can pull the full amount of service provider instance information from the registration center 21, which can be achieved by configuring the cluster mode of the registration center 21 itself or developing synchronization tools.
[0070] Optionally, obtaining the traffic allocation strategy and the list of available instances corresponding to the target service includes: obtaining the list of available instances in the at least one main computer room and the at least one backup computer room according to information of the at least one main computer room and the at least one backup computer room.
[0071] For the scenario of large-scale application instances, the main computer room and the backup computer room are determined by analyzing the traffic allocation strategy, and the instance information of the main computer room and the backup computer room is further pulled from the registration center to obtain a list of available instances.
[0072] Optionally, the traffic allocation strategy also includes the priority corresponding to each backup computer room. In the process of allocating service traffic to the backup computer room, it is performed according to the priority corresponding to each backup computer room. For example, the priority of the backup computer room in the same area as the main computer room is higher than the priority of the backup computer room in a different area from the main computer room. In the process of traffic allocation, the service traffic in the main computer room is preferentially allocated to the backup computer room in the same area as the main computer room.
[0073] The disclosed embodiment obtains a traffic allocation strategy and a list of available instances corresponding to a target service, wherein the traffic allocation strategy includes information of at least one main computer room and at least one backup computer room corresponding to the target service, and the list of available instances includes computer room information corresponding to each available instance; a target instance is selected from the list of available instances for invocation according to the traffic allocation strategy, so that the target instance provides the target service, and the target instance is located in the main computer room; when an abnormal condition occurs in any of the main computer rooms, the service traffic in the main computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy. By configuring a traffic allocation strategy for each service separately, and timely allocating the service traffic to the backup computer room according to the traffic allocation strategy when an abnormal condition occurs in the main computer room corresponding to the target service, the availability of the target service is improved, the failure time is reduced, and the flexibility of the traffic allocation method is improved.
[0074] At the same time, the embodiment of the present disclosure reduces the amount of information obtained in the process and further improves the rationality of the traffic allocation method by parsing the traffic allocation strategy in the scenario of large-scale application instances to pull the instance information of the corresponding computer room in a targeted manner.
[0075] Based on the above embodiment, the method further includes: updating the available instance list and / or the traffic allocation strategy at every preset period.
[0076] Specifically, the service consumer periodically 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 an abnormal condition occurs in any of the computer rooms, the service traffic in the computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including: when the computer room cannot respond to the service traffic, the service traffic in the computer room is switched to at least one backup computer room.
[0078] For any main computer room, when the main computer room cannot respond to the service traffic, the room will be unable to provide the target service. At this time, all the service traffic in the room needs to be switched to other backup computer rooms.
[0079] For example, when the main computer room at site A becomes unresponsive, the service traffic of the main computer room at site A can be switched to the backup computer room at site B, which will continue to provide the target service.
[0080] In some embodiments, when an abnormal condition occurs in any of the computer rooms, the service traffic in the computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including: within a preset time period, if the new traffic in the computer room exceeds a preset threshold, at least one backup computer room is set as a new computer room; and a first preset proportion of the new traffic is allocated to the new computer room.
[0081] The new traffic in the main computer room during the preset time period exceeds the preset threshold, which means that the service traffic in the main computer room has surged, which means that the main computer room will have to handle more requests and data transmissions, bear a higher load pressure, and may cause the service response time to be extended or even the service to be interrupted. To avoid the above situation, the first preset proportion of the new traffic is diverted to other backup computer rooms.
[0082] One possible implementation manner is to determine at least one backup computer room as a newly added main computer room, and allocate a first preset proportion of newly added traffic to the newly added main computer room.
[0083] The first preset ratio may be 100%, that is, all the new traffic is allocated to the new computer room; or, if the first preset ratio is not 100%, the original computer room and the new computer room jointly carry the new traffic.
[0084] Optionally, the first preset ratio is configured by a developer in a traffic allocation strategy.
[0085] On the basis of the above embodiment, the traffic allocation strategy also includes the traffic weight corresponding to each backup computer room, and the first preset proportion of the new traffic is allocated to the newly added main computer room, including: determining the traffic weight corresponding to each of the newly added main computer rooms according to the traffic weight corresponding to each of the backup computer rooms; allocating the first preset proportion of the new traffic to the newly added main computer room according to the traffic weight corresponding to each of the newly added main computer rooms.
[0086] The newly added main machine room is the original backup machine room, so the traffic weight of the newly added main machine room is the traffic weight of the corresponding backup machine room. When allocating the newly added traffic of the first preset ratio, a corresponding proportion of traffic is allocated to each newly added main machine room according to the traffic weight of each newly added main machine room.
[0087] In some embodiments, when an abnormal condition occurs in any of the computer rooms, the service traffic in the computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including: when the response success rate of the target service in the computer room is lower than the preset success rate, the service traffic in the computer room is allocated to at least one backup computer room.
[0088] When the response success rate of the target service in the computer room is lower than the preset success rate, it may represent problems such as insufficient resources or performance degradation of the instance in the computer room, or insufficient network bandwidth.
[0089] A decrease in the response success rate of the target service will affect the service consumer's ability to complete the business process. Therefore, when the response success rate of the target service is lower than the preset success rate, the service traffic in the main computer room needs to be allocated to at least one backup computer room. Specifically, part of the service traffic in the main computer room can be allocated to at least one backup computer room, or all of the service traffic in the main computer room can be allocated to at least one backup computer room, depending on the actual situation and the developer's settings.
[0090] Optionally, when the response success rate of the target service in the main computer room is lower than a preset success rate threshold, a preset proportion of the service traffic in the main computer room is allocated to the backup computer room, and the response success rate of the target service in the main computer room continues to be monitored; if the response success rate in the main computer room is still lower than the preset success rate threshold, all service traffic in the main computer room is switched to the backup computer room.
[0091] Optionally, a second preset ratio is determined based on the response success rate, and the response success rate is inversely correlated with the second preset ratio; and the second preset ratio of service traffic in the main computer room is distributed to at least one backup computer room.
[0092] The lower the response success rate of the main computer room to the service traffic, the more serious the abnormality in the main computer room is, and more service traffic needs to be allocated to the backup computer room. Therefore, the response success rate and the second preset ratio are inversely correlated, and the higher the response success rate, the lower the second preset ratio.
[0093] Furthermore, the traffic allocation strategy includes a traffic weight corresponding to each backup computer room, and the service traffic of the second preset ratio is allocated according to the traffic weight of each backup computer room.
[0094] The disclosed embodiment provides different response strategies that can be implemented by the traffic allocation strategy in various abnormal situations of the main computer room, so that the traffic allocation method can cope with various abnormal situations, thereby further improving the flexibility of the traffic allocation method.
[0095] In some embodiments, the configuration examples of the load balancing strategy are as follows:
[0096]
[0097] The configuration is in JSON format.
[0098] Among them, the configuration field consumer-az is the computer room where the service consumer instance is located; the configuration field provider-az is the computer room where the service provider instance is located, and supports configuring multiple computer rooms, such as the main computer room where the target instance is located in the above embodiment; weight is the traffic weight, which is used to support the weighted polling strategy and realize the proportional distribution of service traffic. The corresponding traffic weights can be configured for the main computer room and the backup computer room; backup represents whether the computer room is a backup computer room. If the value is true, then the computer room is a backup computer room.
[0099] On the basis of the above embodiment, the traffic allocation strategy also includes the traffic weight corresponding to each of the computer rooms, and the target instance is selected from the list of available instances for calling according to the traffic allocation strategy, including: according to the traffic weight corresponding to each of the computer rooms, the service traffic corresponding to the target service is allocated to each of the computer rooms.
[0100] For the same target business, if there are multiple computer rooms, traffic allocation can be performed according to the traffic weight corresponding to each of the computer rooms in the traffic allocation strategy. The traffic weight of the computer room reflects the amount of service traffic each computer room bears. The higher the traffic weight, the more service traffic will be allocated to the computer room under the same conditions; the lower the traffic weight, the less service traffic will be allocated to the computer room under the same conditions.
[0101] Specifically, the first computer room corresponds to the first traffic weight, and the second computer room corresponds to the second traffic weight. When the target service is called, the service traffic corresponding to the first traffic weight is allocated to the first computer room, and the service traffic corresponding to the second traffic weight is allocated to the second computer room; accordingly, the target instance in the first computer room is responsible for loading the service traffic corresponding to the first traffic weight, and the target instance in the second computer room is responsible for loading the service traffic corresponding to the second traffic weight.
[0102] For example, in the above configuration example, the traffic weight corresponding to the "az-a" computer room is 7, and the traffic weight corresponding to the "az-b" computer room is 3, then 70% of the service traffic is allocated to the "az-a" computer room, and 30% of the service traffic is allocated to the "az-b" computer room.
[0103] Specifically, 70% of the service traffic is loaded by the target instance in the "az-a" computer room, and 30% of the service traffic is loaded by the target instance in the "az-b" computer room.
[0104] On the basis of the above embodiment, the traffic allocation strategy also includes the traffic weight corresponding to each of the backup computer rooms, and the service traffic in the main computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including: according to the traffic weight corresponding to each of the backup computer rooms, the service traffic in the main computer room is allocated to each of the backup computer rooms.
[0105] When an abnormal situation occurs in any main computer room and the backup computer room needs to share its service traffic, the service traffic is allocated according to the traffic weight corresponding to each backup computer room. Among them, the traffic weight of the backup computer room reflects the amount of service traffic borne by each backup computer room. The higher the traffic weight, the more service traffic will be allocated to the backup computer room under the same conditions; the lower the traffic weight, the less service traffic will be allocated to the backup computer room under the same conditions.
[0106] For example, the main computer room corresponds to a first backup computer room and a second backup computer room, the first backup computer room is configured with a third traffic weight, and the second backup computer room is configured with a fourth traffic weight.
[0107] When the main computer room cannot respond and the service traffic in the main computer room needs to be switched to at least one backup computer room, the service traffic corresponding to the third traffic weight in the main computer room is allocated to the first backup computer room, and the service traffic corresponding to the fourth traffic weight in the main computer room is allocated to the second backup computer room.
[0108] When the newly added traffic of the main computer room exceeds the preset threshold within the preset time period, at least one backup computer room needs to be set as a newly added main computer room, and the traffic weight of the newly added main computer room is the same as that of the original backup computer room. For example, when the first backup computer room is set as the first newly added main computer room, the first newly added main computer room has the third traffic weight corresponding to the original first backup computer room; when the second backup computer room is set as the second newly added main computer room, the second newly added main computer room has the fourth traffic weight corresponding to the original second backup computer room. Further, allocating the newly added traffic to the newly added main computer room includes: allocating the newly added traffic corresponding to the third traffic weight to the first newly added main computer room, and allocating the newly added traffic corresponding to the fourth traffic weight to the second newly added main computer room.
[0109] When the response success rate of the target service in the main computer room is lower than the preset success rate, the service flow in the main computer room is allocated to at least one backup computer room according to the flow weight corresponding to each backup computer room. Specifically, among the service flows that need to be allocated in the main computer room, the service flows corresponding to the third flow weight are allocated to the first backup computer room, and the service flows corresponding to the fourth flow weight are allocated to the second backup computer room.
[0110] The disclosed embodiment distributes the service traffic of the target service to multiple main computer rooms according to the traffic weights in the traffic allocation strategy, and allocates traffic to multiple backup computer rooms according to the traffic weights during the traffic allocation process, thereby further improving the flexibility of the traffic allocation method.
[0111] Figure 3 The flow allocation device provided in the embodiment of the present disclosure can execute the processing flow provided in the flow allocation method embodiment, such as Figure 3 As shown, the traffic allocation device 30 includes: an acquisition module 31, a calling module 32, and an allocation module 33; wherein the acquisition module 31 is used to obtain the traffic allocation strategy and the available instance list corresponding to the target service, the traffic allocation strategy includes the information of at least one main computer room and at least one backup computer room corresponding to the target service, and the available instance list includes the computer room information corresponding to each available instance; the calling module 32 is used to select a target instance from the available instance list for calling according to the traffic allocation strategy, so that the target instance provides the target service, and the target instance is located in the main computer room; the allocation module 33 is used to allocate the service traffic in the main computer room to one or more backup computer rooms according to the traffic allocation strategy when any of the main computer rooms has an abnormal condition.
[0112] Optionally, the allocation module 33 includes a first allocation unit 331, and the first allocation unit 331 is used to switch the service traffic in the main computer room to at least one backup computer room when the main computer room cannot respond to the service traffic.
[0113] Optionally, the allocation module 33 includes a second allocation unit 332, and the second allocation unit 332 is used to set at least one backup computer room as a new computer room if the new traffic in the computer room exceeds a preset threshold within a preset time period; and allocate a first preset proportion of the new traffic to the new computer room.
[0114] Optionally, the traffic allocation strategy also includes the traffic weight corresponding to each backup computer room, and the second allocation unit 332 is used to determine the traffic weight corresponding to each of the newly added main computer rooms according to the traffic weight corresponding to each of the backup computer rooms; and allocate the first preset proportion of the newly added traffic to the newly added main computer rooms according to the traffic weight corresponding to each of the newly added main computer rooms.
[0115] Optionally, the allocation module 33 includes a third allocation unit 333, and the third allocation unit 333 is used to allocate the service traffic in the main computer room to at least one backup computer room when the response success rate of the target service in the main computer room is lower than a preset success rate.
[0116] Optionally, the third allocation unit 333 is used to determine a second preset ratio according to the response success rate, and the response success rate is inversely correlated with the second preset ratio; and allocate the second preset ratio of service traffic in the main computer room to at least one backup computer room.
[0117] Optionally, the traffic allocation strategy also includes the traffic weight corresponding to each of the computer rooms, and the calling module 32 is specifically used to allocate the service traffic corresponding to the target service to each of the computer rooms according to the traffic weight corresponding to each of the computer rooms.
[0118] Optionally, the traffic allocation strategy also includes a traffic weight corresponding to each of the backup computer rooms, and the allocation module 33 is specifically used to allocate the service traffic in the main computer room to each of the backup computer rooms according to the traffic weight corresponding to each of the backup computer rooms.
[0119] Optionally, the acquisition module 31 is specifically configured to acquire a list of available instances in at least one main computer room and at least one backup computer room according to information of at least one main computer room and at least one backup computer room.
[0120] Figure 3 The flow distribution device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0121] Figure 4 The electronic device provided by the embodiment of the present disclosure can execute the processing flow provided by the flow allocation method embodiment, such as 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 so that the processor 42 executes the flow allocation method as described above.
[0122] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the traffic allocation method described in the above embodiment.
[0123] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0124] In addition, the embodiments of the present disclosure also provide a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the traffic allocation method described above is implemented. The computer program product can be written in any combination of one or more programming languages to write program codes for performing the operations of the embodiments of the present disclosure, and the programming languages include object-oriented programming languages, such as Java, C++, etc., and also include conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0125] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" 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 includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0126] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A flow allocation method, characterized in that: The method comprises: Obtaining a traffic allocation strategy and an available instance list corresponding to a target service, wherein the traffic allocation strategy includes information of at least one main computer room and at least one backup computer room corresponding to the target service, and the available instance list includes computer room information corresponding to each available instance; Selecting a target instance from the available instance list 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 computer room; When an abnormal situation occurs in any of the main computer rooms, the service traffic in the main computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy.
2. The method according to claim 1, characterized in that When an abnormal situation occurs in any of the main computer rooms, the service traffic in the main computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including: When the main computer room cannot respond to the service traffic, the service traffic in the main computer room is switched to at least one backup computer room.
3. The method according to claim 1, characterized in that: When an abnormal situation occurs in any of the main computer rooms, the service traffic in the main computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including: Within a preset time period, if the new traffic of the main computer room exceeds a preset threshold, at least one backup computer room is set as a new main computer room; A first preset proportion of the newly added traffic is distributed to the newly added computer room.
4. The method according to claim 3, characterized in that The traffic allocation strategy also includes the traffic weights corresponding to each backup computer room. The first preset ratio of newly added traffic is allocated to the newly added main computer room, including: Determine the traffic weight corresponding to each of the newly added main computer rooms according to the traffic weight corresponding to each of the backup computer rooms; According to the traffic weights corresponding to each of the newly added computer rooms, the first preset proportion of the newly added traffic is allocated to the newly added computer rooms.
5. The method according to claim 1, characterized in that When an abnormal situation occurs in any of the main computer rooms, the service traffic in the main computer room is allocated to one or more backup computer rooms according to the traffic allocation strategy, including: When the response success rate of the target service in the main computer room is lower than a preset success rate, the service traffic in the main computer room is distributed to at least one backup computer room.
6. The method according to claim 5, characterized in that When the response success rate of the target service in the main computer room is lower than a preset success rate, allocating the service traffic in the main computer room to at least one backup computer room comprises: Determine a second preset ratio according to the response success rate, wherein the response success rate is inversely correlated with the second preset ratio; Distribute a second preset proportion of service traffic in the main computer room to at least one backup computer room.
7. The method according to claim 1, characterized in that The traffic allocation strategy also includes the traffic weights corresponding to each of the computer rooms. The selecting a target instance from the available instance list for calling according to the traffic allocation strategy includes: According to the flow weight corresponding to each of the computer rooms, the service flow corresponding to the target service is distributed to each of the computer rooms.
8. The method according to claim 1, characterized in that The traffic allocation strategy also includes the traffic weights corresponding to each backup computer room. Allocating the service traffic in the main computer room to one or more backup computer rooms according to the traffic allocation strategy includes: According to the flow weight corresponding to each backup computer room, the service flow in the main computer room is allocated to each backup computer room.
9. The method according to claim 1, characterized in that: The method of obtaining the traffic allocation strategy and the list of available instances corresponding to the target service includes: According to the information of at least one main computer room and at least one backup computer room, a list of available instances in the at least one main computer room and at least one backup computer room is obtained.
10. A flow distribution device, characterized in that: include: An acquisition module, used to acquire a traffic allocation strategy and an available instance list corresponding to a target service, wherein the traffic allocation strategy includes information of at least one main computer room and at least one backup computer room corresponding to the target service, and the available instance list includes computer room information corresponding to each available instance; A calling module, configured to select a target instance from the available instance list for calling according to the traffic allocation strategy, so that the target instance provides the target service, and the target instance is located in the computer room; The allocation module is used to allocate the service traffic in the main computer room to one or more backup computer rooms according to the traffic allocation strategy when an abnormal situation occurs in any of the main computer rooms.
11. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
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
Service access request flow distribution method and device
CN114924751A
Intelligent data center cold source regulation and control method and system
CN116880163A
Methods and devices for optimizing load balancing based on cloud monitoring
US20210036957A1
