Service distribution method and device, equipment, storage medium and computer program product
By calculating the average load usage information in a distributed system and splitting and allocating services according to differences, the load information collection instability caused by the change in the number of indicator collectors is solved, and the high availability and service allocation flexibility of the system are improved.
Patent Information
- Application Number
- CN202411009256.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-12-17
AI Technical Summary
In distributed systems, the number of indicator collectors changes lead to unstable collection of service load information, affecting the high availability and effectiveness of the system.
By calculating the average load usage information of the distributed system, if the difference between the load usage information of the indicator collector and the average load usage information meets the splitting conditions, the service split is performed, and the split is allocated in the indicator collector after the change. subservices to realize dynamic scaling and service allocation.
It improves the stability and high availability of service metric data collection, avoids the problem of load information collection caused by the service not being allocated to the metric collector, and improves the effective utilization rate of each metric collector.
Smart Images

Figure CN119149219A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a service allocation method, apparatus, device, storage medium and computer program product. Background Art
[0002] In a distributed system, some indicator collectors and the services loaded by the indicator collectors are usually deployed. Each indicator collector is responsible for collecting some data of the assigned service. For example, the indicator collector will collect the system resources occupied by the service (such as CPU occupancy) in order to perform real-time data analysis. In actual applications, the effective number of indicator collectors may change. For example, if one or some indicator collectors fail and become unavailable, the services in the distributed system will be affected. For example, some services may not have corresponding indicator collectors, which will affect the load information collection of these services. Summary of the invention
[0003] Based on this, it is necessary to provide a service allocation method, device, equipment, storage medium and computer program product to address the above technical problems, which can help improve the stability and high availability of indicator data collection for services.
[0004] In a first aspect, the present application provides a service allocation method, the method comprising:
[0005] In response to a change in the number of indicator collectors in the distributed system, calculating average load usage information of the distributed system;
[0006] If the difference between the load usage information of the indicator collector and the average load usage information meets the splitting condition, splitting the service loaded by the indicator collector according to the average load usage information;
[0007] The sub-services obtained by splitting are distributed in the changed indicator collector.
[0008] In a second aspect, the present application further provides a service allocation device, the device comprising:
[0009] A calculation module, configured to calculate average load usage information of the distributed system in response to a change in the number of indicator collectors in the distributed system;
[0010] A splitting module, configured to split the service loaded by the indicator collector according to the average load usage information if the difference between the load usage information of the indicator collector and the average load usage information meets a splitting condition;
[0011] The allocation module is used to allocate the split sub-services in the changed indicator collector.
[0012] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the above service allocation method are implemented.
[0013] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above service allocation method are implemented.
[0014] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the above service allocation method are implemented.
[0015] The above-mentioned service allocation method, apparatus, computer equipment, storage medium and computer program product respond to the change in the number of indicator collectors in the distributed system and calculate the average load usage information of the distributed system; if the difference between the load usage information of the indicator collector and the average load usage information meets the splitting condition, the service loaded by the indicator collector is split according to the average load usage information, and the sub-services obtained by the split are allocated in the indicator collector after the change. In addition to ensuring that the allocated indicator collector can ensure normal load, it also realizes the dynamic allocation of services when the distributed system is dynamically expanded or reduced, improves the flexibility of service allocation in the distributed system, and is conducive to improving the stability and high availability of indicator data collection for services, avoiding the problem of service load information not being able to be collected due to the service not being allocated to the indicator collector; in addition, based on the above-mentioned allocation method, the effective utilization rate of each indicator collector can also be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 An application environment diagram of a service allocation method in an embodiment;
[0017] Figure 2 A schematic diagram of a flow chart of a service allocation method in one embodiment;
[0018] Figure 3 A schematic diagram of the architecture of a service allocation method in one embodiment;
[0019] Figure 4 A schematic diagram of the internal structure of a scheduling service in one embodiment;
[0020] Figure 5 A schematic diagram of the internal structure of a collection service in one embodiment;
[0021] Figure 6A schematic diagram of a process of service allocation when an indicator collector is changed in one embodiment;
[0022] Figure 7 A schematic diagram of a flow chart of updating a load utilization rate when a service changes in one embodiment;
[0023] Figure 8 It is a structural block diagram of a service allocation device in one embodiment;
[0024] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0026] It should be noted that in the following description, the terms "first, second and third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first, second and third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0027] See also Figure 1 , Figure 1 A schematic diagram of an application environment of the service allocation method provided in the embodiment of the present application is shown. As an implementation mode, the service allocation method provided in the embodiment of the present application can be executed by the server 110 or the terminal device 120. Among them, the server 110 can be connected to the terminal device 120 through a network, and the network is used to provide a medium for a communication link between the server 110 and the terminal device 120. The network can include various connection types, such as a wired communication link, a wireless communication link, etc., which is not limited in the embodiment of the present application.
[0028] It should be understood that Figure 1 The server 110, network and terminal device 120 in the figure are only for illustration. Any number of servers, networks and terminal devices may be provided according to implementation requirements.
[0029] Exemplarily, the terminal device 120 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart watch, an Internet of Things device, a portable wearable device, etc.
[0030] The server 110 may be a physical server or a server cluster composed of multiple servers. The server 110 may deploy a collection service program and a scheduling service program, so that the index data of the service (such as software service) may be collected according to actual needs. In addition, when the index collector changes (such as adding or deleting an index collector), the configured service may be dynamically reallocated. It is understood that the embodiments of the present application may also allow multiple terminal devices 120 to access the server 110 at the same time.
[0031] In the application scenario of distributed systems, some indicator collectors and services are usually deployed. Each indicator collector will load multiple services, that is, each indicator collector will be responsible for collecting indicator data of the assigned services (including operating systems, application services, and other data services or product services), such as system resource information occupied by application services (such as CPU and memory occupancy), and then store these indicator data in corresponding storage media, such as ES (Elasticsearch) clusters, Prometheus databases, or other time series databases (TSDB, Lindorm TimeSeries Database), so as to read indicator data from them in real time for data analysis. However, in actual applications, the effective number of indicator collectors may change. For example, if one or some indicator collectors fail, some services may not have suitable indicator collectors, thereby affecting the efficiency of indicator data collection for services. Among them, the Prometheus database is a time series database in the monitoring system.
[0032] In the face of the above problems, the present application responds to the change in the number of indicator collectors in the distributed system, calculates the average load usage information of the distributed system; if the difference between the load usage information of the indicator collector and the average load usage information meets the splitting condition, the service loaded by the indicator collector is split according to the average load usage information; and the sub-services obtained by the split are allocated in the indicator collector after the change. For example, when one or some indicator collectors (let's assume that indicator collector 1) fails and becomes unavailable, it will first determine whether the service needs to be split. If splitting is necessary, such as splitting the service loaded by indicator collector 1, the sub-services obtained by the split will be allocated to other indicator collectors respectively, thereby realizing the dynamic allocation of services when the distributed system is dynamically expanded or reduced, thereby ensuring the high availability of the indicator collector for data collection.
[0033] In one embodiment, Figure 2 As shown, a service allocation method is provided, which can be executed by a computer device, and the computer device can be a terminal or a server. Figure 2The service allocation method is composed of Figure 1 The server execution in is taken as an example to illustrate, including the following steps:
[0034] S202, in response to the change in the number of indicator collectors in the distributed system, calculate the average load usage information of the distributed system.
[0035] Among them, the change in the number of indicator collectors may refer to the addition of at least one indicator collector in the distributed system (i.e., the addition of at least one new indicator collector), or the deletion of at least one indicator collector, or the failure of at least one indicator collector and the inability to use it. It should be pointed out that, for the case of a newly added indicator collector, it may refer to the first addition of a new indicator collector in the distributed system, i.e., there was no indicator collector in the distributed system originally, and it is the first time that a new indicator collector is added; in addition, it may also refer to the non-first addition of a new indicator collector, i.e., there was an indicator collector in the distributed system originally, and a new indicator collector is added on the basis of the original one.
[0036] The indicator collector can be a collector used to collect indicator data for the loaded (i.e., allocated) service, and can also be called an indicator collection instance. For example, the indicator collector can be a Metricbeat instance, which is a lightweight indicator collector used to collect indicator data for the operating system, application services, and other services, such as collecting the CPU and memory usage of the operating system during operation. After each startup, the indicator collector will automatically register with the scheduling service and sense the health status of the indicator collector through heartbeat sensing, such as Figure 3 In addition, each indicator collector provides a configuration change notification interface, through which the allocation result can be notified to the allocated indicator collector.
[0037] It should be noted that the service loaded by the indicator collector can be one or more specific types of services loaded by the indicator collector, such as operating systems, application services, and other data services or product services. The product service can also be called a service product, which can be a product cluster (i.e., a set of product clusters), such as an indicator collector can collect multiple Kafka clusters. In addition, for different types of product services, the maximum number of indicators loaded by the indicator collector (i.e., the maximum configuration amount or maximum load amount that the indicator collector can collect) may be different, such as a single indicator collector can collect up to 500 Kafka clusters, 600 Zookeeper clusters (referred to as ZK clusters) or 400 Elasticsearch clusters (referred to as ES clusters). For the same type of product services, the maximum number of indicators loaded by the indicator collector can be the same, such as for Kafka clusters, the maximum number that indicator collector 1 and indicator collector 2 can collect is 500.
[0038] In addition, the product service can be not only the above-mentioned product cluster, but also at least one of other software products, software systems or hardware products. Among them, the software product can be social software, shopping software, map software and other software; the hardware product can be a server responsible for processing various services.
[0039] The load usage information is used to reflect the load occupancy of the indicator collector during load service, such as the load usage information can be the load quantity and / or load rate of the indicator collector during load service. Among them, the load usage rate can be calculated based on the maximum configuration quantity and actual configuration quantity (i.e., the actual load quantity) of the indicator collector.
[0040] For example, taking the indicator collector as a Metricbeat instance, when the Metricbeat instance collects load ES clusters, the load usage information may be the number of ES clusters loaded on the Metricbeat instance, or the ratio between the number and the maximum configuration amount of the Metricbeat instance regarding the ES cluster.
[0041] It should be noted that the indicator collector is used to collect indicator data for one or more services, so it can be said that the one or more services are the load of the indicator collector, or the indicator collector loads the one or more services. In other words, the service loaded by the indicator collector can be the service for which the indicator collector is responsible for collecting indicator data, that is, the indicator data of the service is collected by the indicator collector.
[0042] The average load usage information is calculated based on the total number of indicator collectors after the change (ie, the total number of indicator collectors after the change) and the load usage information, and may be the average load quantity and / or the average load usage rate.
[0043] In one embodiment, before S202, the server may also deploy multiple indicator collectors in a distributed system, such as deploying n indicator collectors, which may form a clustered whole, where n is a positive integer greater than or equal to 2. In the present application, by deploying a distributed multi-instance (i.e., multiple indicator collectors) to a single collection service that originally runs independently, the collection service can be highly available.
[0044] After the indicator collector is deployed, the server can also register the node information of the indicator collector with the scheduling service after the indicator collector is started, so that when the number of indicator collectors in the distributed system changes, it can be perceived in time. Figure 4As shown, after the server starts the indicator collector, the registration center module registers the node information of the indicator collector into the scheduling service, so that if a certain indicator collector in the distributed system fails, it can be detected in time through the heartbeat detection module, so the health status of the indicator collector can be determined. Among them, the failure of the indicator collector will cause the effective number of indicator collectors in the distributed system to change.
[0045] After completing the registration, the server can also receive external collection configuration information, which includes the collection frequency, service type, service connection information, and indicator type of the indicator collector, and then persist the collection configuration information. Figure 4 As shown, the server can receive external collection configuration information through the change perception module, so that it can perceive which product clusters and indicator data need to be collected, and then store the collection configuration information in the database through the persistence module; in addition, the collection configuration information can also be sent to the collection service through the scheduling module, so that the collection service can collect indicator data through the indicator collector.
[0046] In one embodiment, when the server senses that the number of indicator collectors in the distributed system has changed, such as one or more indicator collectors have failed, or a new indicator collector has been added to the distributed system, it will reallocate the configured services, such as the scheduling strategy module using the method of the present application to allocate the configured services. For example, when sensing that a new indicator collector has been added to the distributed system, Figure 4 The scheduling strategy module in determines the allocation of product clusters (such as ES clusters) using the target allocation strategy.
[0047] For the collection of indicator data, the server may first obtain the collection configuration information, parse the collection configuration information, and obtain the parsed collection configuration information; and collect the indicator data according to the parsed collection configuration information. Figure 5 As shown, the server can receive the collection configuration information sent by the scheduling module, and then parse the collection configuration information through the collection configuration parsing module, so that the data collection module (i.e., the indicator collector) uses the parsed collection configuration information to collect indicator data for the ES cluster and obtain the indicator data of the ES cluster; in addition, after obtaining the indicator data, the indicator data can also be processed by the collection data processing module, such as converting the data format or other processing, and then the processed indicator data is output through the collection data output module.
[0048] In one embodiment, when calculating the average usage information, the server may first determine the load usage information of the initial indicator collector in the distributed system, and then respond to the change in the number of indicator collectors in the distributed system, and calculate the average load usage information of the distributed system according to the total number of indicator collectors after the change and the load usage information of the initial indicator collector. The initial indicator collector may refer to the indicator collector before the number of indicator collectors in the distributed system changes.
[0049] For the collection of load usage information, the server can obtain the load usage information of each initial indicator collector in the distributed system from the database in response to the indicator collector change event. It should be noted that the load usage information at this time can be the load usage information before the indicator collector changes. Alternatively, the server periodically obtains the load usage information of each initial indicator collector in the distributed system from the database.
[0050] In one embodiment, the server senses the health status of the indicator collector by heartbeat sensing, and determines whether the indicator collector in the distributed system has changed according to the health status. For example, if an indicator collector fails, the server senses the health status of the indicator collector by heartbeat sensing, and determines that the indicator collector fails according to the health status, so the total number of indicator collectors in the distributed system (i.e., the effective number) has changed.
[0051] In addition, when the server senses the health status of the indicator collector through the heartbeat sensing method, it determines whether the indicator collector in the distributed system has changed according to the total number of the sensed indicator collectors. For example, the server sensed that 10 indicator collectors were in a normal and healthy state last time, and this time it sensed that 8 indicator collectors were in a normal and healthy state, so it can be determined that an indicator collector in the distributed system has failed.
[0052] In one embodiment, if a new indicator collector is added to the distributed system, the server will determine the average load usage information of the new indicator collector based on the total number and load usage information after the addition.
[0053] For example, before adding a new indicator collector, the load usage information of each indicator collector in the distributed system is as follows:
[0054] Metric Collector 1: The load quantity is 300 ZK clusters, and the corresponding load utilization rate is 50%. In addition, there is also a load of Kafka, and the corresponding load quantity is 100 Kafka clusters, and the load utilization rate is 20%;
[0055] Metric Collector 2: The load quantity is 300 ES clusters and the load utilization rate is 75%.
[0056] If a new indicator collector 3 is added to the distributed system, the average load usage information corresponding to each newly added indicator collector needs to be recalculated, such as average load quantity = (300 + 100 + 300) / 3 = 233, average load utilization rate = (50% + 20% + 75%) / 3 = 48.3%. It should be pointed out that the average load usage information in the above example uses the average load quantity and the average load utilization rate. In actual applications, at least one of the average load quantity or the average load utilization rate can be used.
[0057] In another embodiment, if an indicator collector is deleted in the distributed system, the server will determine the average load usage information corresponding to the remaining indicator collectors according to the total number after the deletion and the load usage information.
[0058] For example, before deleting the indicator collector, the load usage information corresponding to each indicator collector in the distributed system is as follows:
[0059] Metric Collector 1: The load quantity is 300 ZK clusters, and the corresponding load utilization rate is 50%;
[0060] Metric Collector 2: The load quantity is 100 Kafka clusters and the load utilization rate is 20%;
[0061] Metric Collector 3: The load quantity is 300 ZK clusters and the load utilization rate is 75%.
[0062] If indicator collector 1 is deleted from the distributed system, it is necessary to recalculate the average load usage information of the remaining indicator collectors after the deletion, such as the average load quantity = (300+100+300) / 2 = 350, and the average load utilization rate = (50%+20%+75%) / 2 = 72.5%.
[0063] In one embodiment, the server obtains newly added indicator collectors in the distributed system within a preset time period; determines the total number of indicator collectors after the change based on the newly added indicator collectors and the initial indicator collectors; and determines the average load usage information of the distributed system based on the total number and the load usage information.
[0064] For example, in order to avoid the situation where multiple new indicator collectors are added in a short period of time and multiple allocations are made, the server can adopt a delayed scheduling allocation strategy, that is: if the server detects that a new indicator collector is added to the distributed system, it waits for a preset time to complete the addition of all new indicator collectors within the preset time; after the preset time is completed, the total number of indicator collectors after the change is determined based on the newly added indicator collectors and the initial indicator collectors, and the average load usage information of the distributed system is determined based on the total number and the load usage information. Therefore, through the scheme of the above embodiment, the problem of multiple allocations due to multiple new indicator collectors in a short period of time can be effectively avoided, which greatly reduces the amount of calculation and resource consumption.
[0065] S204: If the difference between the load usage information of the indicator collector and the average load usage information meets the splitting condition, the service loaded by the indicator collector is split according to the average load usage information.
[0066] Among them, before the number of heavy indicator collectors of the distributed system changes, the heavy indicator collector of the distributed system can become the initial indicator collector.
[0067] In one embodiment, for each indicator collector in the initial indicator collectors, if the difference between the load usage information and the average load usage information of the indicator collector meets the splitting condition, the server splits the service loaded by the indicator collector according to the average load usage information.
[0068] In one embodiment, the server can first determine the difference between the load usage information and the average load usage information of the indicator collector for each indicator collector in the initial indicator collector. If there is a difference in at least one indicator collector that meets the splitting condition, the service loaded by the at least one indicator collector is split into corresponding sub-services according to the average load usage information.
[0069] The difference between the load usage information and the average load usage information of the at least one indicator collector meets the splitting condition, indicating that the service loaded by the at least one indicator collector can be split.
[0070] The sub-services may be obtained by splitting the services carried by the indicator collector. For example, multiple product clusters carried by the indicator collector may be split into groups or subsets, so that the sub-services in each group or subset may be obtained.
[0071] As an example, considering that a service is a multiple product cluster of one or more specific types loaded by an indicator collector, when adding or deleting an indicator collector, the service loaded by the indicator collector that meets the splitting conditions can be split, such as splitting 300 Kafka clusters into two groups, each with 150 Kafka clusters. It should be pointed out that the splitting can be splitting the same type of service (such as multiple product clusters of the same type) into two or more groups or subsets, thereby obtaining the split sub-services.
[0072] In one embodiment, the server calculates the difference between the load utilization rate of the indicator collector and the average load utilization rate. If the difference meets the splitting condition, the service loaded by at least one indicator collector that meets the splitting condition is split according to the average load utilization rate to obtain corresponding sub-services. Alternatively, the server calculates the difference between the load quantity of the indicator collector and the average load quantity. If the difference meets the splitting condition, the service loaded by at least one indicator collector that meets the splitting condition is split according to the average load quantity to obtain corresponding sub-services. Alternatively, the server makes a judgment by comprehensively considering the difference between each load utilization rate and the difference between each load quantity.
[0073] For example, the above example is further explained. For the case of adding a new indicator collector, since the average load utilization rate = (50% + 20% + 75%) / 3 = 48.3%, the services carried by indicator collector 2 can be split into two groups. The load utilization rates of these two groups are 48.3% and 26.7% respectively, that is, one group is 48.3% of the ZK clusters, and the other group is 26.7% of the ZK clusters. At this time, one group of ZK clusters needs to be allocated to the newly added indicator collector. For the case of deleting an indicator collector, since the average load utilization rate = (50% + 20% + 75%) / 2 = 72.5% does not meet the splitting condition, that is, at this time, the services carried by indicator collectors 1 to 3 do not meet the splitting condition, the services carried by the indicator collectors are not split.
[0074] S206, allocating the sub-services obtained by splitting in the changed indicator collector.
[0075] In one embodiment, if a new indicator collector is added to the distributed system, the server will allocate some of the split sub-services to the new indicator collector; if the distributed system deletes an indicator collector, the server will allocate the sub-services loaded by the deleted indicator collector to the remaining indicator collectors in accordance with the principle of even distribution, and can also allocate them to the remaining indicator collectors in accordance with the principle of minimal change.
[0076] Among them, the uniform distribution principle can refer to relatively uniform distribution according to load usage information. For example, assuming that there are 3 indicator collectors in the distributed system, corresponding to 300 ZK clusters, 100 Kafka clusters and 300 ES clusters, the load utilization rate of 300 ZK clusters is 50%, the load utilization rate of 100 Kafka clusters is 20%, and the load utilization rate of 300 ES clusters is 75%. Therefore, the average load utilization rate is about (50% + 20% + 75%) / 3 = 48.3%. Therefore, the result of using the uniform distribution principle is: 300 ZK clusters (load utilization rate is 50%) are allocated to indicator collector 1, 193 ES clusters (load utilization rate is 48.3%) are allocated to indicator collector 2, and 100 Kafka clusters (load utilization rate is 20%) and 107 ES clusters (load utilization rate is 26.7%) are allocated to indicator collector 3.
[0077] The minimum change principle can be that one or more indicator collectors are adjusted this time, and when allocating, sub-services are allocated to the indicator collectors adjusted this time as much as possible. For example, if Metricbeat2 and Metricbeat3 of the four Metricbeat instances are changed this time, then Metricbeat1 and Metricbeat4 are not allocated as much as possible, unless the allocation of Metricbeat2 and Metricbeat3 causes the usage rate to exceed 90% (the set alarm load usage rate), then consider allocating to Metricbeat1 and Metricbeat4.
[0078] In one embodiment, the server sends a sub-service allocation notification to the changed indicator collector so that the changed indicator collector can perceive the sub-service allocation result; if there is at least one indicator collector in the changed indicator collector whose load usage information meets the alarm condition, an alarm message is issued.
[0079] For example, after completing the allocation, the server recalculates the load usage information of each indicator collector, and if the load usage rate in the calculated load usage information is greater than or equal to the alarm load usage rate, an alarm message is issued. In addition, if the number of indicator collectors changes because a new indicator collector is added to the distributed system, a sub-service allocation notification is sent to the new indicator collector and the initial indicator collector so that the sub-service allocation results can be perceived.
[0080] As an example, if a new Metricbeat instance (referred to as the new Metricbeat instance) is added to a distributed system, it is necessary to allocate a part of the product cluster carried by the original Metricbeat instance to the new Metricbeat instance. Therefore, based on the load usage information before and after the instance is added, it is determined whether it is necessary to split the multiple product clusters carried by at least one original Metricbeat instance (let's set it as Metricbeat instance 1). If splitting is required, first split the product cluster carried by the Metricbeat instance 1 to obtain the first sub-product cluster and the second sub-product cluster. Then, the first sub-product cluster is kept unchanged on Metricbeat instance 1, and the second sub-product cluster is allocated to the new Metricbeat instance.
[0081] In the above embodiment, in response to the change in the number of indicator collectors in the distributed system, the average load usage information of the distributed system is calculated; if the difference between the load usage information of the indicator collector and the average load usage information meets the splitting condition, the service loaded by the indicator collector is split according to the average load usage information, thereby effectively reducing the granularity of the service, and thus the sub-services obtained by the split are allocated in the indicator collector after the change. In addition to avoiding the allocated indicator collector from ensuring normal load, it also realizes the dynamic allocation of services when the distributed system is dynamically expanded or reduced, improves the flexibility of service allocation in the distributed system, and is conducive to improving the stability and high availability of indicator data collection for services, avoiding the problem of service load information not being able to be collected due to the service not being allocated to the indicator collector; in addition, based on the above allocation method, the effective utilization rate of each indicator collector can also be improved.
[0082] For different changes in the indicator collector in the distributed system, there are certain differences in the allocation method of sub-services. For S208, it can be explained in the following three scenarios:
[0083] Scenario 1: This is not the first time a new indicator collector is added to a distributed cluster.
[0084] In one embodiment, the change in the number of indicator collectors in the distributed system includes adding a new indicator collector to the distributed system, and the indicator collector after the change includes the indicator collector (i.e., the initial indicator collector) and the new indicator collector. Therefore, when allocating subservices, the target subservice in the subservice is allocated to the indicator collector, and the non-target subservice in the subservice is allocated to the new indicator collector; the target subservice refers to any one of the subservices obtained by splitting.
[0085] The target sub-service may be a part of the sub-services obtained by splitting, and the non-target sub-service may be another part of the sub-services obtained by splitting.
[0086] For example, the server keeps the target sub-service in the sub-service loaded on the initial indicator collector, and assigns the non-target sub-service in the sub-service to the new indicator collector. In addition, if the indicator collector to be split has at least two different types of services, at least one type of sub-service obtained from the split can be assigned to the new indicator collector, and the remaining sub-services are retained in the original indicator collector.
[0087] In order to more intuitively understand the allocation process of new indicator collectors that are not added for the first time, combined with Figure 6 The details are as follows:
[0088] S601, determine to add a new indicator collector;
[0089] S6011, determine whether it is the first time to add a new indicator collector;
[0090] S6012: If it is not the first time that a new indicator collector is added, the average load utilization rate is calculated according to the number of new indicator collectors and the load utilization rate of the original indicator collectors;
[0091] S6013, evenly distribute according to the average load utilization rate, and split the services with a load utilization rate exceeding the average during the distribution process to achieve relative balance;
[0092] It should be noted that, during the allocation process, the services loaded by the indicator collectors whose load utilization rate exceeds the average load utilization rate by 10% (ie, load utilization rate = average load utilization rate + 10%) are split. In addition, during the allocation process, the allocation is performed according to the principle of minimum change.
[0093] For example, before adding a new indicator collector, the load usage information corresponding to each indicator collector in the distributed system is as follows:
[0094] Metric Collector 1: The load quantity is 300 ZK clusters, and the corresponding load utilization rate is 50%. In addition, there is also a load of Kafka, and the corresponding load quantity is 100 Kafka clusters, and the load utilization rate is 20%;
[0095] Metric Collector 2: The load quantity is 300 ES clusters and the load utilization rate is 75%.
[0096] If a new indicator collector 3 is added to the distributed system, it is necessary to recalculate the average load usage information corresponding to each newly added indicator collector, such as average load usage rate = (50% + 20% + 75%) / 3 = 48.3%. Obviously, the load usage rate of the indicator collector 75% is greater than the average load rate 48.3% + 10%. Therefore, the ES cluster loaded by the indicator collector 2 meets the splitting condition, and these ES clusters are split into two groups. The load usage rates of these two groups are 48.3% and 26.7%, that is, one group is 48.3% of the ES cluster, and the other group is 26.7% of the ES cluster. Therefore, the 48.3% ES cluster continues to be retained in the indicator collector 1, and the 26.7% ES cluster is allocated to the indicator collector 3. In addition, considering that the indicator collector 1 is loaded with two different types of services and the load usage rate is high, the kafka cluster with a load usage rate of 20% can also be allocated to the indicator collector 3. Therefore, the load situation of each indicator collector after allocation is as follows:
[0097] Metric Collector 1: The load quantity is 300 ZK clusters, and the corresponding load utilization rate is 50%;
[0098] Metric Collector 2: The number of loads is 193 ES clusters, and the load utilization rate is 48.3%.
[0099] Metric Collector 3: Loaded with 100 Kafka clusters and a load utilization of 20%; and, loaded with 107 ES clusters and a load utilization of 26.7%.
[0100] In one embodiment, if the difference between the load usage information of the indicator collector and the average load usage information does not meet the splitting condition, an indicator collector that meets the allocation condition is selected from the indicator collectors; and the service loaded by the selected indicator collector is allocated to the new indicator collector.
[0101] Among them, the indicator collector that meets the allocation conditions can be called the indicator collector to be processed, so meeting the allocation conditions can mean that the load of the indicator collector to be processed has at least two different types of services, and the corresponding load usage information is greater than the load usage information of other indicator collectors. When allocating the services carried by the indicator collection to be processed, part of the services carried by the indicator collection to be processed can be allocated to the new indicator collector.
[0102] The part of the services loaded by the indicator collector to be processed may be: at least one type of service among the multiple types of services loaded. For example, assuming that indicator collector 1 is responsible for collecting indicator data for 100 Kafka clusters and 100 ZK clusters, after adding an indicator collector 3, the 100 ZK clusters can be allocated to the indicator collector 3.
[0103] S603, confirming the allocation result;
[0104] S604, detecting whether there is an indicator collector that exceeds the alarm load usage rate after the service is allocated;
[0105] S605, if yes, then perform alarm processing;
[0106] S606, an instance notification is made on the allocation result, so that the indicator collector can perceive the new allocation result.
[0107] Scenario 2: Delete the indicator collector in the distributed cluster.
[0108] In one embodiment, the change in the number of indicator collectors in the distributed system includes deleting an indicator collector from an initial indicator collector in the distributed system, and the indicator collector after the change includes the first indicator collector and the second indicator collector that have not been deleted in the indicator collector. Therefore, when allocating services, if the indicator collector (i.e., the indicator collector whose service is split) is the deleted indicator collector, the sub-services obtained by the split are allocated in the indicator collector after the change; if the indicator collector is the first indicator collector that has not been deleted, the target sub-service in the sub-service is allocated in the first indicator collector, and the non-target sub-service in the sub-service is allocated in the second indicator collector.
[0109] Among them, the indicator collector that meets the splitting condition may be a deleted indicator collector or an undeleted indicator collector. Therefore, if the indicator collector that meets the splitting condition is a deleted indicator collector, the sub-service obtained by splitting is allocated in the changed indicator collector; if the indicator collector that meets the splitting condition is the undeleted first indicator collector, the target sub-service in the sub-service is allocated in the first indicator collector, and the non-target sub-service in the sub-service is allocated in the second indicator collector.
[0110] For example, assuming that the indicator collector that meets the splitting condition is indicator collector 1, if indicator collector 1 is the deleted indicator collector, the sub-services obtained by the splitting are allocated to the remaining indicator collectors. If indicator collector 1 is not the deleted indicator collector, some of the sub-services obtained by the splitting are kept loaded on indicator collector 1, and the other sub-services obtained by the splitting are allocated to other remaining indicator collectors. In addition, the service loaded by the deleted indicator collector will be allocated to at least one indicator collector among the remaining indicator collectors, such as the indicator collector with the smallest load.
[0111] In order to more intuitively understand the allocation process after deleting the indicator collector, combined with Figure 6 The details are as follows:
[0112] S602, sensing the deletion of the indicator collector;
[0113] S6021, after sensing that the indicator collector is deleted, determining whether the indicator collector still exists;
[0114] S6022: If there are any indicator collectors, calculate the average load utilization rate according to the number remaining after the deletion and the initial load utilization rate of the indicator collectors;
[0115] S6023, evenly distribute according to the average load utilization rate, and split the services with a load utilization rate exceeding the average during the distribution process to achieve relative balance;
[0116] It should be noted that, during the allocation process, the services loaded by the indicator collectors whose load utilization rate exceeds the average load utilization rate by 10% (ie, load utilization rate = average load utilization rate + 10%) are split. In addition, during the allocation process, the allocation is performed according to the principle of minimum change.
[0117] S6024: If the indicator collector does not exist, delete the allocation information of the indicator collector and release all services;
[0118] S6025, issuing an abnormal notification indicating that there is no indicator collector currently collecting data;
[0119] For example, before deleting the indicator collector, the load usage information corresponding to each indicator collector in the distributed system is as follows:
[0120] Metric Collector 1: The number of loads is 60 ZK clusters, and the corresponding load utilization rate is 10%;
[0121] Metric Collector 2: The load quantity is 100 Kafka clusters and the load utilization rate is 20%;
[0122] Metric Collector 3: The load quantity is 300 ZK clusters and the load utilization rate is 75%.
[0123] If an indicator collector is deleted from a distributed system, it is necessary to recalculate the average load usage information corresponding to each deleted indicator collector, such as average load usage = (10% + 20% + 75%) / 2 = 52.5%. Obviously, the load usage of indicator collector 3, 75%, is greater than the average load usage of 52.5% + 10%. Therefore, indicator collector 3 meets the splitting condition, that is, indicator collector 3 is an indicator collector that needs to be split for service. At this time, the 300 ZK clusters loaded by indicator collector 3 are split (it can be evenly split or unevenly split). If the deleted indicator collector is indicator collector 3, the two groups of ZK clusters after splitting are respectively allocated to indicator collector 1 and indicator collector 2. If the deleted indicator collector is not indicator collector 3, such as the deleted indicator collector is indicator collector 1, one group of ZK clusters after splitting will continue to be retained in indicator collector 3, and the other group of ZK clusters will be allocated to indicator collector 2.
[0124] In another embodiment, if the difference between the load usage information of the indicator collector and the average load usage information does not meet the splitting condition, and the indicator collector is a deleted indicator collector, the service loaded by the indicator collector is allocated in the changed indicator collector. If the difference between the indicator collectors does not meet the splitting condition, the service loaded by the deleted indicator collector can be allocated to one or more of the remaining indicator collectors.
[0125] For example, before deleting the indicator collector, the load usage information corresponding to each indicator collector in the distributed system is as follows:
[0126] Metric Collector 1: The load quantity is 300 ZK clusters, and the corresponding load utilization rate is 50%;
[0127] Metric Collector 2: The load quantity is 100 Kafka clusters and the load utilization rate is 20%;
[0128] Metric Collector 3: The load quantity is 300 ZK clusters and the load utilization rate is 75%.
[0129] If the indicator collector 1 is deleted from the distributed system, the average load usage information corresponding to each deleted indicator collector needs to be recalculated, such as the average load number = (300 + 100 + 300) / 2 = 350, and the average load utilization rate = (50% + 20% + 75%) / 2 = 72.5%. Obviously, the load utilization rates of the above three indicator collectors are not greater than the average load utilization rate of 72.5% + 10%. Therefore, the services loaded by indicator collectors 1 to 3 do not meet the splitting conditions, and the services loaded by the indicator collectors are not split. Therefore, the 300 ZK clusters loaded by indicator collector 1 can be allocated to indicator collector 2.
[0130] S603, confirming the allocation result;
[0131] S604, detecting whether there is an indicator collector that exceeds the alarm load usage rate after the service is allocated;
[0132] S605, if yes, then perform alarm processing;
[0133] S606, an instance notification is made on the allocation result, so that the indicator collector can perceive the new allocation result.
[0134] Scenario 3: Add a new indicator collector to the distributed cluster for the first time.
[0135] In one embodiment, if an indicator collector is added to the distributed system for the first time, for each indicator collector (ie, the initial indicator collector), the service loaded is determined according to the number of indicator collectors and cluster statistics of the service to be allocated.
[0136] The cluster statistics information can also be called initial load usage information, that is, the load usage information initialized before allocating services. When allocating, it can be determined whether the splitting conditions are met. If the splitting conditions are not met, the allocated services are allocated in the indicator collectors newly added for the first time according to the cluster statistics information; if the splitting conditions are met, the splitting is performed first and then the allocation is performed. The specific allocation method is as follows:
[0137] When a new indicator collector is added to a distributed cluster for the first time, the server obtains the number of the first batch of indicator collectors (i.e., all new indicator collectors added for the first time) and the cluster statistical information of the services to be allocated; based on the number and cluster statistical information, the average load usage information corresponding to the first batch of indicator collectors is determined; if the difference between the cluster statistical information and the average load usage information of the target service in the services to be allocated meets the splitting condition, the target service is split according to the average load usage information to obtain the split sub-services; the split sub-services and other services in the services to be allocated are respectively allocated to the corresponding indicator collectors in the first batch of indicator collectors.
[0138] In order to more intuitively understand the allocation process of adding a new indicator collector for the first time, combined with Figure 6 The details are as follows:
[0139] S601, determine to add a new indicator collector;
[0140] S6011, determine whether it is the first time to add a new indicator collector;
[0141] S6015, if a new indicator collector is added for the first time, the average load utilization rate is calculated according to the number of new indicator collectors and the initial load utilization rate of the service that needs to collect indicator data;
[0142] S6016, evenly distribute according to the average load utilization rate, and split the services with a load utilization rate exceeding the average during the distribution process to achieve relative balance;
[0143] For example, when a new indicator collector is added to a distributed system for the first time, the cluster statistics of the services that need to collect indicator data are obtained. The cluster statistics of these services are:
[0144] ZK cluster: the load quantity is 300 and the load utilization rate is 50%; Kafka cluster: the load quantity is 100 and the load utilization rate is 20%; ES cluster: the load quantity is 300 and the load utilization rate is 75%.
[0145] If three new indicator collectors are added to the distributed system for the first time, the average load usage information (i.e., average load usage information) corresponding to each newly added indicator collector is calculated, such as average load usage rate = (50% + 20% + 75%) / 3 = 48.3%. Since the load usage information of the ES cluster 75% is greater than the average load usage rate 48.3% + 10%, the ES cluster meets the splitting condition, and these ES clusters are split into two groups, and the load usage rates of these two groups are 48.3% and 26.7%, that is, one group is 48.3% of the ES cluster, and the other group is 26.7% of the ES cluster. Therefore, the ZK cluster with a load usage rate of 50% is assigned to indicator collector 1, the ES cluster with a load usage rate of 48.3% is assigned to indicator collector 2, and the ES cluster with a load usage rate of 26.7% and the Kafka cluster with a load usage rate of 20% are assigned to indicator collector 3.
[0146] S603, confirming the allocation result;
[0147] S604, detecting whether there is an indicator collector that exceeds the alarm load usage rate after the service is allocated;
[0148] S605, if yes, then perform alarm processing;
[0149] S606, an instance notification is made on the allocation result, so that the indicator collector can perceive the new allocation result.
[0150] In the above embodiment, in a distributed system, whether a new indicator collector is added or deleted, perception can be achieved, and the service can be split, and then the obtained sub-services are allocated accordingly. Therefore, whether a new indicator collector is added or deleted, dynamic allocation of services in the distributed system can be achieved, ensuring the high availability of the indicator collector for data collection.
[0151] The solution of the above embodiment is to allocate services when the indicator collector changes, and in addition, the allocation and load usage information can be updated when the service changes. Therefore, the server obtains cluster change information; if the cluster change information indicates that the number of services loaded by the target indicator collector in the distributed system has changed, the load usage information of the target indicator collector is updated according to the changed number and the total amount before the change; the target indicator collector includes any indicator collector in the distributed system.
[0152] The cluster change information can also be called service change information (i.e. notification of service changes), which is stored in the queue or ES cluster used to store data. Considering that cluster changes (i.e. service changes) can be deletion of services, change of services (such as migration of services from one indicator collector to another), and addition of services, it can be explained in the following scenarios, as described below:
[0153] Scenario 1: Application scenario of service deletion.
[0154] In one embodiment, if the cluster change information indicates that the first target service loaded by the target indicator collector in the distributed system has been deleted, the server updates the load usage information of the indicator collector according to the deleted quantity and the total amount before the deletion of the first target service.
[0155] The deleted quantity may refer to the deleted quantity of the first target service; the total quantity before deletion may refer to the total quantity before a target service is deleted. For example, if the 300 ES clusters that the indicator collector 1 is responsible for collecting indicator data are reduced by 10 due to some reasons (such as failure), the deleted quantity is 10 and the total quantity before deletion is 300.
[0156] After the server obtains the cluster change information from the queue or ES cluster used to store data, it can also persist the cluster change information to the database. Then, according to the cluster change information, the service and the change content that have changed this time are confirmed, such as adding m Kafka clusters, deleting n ES clusters, and changing k clusters (such as migrating the cluster loaded on indicator collector 1 to indicator collector 2), where m, n and k are positive integers greater than or equal to 0, and m, n and k are not all zero.
[0157] If the cluster change information indicates adding a new cluster, deleting a cluster (i.e. reducing a cluster), or changing a cluster, the server can prioritize the deletion of the cluster, then the change of the cluster, and finally the addition of the cluster. Therefore, after obtaining the cluster change information, the server will prioritize judging whether the services loaded by the target indicator collector in the distributed system have been deleted or changed based on the cluster change information. If so, the load usage information of the target indicator collector will be updated based on the number of deleted services and the total amount before deletion.
[0158] Scenario 2: Application scenario of changing service.
[0159] In one embodiment, if the cluster change information indicates that the first target service in the distributed system is migrated from the first target indicator collector to the second target indicator collector, the server updates the load usage information of the first target indicator collector and the second target indicator collector according to the total service volume and migration quantity of the first target service; the target indicator collector includes the first target indicator collector and the second target indicator collector. The total service volume may refer to the total quantity of the first target service loaded by the first target indicator collector.
[0160] After processing the deletion situation, the server will determine whether there is a service migrated from one indicator collector (i.e., the first target indicator collector) to another indicator collector (i.e., the second target indicator collector) based on the cluster change information. If it is determined that some of the first target services in the distributed system have migrated from the first target indicator collector to the second target indicator collector, the load utilization rate of the first target indicator collector and the load utilization information of the second target indicator collector will be updated based on the total service volume and migration quantity of the first target service loaded by the first target indicator collector.
[0161] Scenario 3: Application scenarios of newly added services, as well as application scenarios of newly added and deleted services.
[0162] In one embodiment, for the application scenario of a new service, if the cluster change information indicates that a new service has been added to the distributed system, an indicator collector for loading the new service is selected based on the load usage information; the new service is allocated in the selected indicator collector; and the load usage information of the selected indicator collector is updated.
[0163] In another embodiment, for the application scenario of adding and deleting services, if the cluster change information indicates that the number of first target services loaded by the target indicator collector in the distributed system has decreased and the number of second target services has increased, then the load usage information of the target indicator collector is updated according to the changed number and the total amount before the change; in the target indicator collector, the indicator collector used to load the second target service is selected according to the load usage information.
[0164] In order to more clearly understand the solution of the above embodiment, Figure 7 Further explanation is as follows:
[0165] S701, obtaining cluster change information;
[0166] For example, cluster change information can be obtained through the change awareness module in the scheduling service.
[0167] S702, persisting cluster change information to a database;
[0168] For example, after obtaining cluster change information, the cluster change information can be persisted to the database through the persistence module in the scheduling service; in addition, the scheduling strategy module can also execute subsequent allocation processes and load utilization rate update processes based on the cluster change information.
[0169] S703, confirming the product cluster that has been changed and the content of the change according to the cluster change information;
[0170] The change content includes at least one of adding a new cluster, deleting a cluster, or changing a cluster.
[0171] S704: Process the newly added cluster, deleted cluster, or changed cluster in order of priority.
[0172] S705, prioritize the deletion of clusters, refer to S706 to S707 for details;
[0173] S706, record the indicator collector that must be changed;
[0174] S707, calculating the load utilization rate after the deletion process;
[0175] S708, then process the cluster change, that is, modify the indicator collector where the product cluster is located, and record the indicator collector that must be changed;
[0176] S709, finally processing the newly added cluster, refer to S705 to S706 for details;
[0177] S710, determining whether the newly added product cluster exists (ie, is distributed in) the distributed system;
[0178] S711, if the newly added product cluster does not exist in any of the product clusters loaded by the indicator collector, the indicator collector that must be changed is allocated to the one with the smallest load utilization rate according to the type with the largest proportion;
[0179] Among them, if there is an indicator collector that must be changed, the newly added product cluster will be preferentially allocated to the indicator collector with the minimum load utilization rate; if there is no indicator collector that must be changed, the newly added product cluster will be allocated to the indicator collector with the minimum load utilization rate.
[0180] S712, if the newly added product cluster exists in all the product clusters loaded by the indicator collector, the indicator collector that must be changed is allocated to the one with the smallest load utilization rate according to the type with the largest proportion;
[0181] S713: If some of the product clusters loaded by the indicator collector have the currently added product cluster, process according to the existing situation;
[0182] S714, calculating a new load utilization rate;
[0183] S715, confirming the allocation result;
[0184] S716, exceeding the alarm load utilization rate;
[0185] S717, perform alarm processing;
[0186] S718, an instance notification is made on the allocation result so that the indicator collector can perceive the new allocation result.
[0187] In the above embodiment, in a distributed system, whether adding a new service, changing a service or deleting a service, it can be perceived, and then the load utilization rate of the indicator collector is dynamically updated according to the actual changes.
[0188] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0189] Based on the same inventive concept, the embodiment of the present application also provides a service allocation device for implementing the service allocation method involved above, and the device is a partial structure of the scheduling service. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more service allocation device embodiments provided below can refer to the limitations of the service allocation method above, and will not be repeated here.
[0190] In one embodiment, Figure 8 As shown, a service allocation device is provided, including: a calculation module 802, a splitting module 804 and an allocation module 806, wherein:
[0191] A calculation module 802, configured to calculate average load usage information of the distributed system in response to a change in the number of indicator collectors in the distributed system;
[0192] A splitting module 804 is configured to split the service loaded by the indicator collector according to the average load usage information if the difference between the load usage information of the indicator collector and the average load usage information meets a splitting condition;
[0193] The allocation module 806 is used to allocate the split sub-services in the changed indicator collector.
[0194] In the above embodiment, in response to the change in the number of indicator collectors in the distributed system, the average load usage information of the distributed system is calculated; if the difference between the load usage information of the indicator collector and the average load usage information meets the splitting condition, the service loaded by the indicator collector is split according to the average load usage information, thereby effectively reducing the granularity of the service, and thus the sub-services obtained by the split are allocated in the indicator collector after the change. In addition to avoiding the allocated indicator collector from ensuring normal load, it also realizes the dynamic allocation of services when the distributed system is dynamically expanded or reduced, improves the flexibility of service allocation in the distributed system, and is conducive to improving the stability and high availability of indicator data collection for services, avoiding the problem of service load information not being able to be collected due to the service not being allocated to the indicator collector; in addition, based on the above allocation method, the effective utilization rate of each indicator collector can also be improved.
[0195] In one embodiment, the change in the number of indicator collectors in the distributed system includes adding a new indicator collector to the distributed system, and the indicator collectors after the change include the indicator collector and the new indicator collector;
[0196] The allocation module 806 is further used to allocate a target subservice among the subservices to the indicator collector, and allocate a non-target subservice among the subservices to the new indicator collector; the target subservice refers to any one of the subservices obtained by splitting.
[0197] In one embodiment, the device further comprises:
[0198] A selection module 808 is used to select an indicator collector that meets the allocation condition from the indicator collectors if the difference between the load usage information of the indicator collector and the average load usage information does not meet the split condition;
[0199] The allocation module 806 is further used to allocate the services loaded by the selected indicator collector to the new indicator collector.
[0200] In one of the embodiments, the calculation module 802 is also used to obtain newly added indicator collectors in the distributed system within a preset time period; determine the total number of indicator collectors after the change based on the newly added indicator collectors and the initial indicator collectors; and determine the average load usage information of the distributed system based on the total number and the load usage information.
[0201] In one embodiment, the change in the number of indicator collectors in the distributed system includes deleting an indicator collector from an initial indicator collector in the distributed system, and the indicator collector after the change includes a first indicator collector and a second indicator collector that are not deleted in the indicator collector;
[0202] The allocation module 806 is also used to allocate the sub-services obtained by splitting in the changed indicator collector if the indicator collector is a deleted indicator collector; if the indicator collector is the first indicator collector that has not been deleted, allocate the target sub-service in the sub-service in the first indicator collector, and allocate the non-target sub-service in the sub-service in the second indicator collector.
[0203] In one embodiment, the allocation module 806 is also used to allocate the service loaded by the indicator collector in the changed indicator collector if the difference between the load usage information and the average load usage information of the indicator collector does not meet the splitting condition and the indicator collector is a deleted indicator collector.
[0204] In one embodiment, for each of the indicator collectors, the loaded service is determined according to the number of indicator collectors and cluster statistical information of the service to be allocated.
[0205] In the above embodiment, in a distributed system, whether a new indicator collector is added or deleted, perception can be achieved, and the service can be split, and then the obtained sub-services are allocated accordingly. Therefore, whether a new indicator collector is added or deleted, dynamic allocation of services in the distributed system can be achieved, ensuring the high availability of the indicator collector for data collection.
[0206] In one embodiment, the device further comprises:
[0207] An acquisition module 810 is used to acquire cluster change information;
[0208] Update module 812 is used to update the load usage information of the target indicator collector according to the changed quantity and the total amount before the change if the cluster change information indicates that the number of services loaded by the target indicator collector in the distributed system has changed; the target indicator collector includes any indicator collector in the distributed system.
[0209] In one embodiment, the device further comprises:
[0210] A selection module 814 is used to select an indicator collector for the newly added service according to the load usage information if the cluster change information indicates that a new service has been added in the distributed system;
[0211] The allocation module 806 is further used to allocate the newly added service in the selected indicator collector;
[0212] The updating module 812 is further used to update the load usage information of the selected indicator collector.
[0213] In one embodiment, the update module 812 is further configured to update the load usage information of the target indicator collector according to the changed quantity and the total amount before the change if the cluster change information indicates that the number of the first target service loaded by the target indicator collector in the distributed system is reduced and the number of the second target service is increased;
[0214] The selection module 814 is further used to select, in the target indicator collector, an indicator collector for loading the second target service according to the load usage information.
[0215] In one embodiment, the update module 812 is also used to update the load usage information of the indicator collector according to the number of deletions and the total amount before deletion of the first target service if the cluster change information indicates that the first target service loaded by the target indicator collector in the distributed system has been deleted.
[0216] In one embodiment, the update module 812 is also used to update the load usage information of the first target indicator collector and the second target indicator collector according to the total service volume and migration quantity of the first target service if the cluster change information indicates that the first target service in the distributed system is migrated from the first target indicator collector to the second target indicator collector; the target indicator collector includes the first target indicator collector and the second target indicator collector.
[0217] In the above embodiment, in a distributed system, whether adding a new service, changing a service or deleting a service, it can be perceived, and then the load utilization rate of the indicator collector is dynamically updated according to the actual changes.
[0218] Each module in the above service distribution device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0219] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a service allocation method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.
[0220] Those skilled in the art will understand that Fig. 9The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0221] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above service allocation method when executing the computer program.
[0222] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned service allocation method are implemented.
[0223] In one embodiment, a computer program product is provided, comprising a computer program, which implements the steps of the above service allocation method when executed by a processor.
[0224] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0225] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0226] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A service allocation method, characterized in that: The method comprises: In response to a change in the number of indicator collectors in the distributed system, calculate average load usage information of the distributed system; If the difference between the load usage information of the indicator collector and the average load usage information meets the splitting condition, splitting the service loaded by the indicator collector according to the average load usage information; The sub-services obtained by splitting are distributed in the changed indicator collector.
2. The method according to claim 1, characterized in that The change in the number of indicator collectors in the distributed system includes adding a new indicator collector to the distributed system, and the indicator collectors after the change include the indicator collector and the new indicator collector; The sub-services obtained by splitting are distributed in the indicator collector after the change, including: The target subservice among the subservices is allocated to the indicator collector, and the non-target subservice among the subservices is allocated to the new indicator collector; the target subservice refers to any one of the subservices obtained by splitting.
3. The method according to claim 2, characterized in that The method further comprises: If the differences between the load usage information of the indicator collector and the average load usage information do not meet the splitting condition, selecting an indicator collector that meets the allocation condition from the indicator collectors; The service loaded by the selected indicator collector is allocated to the new indicator collector.
4. The method according to claim 2, characterized in that: The calculating the average load usage information of the distributed system includes: Obtaining newly added indicator collectors in the distributed system within a preset time period; Determine the total number of indicator collectors after the change according to the newly added indicator collectors and the initial indicator collectors; The average load usage information of the distributed system is determined according to the total number and the load usage information of the initial indicator collector.
5. The method according to claim 1, characterized in that The change in the number of indicator collectors in the distributed system includes deleting an indicator collector from an initial indicator collector in the distributed system, and the indicator collector after the change includes a first indicator collector and a second indicator collector that are not deleted from the indicator collector; The sub-services obtained by splitting are distributed in the indicator collector after the change, including: If the indicator collector is a deleted indicator collector, the sub-services obtained by the splitting are allocated in the changed indicator collector; If the indicator collector is the undeleted first indicator collector, the target sub-service among the sub-services is allocated in the first indicator collector, and the non-target sub-service among the sub-services is allocated in the second indicator collector.
6. The method according to claim 5, characterized in that The method further comprises: If the differences between the load usage information of the indicator collector and the average load usage information do not meet the splitting condition, and the indicator collector is a deleted indicator collector, the services loaded by the indicator collector are allocated in the changed indicator collector.
7. The method according to claim 1, characterized in that For each of the indicator collectors, the loaded service is determined according to the number of the indicator collectors and cluster statistical information of the service to be allocated.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: Get cluster change information; If the cluster change information indicates that the number of services loaded by the target indicator collector in the distributed system has changed, the load usage information of the target indicator collector is updated according to the changed number and the total amount before the change; the target indicator collector includes any indicator collector in the distributed system.
9. The method according to claim 8, characterized in that The method further comprises: If the cluster change information indicates that a new service is added in the distributed system, selecting an indicator collector for loading the new service according to the load usage information; Allocating the newly added service in the selected indicator collector; The load usage information of the selected indicator collector is updated.
10. A service distribution device, characterized in that: The device comprises: A calculation module, configured to calculate average load usage information of the distributed system in response to a change in the number of indicator collectors in the distributed system; A splitting module, configured to split the service loaded by the indicator collector according to the average load usage information if the difference between the load usage information of the indicator collector and the average load usage information meets a splitting condition; The allocation module is used to allocate the split sub-services in the changed indicator collector.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
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 steps of the method according to any one of claims 1 to 9 are implemented.
