Cluster capacity expansion method and device, computer equipment and storage medium
By introducing proxy services into the message middleware system and dynamically adjusting the number of cluster containers, the problems of insufficient resources under peak traffic and waste of resources under low traffic are solved, and resource utilization and message processing efficiency are improved.
Patent Information
- Application Number
- CN202411868007.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-18
AI Technical Summary
In the message middleware system, a large number of servers need to be deployed in peak traffic scenarios to deal with message backlog. However, in the case of low traffic or no messages, the reserved server resources are idle, resulting in low resource utilization and increased operation and maintenance costs.
By introducing proxy services into the elastic component, sending cluster configuration information to it to obtain the current message backlog, and expanding or reducing capacity control of the target cluster based on the backlog metric, ensuring that the dynamic adjustment of resources matches the message processing requirements.
It realizes dynamic adjustment of the number of cluster containers based on the message backlog, improves resource utilization, reduces operation and maintenance costs, and improves message processing efficiency.
Smart Images

Figure CN119847733A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of message processing technology, and in particular to a cluster expansion method, device, computer equipment and storage medium. Background Art
[0002] In modern business systems, message middleware is widely used to implement asynchronous task processing and decouple complex business logic, for example, by listening to third-party messages to synchronize data, or by sending batch messages through scheduled tasks to complete complex business calculations. The asynchronous processing capabilities of message middleware can effectively improve the throughput and stability of the system.
[0003] However, due to the large volatility of message traffic, in actual business, it is necessary to deploy enough servers for peak traffic scenarios to ensure that the message consumption capacity can cope with the backlog problem and avoid the situation where message processing is delayed due to excessive backlog. Although this deployment strategy can ensure the normal operation of the business, when the message volume is low or even no messages, most of the reserved server resources are idle, resulting in low resource utilization and increased business operation and maintenance costs.
[0004] For interface applications, resource allocation can be dynamically adjusted through elastic scaling strategies based on query rate per second, thereby optimizing resource utilization efficiency. However, a large number of message services cannot directly adopt elastic strategies based on query rate per second, resulting in serious resource waste. Therefore, how to improve resource utilization has become an urgent problem to be solved. Summary of the invention
[0005] In view of this, in order to solve the above technical problems or part of the technical problems, the embodiments of the present invention provide a cluster expansion method, apparatus, computer equipment and storage medium.
[0006] In a first aspect, an embodiment of the present invention provides a cluster expansion method, which is applied to an elastic component, and includes:
[0007] When receiving a query request of a target cluster, sending configuration information of the target cluster to the proxy service corresponding to the elastic component, so that the proxy service obtains the current message backlog according to the configuration information, and calculates the backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process;
[0008] receiving the backlog indicator returned by the proxy service;
[0009] The target cluster is expanded and controlled according to the backlog indicator.
[0010] In a possible implementation, the sending the configuration information of the target cluster to the proxy service corresponding to the elastic component includes:
[0011] Acquire a service identifier and a service deployment environment of a target service included in the target cluster from the query request, where the target service is deployed in multiple clusters;
[0012] According to the service identifier and the service deployment environment, obtain the maximum number of containers of the target cluster, the message threshold of each container, the number of deployed containers, the message middleware, the cluster name, the message middleware topic and the consumer group name as the configuration information;
[0013] The configuration information is sent to the proxy service.
[0014] In a possible implementation, the proxy service obtains the current message backlog according to the configuration information, including:
[0015] The proxy service calls a target interface of a message middleware corresponding to the target cluster, and obtains the message backlog from the target interface according to the message middleware, a cluster name, the message middleware topic, and the consumer group name.
[0016] In a possible implementation, calculating the backlog index of the target cluster according to the message backlog includes:
[0017] Polling multiple clusters deployed with the target service in sequence according to the message backlog;
[0018] Determine whether the current polling cluster is the target cluster;
[0019] When the judgment result is no, the current remaining message backlog is greater than zero, and the number of containers of the current polling cluster has not reached the maximum number of containers, the message threshold of the current polling cluster is subtracted from the remaining message backlog to update the current remaining message backlog, and the number of containers of the current polling cluster is increased by one, and polling continues;
[0020] When the target cluster is polled, and the current remaining message backlog is greater than zero, and the number of containers of the target cluster has not reached the maximum number of containers, the number of containers of the target cluster is increased by one to obtain the target number of containers;
[0021] After subtracting the message threshold of the target cluster from the remaining message backlog, continue polling until the remaining message backlog is zero, or the number of target containers is equal to the maximum number of containers of the target cluster, then stop polling;
[0022] The backlog indicator is calculated according to the target number of containers and the message threshold.
[0023] In a possible implementation, calculating the backlog indicator according to the target number of containers and the message threshold includes:
[0024] Calculating a first product of the target number of containers and the message threshold, and calculating a second product of the message threshold and a preset value, where the preset value is less than 1 and greater than 0;
[0025] The backlog indicator is obtained by subtracting the second product from the first product.
[0026] In a possible implementation, the controlling the expansion of the target cluster according to the backlog indicator includes:
[0027] Dividing the backlog indicator by the message threshold to obtain a first container number;
[0028] When the first number of containers is greater than the number of deployed containers, subtract the number of deployed containers from the first number of containers to obtain the number of expanded containers;
[0029] The containers in the target cluster are expanded according to the number of expanded containers.
[0030] In a second aspect, an embodiment of the present invention provides a cluster expansion system for implementing the method described in the first aspect, including: an elastic component, a proxy service, and a message middleware;
[0031] The elastic component is used to send the configuration information of the target cluster to the proxy service when receiving a query request of the target cluster;
[0032] The proxy service is used to obtain the current message backlog from the message middleware according to the configuration information, and calculate the backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process;
[0033] The elastic component is further used to receive the backlog indicator returned by the proxy service, and perform capacity expansion control on the target cluster according to the backlog indicator.
[0034] In a third aspect, an embodiment of the present invention provides a cluster expansion device, including:
[0035] A sending module, configured to, when receiving a query request of a target cluster, send configuration information of the target cluster to a proxy service corresponding to the elastic component, so that the proxy service obtains a current message backlog according to the configuration information, and calculates a backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process;
[0036] A receiving module, used for receiving the backlog indicator returned by the proxy service;
[0037] A control module is used to control the expansion of the target cluster according to the backlog indicator.
[0038] In a fourth aspect, an embodiment of the present invention provides a computer device, comprising: a processor and a memory, wherein the processor is used to execute a cluster expansion program stored in the memory to implement the cluster expansion method described in any one of the first aspects above.
[0039] In a fifth aspect, an embodiment of the present invention provides a storage medium, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the cluster expansion method described in any one of the first aspects above.
[0040] The cluster expansion solution provided by the embodiment of the present invention sends the configuration information of the target cluster to the proxy service corresponding to the elastic component when receiving a query request of the target cluster, so that the proxy service obtains the current message backlog according to the configuration information, and calculates the backlog index of the target cluster according to the message backlog, and the backlog index represents the amount of messages that the target cluster currently needs to process; receives the backlog index returned by the proxy service; and controls the expansion of the target cluster according to the backlog index. In this way, the cluster can be expanded and controlled according to the message backlog and the backlog index calculated by the proxy service, and the number of containers in the cluster can be flexibly adjusted to improve the resource utilization of the message service. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of a flow chart of a cluster expansion method provided in an embodiment of the present invention;
[0042] Figure 2 A schematic diagram of a flow chart of another cluster expansion method provided in an embodiment of the present invention;
[0043] Figure 3 A schematic diagram of the structure of a cluster expansion system provided by an embodiment of the present invention;
[0044] Figure 4 A schematic diagram of the structure of a cluster expansion device provided by an embodiment of the present invention;
[0045] Figure 5 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] To facilitate understanding of the embodiments of the present invention, specific embodiments will be further explained below in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.
[0048] Figure 1 A schematic diagram of a cluster expansion method provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method specifically includes:
[0049] S11. When receiving a query request of a target cluster, sending configuration information of the target cluster to the proxy service corresponding to the elastic component, so that the proxy service obtains the current message backlog according to the configuration information, and calculates the backlog index of the target cluster according to the message backlog.
[0050] The message expansion method provided in the embodiment of the present invention is applied to the elastic component in the computer device, which may include but is not limited to: a server, a desktop computer, a tablet computer, etc. The elastic component may be the elastic component KEDA (Kubernetes Event-driven Autoscaling) in Kubernetes (K8S). Kubernetes is a system for automatically deploying, scaling and managing containerized applications. KEDA is an open source elastic scaling component of Kubernetes, which is specially designed for event-driven applications and can dynamically adjust the number of Pod copies according to the load of the external event source. Specifically, the expansion control of the containers in the cluster can be performed according to the message backlog in the cluster and the backlog index calculated by the proxy service corresponding to the cluster.
[0051] In this embodiment, a proxy service is pre-set, and the proxy service plays a scheduling role. It can calculate the backlog index that represents the amount of messages that the target cluster currently needs to process. The elastic component can call the interface of the proxy service to obtain the backlog index, and calculate the number of containers that need to be deployed in the target cluster according to the backlog index, thereby scaling the number of containers. The proxy service can calculate the backlog index by calling the interface of the message middleware and reading the message backlog of the queue message.
[0052] Specifically, the target service is usually deployed in multiple clusters, and each cluster periodically sends query instructions to the elastic component to query whether capacity expansion is currently required and the backlog indicator of the number of containers currently used to calculate the capacity expansion.
[0053] The elastic component can send configuration information to the proxy service after obtaining the configuration information, updating the configuration information, or receiving the query request. The configuration information can be the elastic configuration that the user has pre-configured on the page. The configuration information is used to obtain the message backlog, calculate the backlog index, and control the expansion. It may include but is not limited to: cluster name (clusterName), message middleware (ROCKETMQ), service area (zone), Topic name of the message queue; Consumer Group (Consumer Group, cg), container message threshold (the message threshold of each container in a cluster is the same), maximum number of containers, number of deployed containers, maximum number of replicas and minimum number of replicas, etc. If the service is deployed in multiple clusters, multiple sets of configuration information can be configured for each cluster. After the configuration is completed, since the components in k8s are defined in the form of resources, the configuration information is converted into k8s resources (KEDA resource) and deployed to the corresponding k8s cluster.
[0054] After receiving the configuration information, the proxy service calls the ROCKETMQ OPENAI interface of the message middleware and obtains the message backlog (totalDiff) from the message middleware according to clusterName, topic, and cg. The message backlog represents the total number of messages that have not been consumed by consumers, which usually indicates load pressure.
[0055] Furthermore, since the expansion quantity of all clusters deployed by the target service needs to be evenly distributed when expanding, the number of containers required to be expanded in other clusters should be considered when calculating the number of containers for expansion of the target cluster. Therefore, the proxy service will poll multiple clusters in turn according to the message processing order of all clusters based on the current message backlog, and pre-allocate the message backlog. The purpose is to calculate the number of expansions required for each cluster and the amount of messages that need to be processed, thereby accurately deriving the amount of messages that the target cluster needs to process.
[0056] Specifically, during polling, the amount of messages that each cluster needs to process is calculated and a message backlog is allocated to each cluster. Clusters that have not reached the maximum number of containers are allocated containers that need to be added. Polling ends when all message backlogs are calculated and allocated, or when the currently calculated number of target containers required by the target cluster has reached the maximum number of containers. After polling, the amount of messages that the target cluster needs to process in the current message backlog is obtained as the backlog indicator.
[0057] S12, receiving the backlog indicator returned by the proxy service;
[0058] S13. Control the capacity expansion of services in the cluster based on the backlog indicator.
[0059] In this embodiment, after receiving the backlog indicator returned by the proxy service, the elastic component divides the backlog indicator by the message threshold of the container of the current target cluster to obtain the number of containers to be deployed. If the number of containers to be deployed is greater than the number of deployed containers of the target cluster, the number of containers to be deployed is subtracted from the number of deployed containers to obtain the number of containers to be expanded. The containers in the target cluster are increased according to the number of containers to be expanded to achieve expansion, wherein the number of containers after expansion does not exceed the maximum number of containers of the target cluster.
[0060] If the number of containers to be deployed is less than the number of deployed containers in the target cluster, the number of containers to be deployed is subtracted from the number of deployed containers to obtain the number of containers to be scaled down. The number of containers in the target cluster is reduced according to the number of containers to be scaled down to achieve the scale-down. The minimum number of containers after the scale-down is 0.
[0061] As an example, the target service is deployed in three clusters A, B, and C. Cluster B is the target cluster. Every 30 seconds, cluster B sends a query request to the elastic component. The elastic component sends the configuration information of cluster B to the proxy service. The proxy service obtains the current message backlog of 7000 from the message middleware corresponding to the target service according to the configuration information. The proxy service polls clusters A, B, and C in turn. During the polling process, polling starts from the number of containers in each cluster is 0. The number of containers that need to be deployed in each cluster is calculated based on the message threshold and the maximum number of containers of the cluster container. If the maximum number of containers in cluster B is 5 and the message threshold of each container is 100, each time each cluster is polled, if there are still messages, If the backlog is reached and the cluster has not reached the maximum number of containers, the number of containers needs to be increased by 1, and the next cluster is polled after adding 1. The three clusters are polled repeatedly until all message backlogs are allocated or the cluster reaches the maximum number of containers. The number of containers that cluster B needs to deploy is obtained as the target number of containers. The message backlog that cluster B needs to allocate is calculated according to the target number of containers as the backlog indicator, and the backlog indicator is sent to the elastic component to expand or reduce the number of containers in cluster B through the elastic component. When the target number of containers is greater than the number of deployed containers, the containers in cluster B are expanded according to the target number of containers. When the target number of containers is less than the number of deployed containers, the containers in cluster B are reduced according to the target number of containers.
[0062] The cluster expansion solution provided by the embodiment of the present invention sends the configuration information of the target cluster to the proxy service corresponding to the elastic component when receiving a query request of the target cluster, so that the proxy service obtains the current message backlog according to the configuration information, and calculates the backlog index of the target cluster according to the message backlog, and the backlog index represents the amount of messages that the target cluster currently needs to process; receives the backlog index returned by the proxy service; and controls the expansion of the target cluster according to the backlog index. In this way, the cluster can be expanded and controlled according to the message backlog and the backlog index calculated by the proxy service, and the number of containers in the cluster can be flexibly adjusted to improve the resource utilization of the message service.
[0063] Figure 2 A schematic diagram of a flow chart of another cluster expansion method provided by an embodiment of the present invention, such as Figure 2 As shown, the method specifically includes:
[0064] S21. When a query request is received, the service identifier and service deployment environment of the target service contained in the target cluster are obtained from the query request; the maximum number of containers of the target cluster, the message threshold of each container, the number of deployed containers, the message middleware, the cluster name, the message middleware topic and the consumer group name are obtained as configuration information according to the service identifier and the service deployment environment; and the configuration information is sent to the proxy service.
[0065] In this embodiment, the user performs elastic configuration on the page in advance. The items that need to be configured may include but are not limited to: the cluster where the target service is located, the minimum number of copies, the maximum number of copies, the message threshold of the container in each cluster (if exceeding the threshold, one container is added), the maximum number of containers, the number of deployed containers (which can be updated periodically), the message middleware, the cluster name (clusterName), the message middleware topic (Topic), the consumer group name, etc. If the service is deployed in multiple clusters, the above configurations can be configured in multiple sets according to the cluster configuration to obtain multiple configuration information.
[0066] After the configuration is completed, convert the configuration information into resources for deployment. For example, convert the above configuration into KEDA resource of k8s and deploy it to the corresponding k8s cluster. The deployment can be performed as follows:
[0067]
[0068] Oral Access
[0069] metadata:
[0070] targetValue:"2000" / / Message threshold
[0071] url:
[0072] http: / / xxx / i / release / api / 1.0 / app / scale / metrics / rmq-delay? appId=216&env=TES T&zone=HB_BDBDY_C&clusterName=mp-iqiyihao-rocketmq&topic=qiyihao-industry-discrete-message&cg=CG-industry-decide-discrete-message / / Agent service
[0073] valueLocation:"data.test.delayCnt" / / Defines which field of the proxy service interface return value to read the backlog indicator. According to the above resource description, KEDA will call the proxy service interface every 30 seconds to obtain the backlog indicator. The parameters of the proxy service interface mainly include appId, the service id, which identifies the service; env, the deployment environment of the service (official, test); zone, the cluster where the service is deployed; clusterName, the ROCKETMQ cluster name, Topic; cg, the consumer group, etc.
[0074] Furthermore, the elastic component receives a query request sent by the target cluster to query whether it is necessary to expand or shrink the capacity at present. The query request contains the service identifier (e.g., appId) and service deployment environment (env, e.g., formal, test) of the target service deployed in the target cluster. The service identifier and the service deployment environment are pre-set with the elastic configuration. The elastic configuration corresponding to the service identifier and the service deployment environment is obtained from the corresponding relationship. The obtained content may include: the maximum number of containers, the message threshold of each container (the message threshold of each container in a cluster is the same), the number of deployed containers, the message middleware, the cluster name, the message middleware topic and the consumer group name as configuration information; the configuration information is sent to the proxy service.
[0075] S22, so that the proxy service calls the target interface of the message middleware corresponding to the target cluster, and obtains the message backlog from the target interface according to the message middleware, cluster name, message middleware topic and consumer group name.
[0076] In this embodiment, the proxy service calls the message middleware interface (ROCKETMQ OPENAI), according to the message middleware, cluster name (clusterName), message middleware topic (topic),
[0077] S23, enabling the proxy service to poll multiple clusters deployed by the target service in sequence according to the message backlog; and determining whether the currently polled cluster is the target cluster;
[0078] S24. When the judgment result is no, the current remaining message backlog is greater than zero, and the number of containers of the current polling cluster has not reached the maximum number of containers, the remaining message backlog is subtracted from the message threshold of the current polling cluster to update the current remaining message backlog, and the number of containers of the current polling cluster is increased by one, and polling continues.
[0079] In this embodiment, after the proxy service receives the message backlog, it polls the clusters in sequence according to the message processing order of multiple clusters corresponding to the target service. During the polling process, the message backlog is pre-allocated to calculate the amount of messages that each cluster needs to process. The specific polling process is to start polling with the number of containers in each cluster as zero, and allocate containers to each cluster respectively. Each cluster increases the number of containers by at most one during each polling, and subtracts the message threshold of the cluster from the message backlog to update the message backlog, so as to obtain the current remaining message backlog, and poll the next cluster after adding the container.
[0080] Each time you poll, first determine whether the current cluster is the target cluster. If it is not the target cluster and the current remaining message backlog is greater than zero, determine whether the number of containers allocated to the current polling cluster has reached the maximum number of containers. If not, increase the number of containers in the current cluster by one (or determine the maximum number of containers in the current cluster minus one), subtract the current remaining message backlog from the current message threshold to update the current remaining message backlog, and continue polling. If the number of containers allocated to the currently polled cluster has reached the maximum number of containers in the cluster, skip the cluster and poll the next cluster in sequence.
[0081] S25. When the target cluster is polled, and the current remaining message backlog is greater than zero, and the number of containers of the target cluster has not reached the maximum number of containers, the number of containers of the target cluster is increased by one to obtain the target number of containers;
[0082] S26. After subtracting the message threshold of the target cluster from the remaining message backlog, continue polling until the remaining message backlog is zero, or the number of target containers is equal to the maximum number of containers of the target cluster, and then stop polling.
[0083] In this embodiment, whenever the target cluster is polled, it is determined whether the current remaining message backlog is greater than zero. When it is greater than zero and the number of currently allocated containers of the target cluster has not reached the maximum number of containers, it means that the target cluster can still be expanded to process the backlogged messages. At this time, the number of containers of the current target cluster is determined to be plus one, which is used as the target container number. Then, the current remaining message backlog is subtracted from the message threshold of the target cluster to update the remaining message backlog, and other clusters are polled until the remaining message backlog is zero, indicating that it has been allocated. Polling is terminated to obtain the current target container number. Or, when the target container number of the target cluster has currently increased to equal the maximum number of containers of the target cluster, polling is terminated.
[0084] S27. Calculate the backlog index according to the target container number and the message threshold.
[0085] In this embodiment, a backlog index is calculated according to a preset formula based on the message threshold and the calculated target container number. The backlog index can represent the amount of messages that the target cluster currently needs to process.
[0086] Specifically, a first product of the target container number and the message threshold is calculated, and a second product of the message threshold and a preset value is calculated, where the preset value is less than 1 and greater than 0; the second product is subtracted from the first product to obtain the backlog index.
[0087] As an example, calculate the target number of containers that should be deployed in the zone cluster (target cluster, denoted by B later) in the query request, and poll the elastic configuration of each cluster corresponding to the target service in turn. The prerequisite for polling is that the current remaining message backlog is > 0. The cluster currently polled is represented by variable A. When the number of containers in cluster A has reached the maximum number of containers, cluster A is skipped and other clusters are polled.
[0088] When the maximum number of containers is not reached, the remaining message backlog (totalDiff) minus the message threshold of the cluster, the number of containers allocated to cluster A plus 1, or the maximum number of containers in cluster A minus 1; if A is not B, continue the round-robin training; if A is B, the number of containers allocated to cluster B is +1 to obtain the target number of containers for cluster B; if the number of containers in B reaches the maximum number of containers, or the remaining message backlog is zero (the message backlog has been fully allocated), return; otherwise, continue the round-robin training.
[0089] The number of containers allocated to cluster B is converted into a message backlog indicator using the formula: backlog indicator = (target number of containers in cluster B * message threshold - message threshold * 0.5). The message threshold * 0.5 is subtracted because the threshold is reached when capacity is expanded, which will result in one more expansion.
[0090] S28. Divide the backlog indicator by the message threshold to obtain the first container number; when the first container number is greater than the deployed container number, subtract the deployed container number from the first container number to obtain the expanded container number; and expand the container in the target cluster according to the expanded container number.
[0091] In this embodiment, the elastic component receives a backlog indicator, uses the message threshold of the backlog indicator in the target cluster to obtain the first number of containers that need to be deployed, obtains the number of deployed containers of the target cluster, and when the first number of containers is greater than the number of deployed containers, the target cluster needs to be expanded, and the number of deployed containers is subtracted from the first number of containers to obtain the number of expanded containers; the containers of the target cluster are increased according to the number of expanded containers, and the number of increased containers does not exceed the maximum number of containers; when the first number of containers is less than the number of deployed containers, the target cluster needs to be reduced, and the number of deployed containers is subtracted from the first number of containers to obtain the number of reduced containers; the containers of the target cluster are reduced according to the number of reduced containers, and the minimum number of containers after reduction is zero, and when the first number of containers is equal to the number of deployed containers, the current number of containers is maintained.
[0092] The cluster expansion method provided in an embodiment of the present invention uses the message backlog and the message threshold of the cluster container through a proxy service to calculate the number of containers deployed in the current target cluster, and converts it into a backlog indicator and sends it to the elastic component, so that the elastic component can expand or reduce the current number of containers in the target cluster, thereby improving the utilization rate of container resources in the cluster, avoiding message backlogs, and improving message processing efficiency.
[0093] Figure 3 A schematic diagram of a cluster expansion system provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the system specifically includes:
[0094] Elastic components ( Figure 3 KEDA in), agency services ( Figure 3 Efficiency Platform) and Message Middleware ( Figure 3 MQOpen API in MQOpen API);
[0095] The elastic component is used to send the configuration information of the target cluster to the proxy service when receiving a query request of the target cluster;
[0096] The proxy service is used to obtain the current message backlog from the message middleware according to the configuration information, and calculate the backlog index of the target cluster based on the message backlog. The backlog index represents the amount of messages that the target cluster currently needs to process.
[0097] The elasticity component is also used to receive the backlog indicator returned by the proxy service and control the expansion of the target cluster based on the backlog indicator.
[0098] Figure 3KEDA is an elastic component, ScaledObjects is KEDA resource, which is the k8s (Kubernetes system) resource corresponding to KEDA, Api Server (interface service) is the k8s cluster operation entrance, responsible for the authentication and authorization of Kubernetes resources, verification, and resource addition, deletion, modification, and query operations, providing RESTful APIs for other components to call, HPA (HorizontalPodAutoscaler) is the native service horizontal scaling (elastic) resource (component) of k8s, used for capacity expansion and contraction control, the work efficiency platform is the proxy service, OPENAPI is an interface definition specification, ZoneA, ZoneB, and ZoneC are clusters deployed by the target service, Pod is the smallest deployable computing unit created and managed in Kubernetes, and is simply understood as a service, Service: represents the entire service, composed of multiple pods, Metrics Adapter ControllerMetrics Api Scaller is the internal implementation of KEDA open source components, Metrics Adapter is responsible for docking with HPA, Metrics API Scaler is ScaledObjects, which is one type of ScaledObjects. It means obtaining indicators from the interface, corresponding to type:metrics-api in the yaml file. Controller is the KEDA controller, which is used to monitor KEDAresource, listen to the latest status of resource yaml and make actual adjustments.
[0099] Figure 4 A schematic diagram of a cluster expansion device provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the device specifically includes:
[0100] The sending module 41 is used for sending the configuration information of the target cluster to the proxy service corresponding to the elastic component when receiving the query request of the target cluster, so that the proxy service obtains the current message backlog according to the configuration information, and calculates the backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process;
[0101] A receiving module 42, configured to receive the backlog indicator returned by the proxy service;
[0102] The control module 43 is used to control the expansion of the target cluster according to the backlog indicator.
[0103] In a possible implementation, the sending module is specifically configured to obtain a service identifier and a service deployment environment of a target service included in the target cluster from the query request, wherein the target service is deployed in multiple clusters;
[0104] According to the service identifier and the service deployment environment, obtain the maximum number of containers of the target cluster, the message threshold of each container, the number of deployed containers, the message middleware, the cluster name, the message middleware topic and the consumer group name as the configuration information;
[0105] The configuration information is sent to the proxy service.
[0106] In a possible implementation, enabling the proxy service to obtain the current message backlog according to the configuration information includes:
[0107] The proxy service calls a target interface of a message middleware corresponding to the target cluster, and obtains the message backlog from the target interface according to the message middleware, a cluster name, the message middleware topic, and the consumer group name.
[0108] In a possible implementation, the proxy service calculates the backlog index of the target cluster according to the message backlog, including:
[0109] Polling multiple clusters deployed with the target service in sequence according to the message backlog;
[0110] Determine whether the current polling cluster is the target cluster;
[0111] When the judgment result is no, the current remaining message backlog is greater than zero, and the number of containers of the current polling cluster has not reached the maximum number of containers, the message threshold of the current polling cluster is subtracted from the remaining message backlog to update the current remaining message backlog, and the number of containers of the current polling cluster is increased by one, and polling continues;
[0112] When the target cluster is polled, and the current remaining message backlog is greater than zero, and the number of containers of the target cluster has not reached the maximum number of containers, the number of containers of the target cluster is increased by one to obtain the target number of containers;
[0113] After subtracting the message threshold of the target cluster from the remaining message backlog, continue polling until the remaining message backlog is zero, or the number of target containers is equal to the maximum number of containers of the target cluster, then stop polling;
[0114] The backlog indicator is calculated according to the target number of containers and the message threshold.
[0115] The calculating the backlog indicator according to the target number of containers and the message threshold includes:
[0116] Calculating a first product of the target number of containers and the message threshold, and calculating a second product of the message threshold and a preset value, where the preset value is less than 1 and greater than 0;
[0117] The backlog indicator is obtained by subtracting the second product from the first product.
[0118] In a possible implementation manner, the control module is specifically configured to divide the backlog indicator by the message threshold to obtain a first container number;
[0119] When the first number of containers is greater than the number of deployed containers, subtract the number of deployed containers from the first number of containers to obtain the number of expanded containers;
[0120] The containers in the target cluster are expanded according to the number of expanded containers.
[0121] The cluster expansion device provided in this embodiment may be as follows: Figure 4 The device shown in FIG. 1 can perform the following steps: Figure 1-2 All steps of the cluster expansion method in order to achieve Figure 1-2 The technical effect of the cluster expansion method shown in the figure is as follows. Figure 1-2 For the sake of brevity, the relevant description is not repeated here.
[0122] Figure 5 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention, Figure 5 The computer device 500 shown includes: at least one processor 501, a memory 502, at least one network interface 504 and other user interfaces 503. The various components in the computer device 500 are coupled together via a bus system 505. It is understood that the bus system 505 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 505 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 505 is not described in detail. Figure 5 Various buses are labeled as bus system 505 .
[0123] The user interface 503 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).
[0124] It can be understood that the memory 502 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DRRAM). The memory 502 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0125] In some implementations, the memory 502 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 5021 and an application program 5022 .
[0126] The operating system 5021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 5022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present invention can be included in the application 5022.
[0127] In the embodiment of the present invention, by calling the program or instruction stored in the memory 502, specifically, the program or instruction stored in the application 5022, the processor 501 is used to execute the method steps provided by each method embodiment, for example, including:
[0128] When receiving a query request of a target cluster, sending configuration information of the target cluster to the proxy service corresponding to the elastic component, so that the proxy service obtains the current message backlog according to the configuration information, and calculates the backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process;
[0129] receiving the backlog indicator returned by the proxy service;
[0130] The target cluster is expanded and controlled according to the backlog indicator.
[0131] In a possible implementation, a service identifier and a service deployment environment of a target service included in the target cluster are obtained from the query request, and the target service is deployed in multiple clusters;
[0132] According to the service identifier and the service deployment environment, obtain the maximum number of containers of the target cluster, the message threshold of each container, the number of deployed containers, the message middleware, the cluster name, the message middleware topic and the consumer group name as the configuration information;
[0133] The configuration information is sent to the proxy service.
[0134] In a possible implementation, the proxy service calls a target interface of a message middleware corresponding to the target cluster, and obtains the message backlog from the target interface according to the message middleware, the cluster name, the message middleware topic, and the consumer group name.
[0135] In a possible implementation, multiple clusters where the target service is deployed are polled in sequence according to the message backlog;
[0136] Determine whether the current polling cluster is the target cluster;
[0137] When the judgment result is no, the current remaining message backlog is greater than zero, and the number of containers of the current polling cluster has not reached the maximum number of containers, the message threshold of the current polling cluster is subtracted from the remaining message backlog to update the current remaining message backlog, and the number of containers of the current polling cluster is increased by one, and polling continues;
[0138] When the target cluster is polled, and the current remaining message backlog is greater than zero, and the number of containers of the target cluster has not reached the maximum number of containers, the number of containers of the target cluster is increased by one to obtain the target number of containers;
[0139] After subtracting the message threshold of the target cluster from the remaining message backlog, continue polling until the remaining message backlog is zero, or the number of target containers is equal to the maximum number of containers of the target cluster, then stop polling;
[0140] The backlog indicator is calculated according to the target number of containers and the message threshold.
[0141] In a possible implementation, a first product of the target number of containers and the message threshold is calculated, and a second product of the message threshold and a preset value is calculated, where the preset value is less than 1 and greater than 0;
[0142] The backlog indicator is obtained by subtracting the second product from the first product.
[0143] In a possible implementation, the backlog indicator is divided by the message threshold to obtain a first container number;
[0144] When the first number of containers is greater than the number of deployed containers, subtract the number of deployed containers from the first number of containers to obtain the number of expanded containers;
[0145] The containers in the target cluster are expanded according to the number of expanded containers.
[0146] The method disclosed in the above embodiment of the present invention can be applied to the processor 501, or implemented by the processor 501. The processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 501 or the instruction in the form of software. The above processor 501 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 502, and the processor 501 reads the information in the memory 502 and completes the steps of the above method in combination with its hardware.
[0147] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0148] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0149] The computer device provided in this embodiment may be as follows Figure 5 The computer device shown in , can execute Figure 1-2 All steps of the cluster expansion method in order to achieve Figure 1-2 The technical effect of the cluster expansion method shown in the figure is as follows. Figure 1-2 For the sake of brevity, the relevant description is not repeated here.
[0150] The embodiment of the present invention also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.
[0151] When one or more programs in the storage medium can be executed by one or more processors, the cluster expansion method executed on the device side can be implemented.
[0152] The processor is used to execute the cluster expansion program stored in the memory to implement the following steps of the cluster expansion method executed on the device side:
[0153] When receiving a query request of a target cluster, sending configuration information of the target cluster to the proxy service corresponding to the elastic component, so that the proxy service obtains the current message backlog according to the configuration information, and calculates the backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process;
[0154] receiving the backlog indicator returned by the proxy service;
[0155] The target cluster is expanded and controlled according to the backlog indicator.
[0156] In a possible implementation, a service identifier and a service deployment environment of a target service included in the target cluster are obtained from the query request, and the target service is deployed in multiple clusters;
[0157] According to the service identifier and the service deployment environment, obtain the maximum number of containers of the target cluster, the message threshold of each container, the number of deployed containers, the message middleware, the cluster name, the message middleware topic and the consumer group name as the configuration information;
[0158] The configuration information is sent to the proxy service.
[0159] In a possible implementation, the proxy service calls a target interface of a message middleware corresponding to the target cluster, and obtains the message backlog from the target interface according to the message middleware, the cluster name, the message middleware topic, and the consumer group name.
[0160] In a possible implementation, multiple clusters where the target service is deployed are polled in sequence according to the message backlog;
[0161] Determine whether the current polling cluster is the target cluster;
[0162] When the judgment result is no, the current remaining message backlog is greater than zero, and the number of containers of the current polling cluster has not reached the maximum number of containers, the message threshold of the current polling cluster is subtracted from the remaining message backlog to update the current remaining message backlog, and the number of containers of the current polling cluster is increased by one, and polling continues;
[0163] When the target cluster is polled, and the current remaining message backlog is greater than zero, and the number of containers of the target cluster has not reached the maximum number of containers, the number of containers of the target cluster is increased by one to obtain the target number of containers;
[0164] After subtracting the message threshold of the target cluster from the remaining message backlog, continue polling until the remaining message backlog is zero, or the number of target containers is equal to the maximum number of containers of the target cluster, then stop polling;
[0165] The backlog indicator is calculated according to the target number of containers and the message threshold.
[0166] In a possible implementation, a first product of the target number of containers and the message threshold is calculated, and a second product of the message threshold and a preset value is calculated, where the preset value is less than 1 and greater than 0;
[0167] The backlog indicator is obtained by subtracting the second product from the first product.
[0168] In a possible implementation, the backlog indicator is divided by the message threshold to obtain a first container number;
[0169] When the first number of containers is greater than the number of deployed containers, subtract the number of deployed containers from the first number of containers to obtain the number of expanded containers;
[0170] The containers in the target cluster are expanded according to the number of expanded containers.
[0171] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0172] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0173] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A cluster expansion method, characterized in that: Applied to elastic components, including: When receiving a query request of a target cluster, sending configuration information of the target cluster to the proxy service corresponding to the elastic component, so that the proxy service obtains the current message backlog according to the configuration information, and calculates the backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process; receiving the backlog indicator returned by the proxy service; The target cluster is expanded and controlled according to the backlog indicator.
2. The method according to claim 1, characterized in that The sending the configuration information of the target cluster to the proxy service corresponding to the elastic component includes: Acquire a service identifier and a service deployment environment of a target service included in the target cluster from the query request, where the target service is deployed in multiple clusters; According to the service identifier and the service deployment environment, obtain the maximum number of containers of the target cluster, the message threshold of each container, the number of deployed containers, the message middleware, the cluster name, the message middleware topic and the consumer group name as the configuration information; The configuration information is sent to the proxy service.
3. The method according to claim 2, characterized in that The proxy service obtains the current message backlog according to the configuration information, including: The proxy service calls a target interface of a message middleware corresponding to the target cluster, and obtains the message backlog from the target interface according to the message middleware, a cluster name, the message middleware topic, and the consumer group name.
4. The method according to claim 2, characterized in that: The calculating the backlog index of the target cluster according to the message backlog includes: Polling multiple clusters deployed with the target service in sequence according to the message backlog; Determine whether the current polling cluster is the target cluster; When the judgment result is no, the current remaining message backlog is greater than zero, and the number of containers of the current polling cluster has not reached the maximum number of containers, the message threshold of the current polling cluster is subtracted from the remaining message backlog to update the current remaining message backlog, and the number of containers of the current polling cluster is increased by one, and polling continues; When the target cluster is polled, and the current remaining message backlog is greater than zero, and the number of containers of the target cluster has not reached the maximum number of containers, the number of containers of the target cluster is increased by one to obtain the target number of containers; After subtracting the message threshold of the target cluster from the remaining message backlog, continue polling until the remaining message backlog is zero, or the number of target containers is equal to the maximum number of containers of the target cluster, then stop polling; The backlog indicator is calculated according to the target number of containers and the message threshold.
5. The method according to claim 4, characterized in that The calculating the backlog indicator according to the target number of containers and the message threshold includes: Calculating a first product of the target number of containers and the message threshold, and calculating a second product of the message threshold and a preset value, where the preset value is less than 1 and greater than 0; The backlog indicator is obtained by subtracting the second product from the first product.
6. The method according to claim 4, characterized in that The controlling the expansion of the target cluster according to the backlog indicator includes: Dividing the backlog indicator by the message threshold to obtain a first container number; When the first number of containers is greater than the number of deployed containers, subtract the number of deployed containers from the first number of containers to obtain the number of expanded containers; The containers in the target cluster are expanded according to the number of expanded containers.
7. A cluster expansion system, characterized in that: The method for implementing claim 1 comprises: elastic components, proxy services and message middleware; The elastic component is used to send the configuration information of the target cluster to the proxy service when receiving a query request of the target cluster; The proxy service is used to obtain the current message backlog from the message middleware according to the configuration information, and calculate the backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process; The elastic component is further used to receive the backlog indicator returned by the proxy service, and perform capacity expansion control on the target cluster according to the backlog indicator.
8. A cluster expansion device, characterized in that: include: A sending module, configured to, when receiving a query request of a target cluster, send configuration information of the target cluster to a proxy service corresponding to the elastic component, so that the proxy service obtains a current message backlog according to the configuration information, and calculates a backlog index of the target cluster according to the message backlog, wherein the backlog index represents the message volume that the target cluster currently needs to process; A receiving module, used for receiving the backlog indicator returned by the proxy service; A control module is used to control the expansion of the target cluster according to the backlog indicator.
9. A computer device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a cluster expansion program stored in the memory to implement the cluster expansion method according to any one of claims 1 to 6.
10. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the cluster expansion method according to any one of claims 1 to 6.
Citation Information
Cited By
Log processing method and device, electronic equipment and computer readable medium
CN121255742A