Database resource adjustment method and device, equipment, medium and program product
By dynamically adjusting the resource allocation of the database cluster and optimizing resource usage based on historical data and prediction information, the problem of low resource utilization caused by changes in database service pressure is solved, and efficient resource utilization and elastic database expansion are achieved.
Patent Information
- Application Number
- CN202411434803.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-01-17
AI Technical Summary
The pressure of database services changes dynamically over time, resulting in insufficient or excessive allocation of fixed resources, reducing database resource utilization.
By obtaining historical resource usage information of the target database cluster, future resource usage predictions are made, and current resource allocation is dynamically adjusted based on resource regulation methods and prediction information to ensure that resource allocation is adapted to dynamically changing service pressure.
Improve database resource utilization, avoid insufficient or oversupply, and support elastic scaling and serverlessness of the database.
Smart Images

Figure CN119322771A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to computer technology, and in particular to a database resource adjustment method, device, equipment, medium and program product. Background Art
[0002] With the rapid development of computer technology, clients often need to perform data query and storage operations on databases. At present, traditional database deployment requires explicit specification of fixed resources, such as 16 cores, 64GB memory, 2TB disk, etc., in order to use fixed resources to run database services.
[0003] However, in the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] Since the database service pressure changes dynamically over time, there may be a situation where the allocated fixed resources are insufficient or excessive, which reduces the utilization rate of database resources. Summary of the invention
[0005] The embodiments of the present invention provide a database resource adjustment method, apparatus, device, medium and program product to achieve dynamic adjustment of resource allocation information of a database cluster, thereby adapting to dynamically changing database service pressure and improving database resource utilization.
[0006] In a first aspect, an embodiment of the present invention provides a method for adjusting database resources, comprising:
[0007] Obtain resource adjustment information corresponding to the target database cluster to be adjusted;
[0008] Based on the resource adjustment message, acquiring historical resource usage information of the target database cluster;
[0009] Perform future resource usage prediction based on the historical resource usage information to determine predicted resource usage information of the target database cluster;
[0010] Based on the resource control mode of the target database cluster and the predicted resource usage information, current resource allocation information of the target database cluster is adjusted.
[0011] In a second aspect, an embodiment of the present invention further provides a database resource adjustment device, including:
[0012] A resource adjustment message acquisition module is used to acquire a resource adjustment message corresponding to a target database cluster to be adjusted;
[0013] A historical resource usage information acquisition module, used to acquire historical resource usage information of the target database cluster based on the resource adjustment message;
[0014] A predicted resource usage information determination module, configured to perform future resource usage prediction based on the historical resource usage information and determine the predicted resource usage information of the target database cluster;
[0015] The current resource allocation information adjustment module is used to adjust the current resource allocation information of the target database cluster based on the resource control mode of the target database cluster and the predicted resource usage information.
[0016] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0017] one or more processors;
[0018] A memory for storing one or more programs;
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the database resource adjustment method provided by any embodiment of the present invention.
[0020] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a database resource adjustment method as provided in any embodiment of the present invention.
[0021] In a fifth aspect, an embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements the database resource adjustment method provided by any embodiment of the present invention.
[0022] One embodiment of the above invention has the following advantages or beneficial effects:
[0023] By obtaining the historical resource usage information of the target database cluster based on the resource adjustment message corresponding to the target database cluster to be adjusted, and predicting the future resource usage based on the historical resource usage information, the predicted resource usage information of the target database cluster is determined; based on the resource control method of the target database cluster and the predicted resource usage information, the current resource allocation information of the target database cluster is dynamically adjusted, so that the adjusted resource allocation information is adapted to the future resource usage, thereby adapting to the dynamically changing database service pressure, and improving the database resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0025] Figure 1 is a flow chart of a database resource adjustment method provided by an embodiment of the present invention;
[0026] Figure 2 is an example diagram of data flow and control flow of a database cluster involved in an embodiment of the present invention;
[0027] Figure 3 is a flow chart of another database resource adjustment method provided by an embodiment of the present invention;
[0028] Figure 4 This is an example diagram of a resource adjustment process of a database cluster involved in an embodiment of the present invention;
[0029] Figure 5 is a flow chart of another database resource adjustment method provided by an embodiment of the present invention;
[0030] Figure 6 It is a structural schematic diagram of a database resource adjustment device provided by an embodiment of the present invention;
[0031] Figure 7 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0033] Figure 1 This is a flowchart of a database resource adjustment method provided by an embodiment of the present invention. This embodiment is applicable to the case where the resource allocation information of a database cluster is dynamically adjusted, especially to the application scenario where the database cluster is dynamically expanded and reduced. The method can be executed by a database resource adjustment device, which can be implemented by software and / or hardware and integrated in an electronic device. Figure 1 As shown, the method specifically comprises the following steps:
[0034] S110: Obtain resource adjustment information corresponding to the target database cluster to be adjusted.
[0035] The target database cluster may be any type of database cluster that currently needs to dynamically adjust resources. For example, the target database cluster may be, but is not limited to, a TiDB database cluster or a MySQL database cluster. It should be noted that the resource allocation information of any type of database cluster may be dynamically adjusted using the method described in steps S110-S140, thereby improving the versatility of database resource adjustment.
[0036] The resource adjustment message may be a message for triggering a database resource adjustment operation, which may include information of the target database cluster to be adjusted, so that the database cluster that currently needs to be adjusted can be determined based on the resource adjustment information. The resource adjustment message may also include: maximum resource allocation information, resource adjustment cycle information, and latest adjustment time information, etc. Among them, the maximum resource allocation information may be the maximum resource allowed to be allocated by the target database cluster. The resource adjustment cycle information may refer to the execution cycle of the resource adjustment operation, such as 60s, that is, the resource adjustment operation is performed once every 60s, that is, the operation of steps S120-S140 is performed once. The latest adjustment time information refers to the time when the resource was last adjusted.
[0037] Specifically, when resources of the target database cluster need to be adjusted, a resource adjustment message can be generated based on information of the target database cluster and sent to the resource adjustment device, so that the resource adjustment device triggers the resource adjustment operation of the target database cluster based on the received resource adjustment message.
[0038] S120: Based on the resource adjustment message, obtain historical resource usage information of the target database cluster.
[0039] The historical resource usage information may include resource information actually used by the target database cluster in a historical time period. The historical time period may be a historical time period closest to the current time, such as within the last 100 seconds. The number of historical resource usage information may be multiple, such as a sequence of historical resource usage information arranged in chronological order, so as to improve the accuracy of future resource usage prediction.
[0040] Exemplarily, the historical resource usage information may include, but is not limited to: at least one of the historical usage number of database nodes of the target database cluster and the historical usage computing resource information of the database nodes. Among them, the historical usage number of database nodes may refer to the number of database nodes actually used in history, that is, the number of database nodes that were in a non-idle state in history, and the non-idle state refers to the state in which the database node is assigned a data processing task. For example, the historical usage number of database nodes may also refer to the number of replicas actually used in history. The historical usage computing resource information of database nodes may refer to the computing resource information actually used in history in the database node, such as the number of CPU cores used, memory usage, and disk usage of the database node.
[0041] Specifically, in response to the resource adjustment message, historical resource usage information of the target database cluster may be obtained from the operation log of the target database cluster.
[0042] S130: Predict future resource usage based on historical resource usage information to determine predicted resource usage information of the target database cluster.
[0043] The predicted resource usage information may be a predicted resource usage of the target database cluster at a future time. The future time may refer to a future resource adjustment time. The predicted resource usage information may be used to characterize the database service pressure of the target database cluster at a future time.
[0044] Exemplarily, the predicted resource usage information may include, but is not limited to: at least one of the predicted usage quantity of database nodes of the target database cluster and the predicted usage computing resource information of the database nodes. The predicted usage quantity of the database nodes may refer to the predicted number of database nodes to be used in the future. The predicted usage computing resource information of the database nodes may refer to the predicted computing resource information to be used by the database nodes in the future.
[0045] Specifically, a machine learning model can be used to accurately predict future resource usage. For example, historical resource usage information is input into a pre-trained target network model to predict future resource usage, and based on the output of the target network model, the predicted resource usage information of the target database cluster is obtained. The target network model can be a network model of any architecture for predicting future resource usage. For example, the target network model can be an LSTM (Long Short-Term Memory) model.
[0046] S140: Based on the resource control mode and predicted resource usage information of the target database cluster, adjust the current resource allocation information of the target database cluster.
[0047] Among them, the resource control method of the target database cluster may refer to a method for controlling the resource allocation of the target database cluster. For example, the resource control method may include an operator controller method or an interface control method. Among them, the operator controller method uses the operator controller in the Kubernetes container orchestration system to allocate resources. The operator controller of the target database cluster is deployed and controlled through a custom resource object. The custom resource object is an object obtained by initializing the structure of the custom resource (Custom Resource Define, CRD) of the target database cluster, that is, cluster CR. The custom resource of the target database cluster includes the configured current resource allocation information, so that the operator controller of the target database cluster allocates resources according to the current resource allocation information. The interface control method uses an external server to allocate resources, so it is necessary to call the interface of the external server to control resource allocation.
[0048] Specifically, based on the resource control method of the target database cluster, the current resource allocation information of the target database cluster can be directly adjusted to the predicted resource usage information. Alternatively, it is detected whether the current resource allocation information of the target database cluster is the same as the predicted resource usage information. If the current resource allocation information is the same as the predicted resource usage information, it indicates that there is no need to adjust the resources allocated to the database at present, and the resource adjustment operation can be ended at this time. If the current resource allocation information is different from the predicted resource usage information, it indicates that the resources allocated to the database need to be adjusted at present. At this time, based on the resource control method of the target database cluster, the current resource allocation information of the target database cluster is adjusted to the predicted resource usage information.
[0049] For example, if the resource control mode of the target database cluster is the operator controller mode, the current resource allocation information in the custom resource object of the target database cluster is modified to the predicted resource usage information, so that the operator controller of the target database cluster reallocates resources according to the predicted resource usage information; if the resource control mode of the target database cluster is the interface control mode, the predicted resource usage information is sent to the external server by calling the external server interface of the target database cluster, so that the external server reallocates resources according to the predicted resource usage information. By adjusting the current allocated resources of the target database cluster to future usage resources, the allocated resources of the target database cluster are always adapted to the database service pressure, avoiding the situation of insufficient resources or excessive resources, thereby improving the utilization rate of database resources. By utilizing the above steps S110-S140, the allocated resources of the database cluster can be adjusted in real time according to the database service pressure, thereby supporting the elastic expansion and contraction of the database and realizing the Serverless database. Serverless does not mean that servers are not needed, but that the server becomes imperceptible to users.
[0050] The technical solution of this embodiment obtains historical resource usage information of the target database cluster based on the resource adjustment message corresponding to the target database cluster to be adjusted, and predicts future resource usage based on the historical resource usage information to determine the predicted resource usage information of the target database cluster; based on the resource control method of the target database cluster and the predicted resource usage information, the current resource allocation information of the target database cluster is dynamically adjusted, so that the adjusted resource allocation information is adapted to the future resource usage, thereby adapting to the dynamically changing database service pressure, thereby improving the database resource utilization rate.
[0051] Based on the above technical solution, the target database cluster may include multiple database nodes, each of which is a containerized database deployment node. The kernel layer of each database node supports shared storage services to store data in a shared storage cloud.
[0052] See also Figure 2 , each database node is a node used to implement database services. Each database node is equivalent to a deployment node Pod in the Kubernetes container orchestration system. In order to realize serverless database, the kernel layer of each database node needs to support shared storage services, that is, the kernel layer supports capabilities such as one write and multiple reads of a copy of data, and data needs to be stored on shared storage, not on local disks, so as to achieve centralized data management.
[0053] Exemplarily, each database node is a weak-state service, and the proxy component in the target database cluster destroys the database node after migrating the established session connections in the database node to be destroyed to the database node that has not been destroyed.
[0054] Specifically, when adjusting the allocated resources, in order to achieve rapid creation and destruction of database nodes, each database node needs to provide a weak state service. Weak state service means that the node is destroyed after executing less business logic, so that the node expansion and contraction can be completed within a few seconds or tens of seconds. Since the database Serverless will inevitably face the frequent creation and destruction of nodes, the problem of repeated disconnection and reconnection of database connections will occur on the client side. In order to avoid this problem, it is necessary to use the Proxy proxy component as the middle layer to solve the problem of frequent disconnection of backend connections, shielding the client-side error. For example, the target database cluster needs to use the Proxy proxy component for node management and request scheduling. At the same time, the Proxy proxy component controls the database node to be destroyed to migrate the established session connection to the undestroyed database node after completing the assigned task, so that the Proxy proxy component transfers the subsequent tasks that need to be assigned to the database node to be destroyed to the undestroyed database node, and then destroys the node offline after the session transfer, so as to ensure that the destroyed database node has no connection.
[0055] See also Figure 2 , the data flow represents the data processing process between the client and the target database cluster, which is as follows: the client sends a data processing request to the target database cluster, such as a data query request or a data storage request. After receiving the data processing request, the proxy component in the target database cluster allocates and schedules the data processing request, determines the database node that needs to process the data processing request, and sends the data processing request to the database node. The database node processes the data processing request based on the shared storage service, such as querying data from the shared storage cloud or storing data in the shared storage cloud.
[0056] Exemplarily, step S120 may include: generating an information acquisition request corresponding to the target database cluster based on the resource adjustment message; sending the information acquisition request to a data acquisition component, the data acquisition component being used to collect resource usage information of each database cluster in real time; and receiving historical resource usage information of the target database cluster returned by the data acquisition component based on the information acquisition request.
[0057] The data collection component may be a device for real-time collection and storage of resource usage information of each database cluster, such as a data monitoring system Prometheus. Figure 2After receiving the resource adjustment message, the resource adjustment device generates an information acquisition request corresponding to the target database cluster based on the target database cluster that needs to be adjusted in the resource adjustment message, and sends the information acquisition request to the data acquisition component. Based on the information acquisition request, the data acquisition component obtains the historical resource usage information of the target database cluster from the collected data, and returns the historical resource usage information, so that the resource adjustment device can obtain the historical resource usage information of the target database cluster.
[0058] See also Figure 2 , the control flow represents the control process of the resource adjustment device for the resource allocation of the target database cluster. The resource adjustment device can be implemented by using the operator controller in the Kubernetes container orchestration system. The resource adjustment device can include a control management component and a prediction component. Both the control management component and the prediction component can be implemented by using the deployment deployment in the Kubernetes container orchestration system. The control process is: the control management component obtains the resource adjustment message corresponding to the target database cluster to be adjusted, and based on the resource adjustment message, sends the resource prediction request corresponding to the target database cluster to the prediction component. The prediction component generates an information acquisition request corresponding to the target database cluster based on the received resource prediction request, and sends the information acquisition request to the data acquisition component. The data acquisition component returns the historical resource usage information of the target database cluster to the prediction component based on the information acquisition request. The prediction component predicts future resource usage based on the received historical resource usage information, determines the predicted resource usage information of the target database cluster, and sends the predicted resource usage information to the control management component. The control management component adjusts the current resource allocation information of the target database cluster based on the resource regulation mode of the target database cluster and the received predicted resource usage information, thereby completing a resource allocation adjustment process.
[0059] Figure 3 This is a flowchart of another database resource adjustment method provided by an embodiment of the present invention. Based on the above embodiments, this embodiment optimizes the step of "obtaining resource adjustment information corresponding to the target database cluster to be adjusted". The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here.
[0060] See also Figure 3 Another database resource adjustment method provided in this embodiment specifically includes the following steps:
[0061] S310, receiving a resource adjustment message corresponding to a target database cluster to be adjusted sent by a control plane component; the resource adjustment message is generated based on a custom resource object written for implementing resource adjustment of the target database cluster.
[0062] The custom resource object used to implement the target database cluster resource adjustment may include database type information, maximum resource allocation information, resource adjustment cycle information, and latest adjustment time information corresponding to the target database cluster. The custom resource object may be an object initialized according to the structure of the custom resource CRD for implementing the target database cluster resource adjustment, that is, serverless CR. The database type information in the custom resource object serverless CR refers to the database type in the target database cluster, such as TiDB or MySQL. The maximum resource allocation information may be the maximum resource allowed to be allocated by the target database cluster. The resource adjustment cycle information may refer to the execution cycle of the resource adjustment operation, such as 60s, that is, the resource adjustment operation is performed every 60s. The latest adjustment time information refers to the time of the last resource adjustment. The custom resource object serverless CR may also include: resource type information (such as Serverless), name information (such as demo), namespace (such as dev), and request URL information of the data collection component.
[0063] Specifically, see Figure 4 The user writes a custom resource object for adjusting the target database cluster resources based on the control requirements, and submits the custom resource object to the control plane component. The control plane component generates a resource adjustment message corresponding to the target database cluster to be adjusted based on the custom resource object. The control plane component can send the resource adjustment message to the resource adjustment device through a broadcast notification method, so that the resource adjustment device monitors the resource adjustment message corresponding to the target database cluster.
[0064] S320: Based on the resource adjustment message, obtain historical resource usage information of the target database cluster.
[0065] Exemplarily, step S320 may include: if it is detected that the resource adjustment condition is currently met based on the resource adjustment period information and the latest adjustment time information in the resource adjustment message, acquiring historical resource usage information of the target database cluster based on the resource adjustment message.
[0066] The resource adjustment condition may refer to a condition that allows database resource adjustment. Specifically, based on the latest adjustment time information in the resource adjustment message, the time interval between the current time and the latest adjustment time information is determined, and whether the time interval is equal to or greater than the resource adjustment cycle information is detected. If so, it indicates that the time for adjusting the resource has arrived. At this time, it is determined that the resource adjustment condition is currently met, and based on the resource adjustment message, the historical resource usage information of the target database cluster is obtained. By using the resource adjustment cycle information and the latest adjustment time information in the resource adjustment message, periodic adjustment of database resources can be achieved.
[0067] S330: Predict future resource usage based on historical resource usage information to determine predicted resource usage information of the target database cluster.
[0068] S340: Based on the resource control mode and predicted resource usage information of the target database cluster, adjust the current resource allocation information of the target database cluster.
[0069] Specifically, see Figure 4 After the resource adjustment device listens to the resource adjustment message, it obtains the historical resource usage information of the target database cluster from the data acquisition component, and predicts the future resource usage based on the historical resource usage information, determines the predicted resource usage information of the target database cluster, and submits the predicted resource usage information to the control plane component when the resource control mode is the operator controller mode, so that the control plane component can modify the current resource allocation information in the custom resource object cluster CR of the target database cluster to the predicted resource usage information, so that the operator controller of the target database cluster reallocates resources according to the predicted resource usage information.
[0070] Exemplarily, after step S340, the method may further include: updating the latest adjustment time information in the resource adjustment message in the control plane component to trigger resending of the updated resource adjustment message.
[0071] Specifically, after the current resource adjustment, the latest adjustment time information in the resource adjustment message in the control plane component is updated to the current time, thereby triggering the control plane component to send the updated resource adjustment message again, and executing steps S320-S340 based on the resource adjustment message sent again to perform the next adjustment of database resources, thereby enabling the allocated resources of the target database cluster to be adjusted dynamically and uninterruptedly.
[0072] The technical solution of this embodiment receives a resource adjustment message corresponding to the target database cluster to be adjusted sent by the control plane component; the resource adjustment message is generated based on a custom resource object written to implement the target database cluster resource adjustment, so that the control plane component can be used to effectively control the triggering of the target database cluster resource adjustment, thereby realizing the serverlessization of database resources.
[0073] Figure 5This is a flow chart of another database resource adjustment method provided by an embodiment of the present invention. Based on the above embodiments, this embodiment optimizes the step of "adjusting the current resource allocation information of the target database cluster based on the resource control mode and predicted resource usage information of the target database cluster". The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here.
[0074] See also Figure 5 Another database resource adjustment method provided in this embodiment specifically includes the following steps:
[0075] S510: Obtain resource adjustment information corresponding to the target database cluster to be adjusted.
[0076] S520: Based on the resource adjustment message, obtain historical resource usage information of the target database cluster.
[0077] S530: Predict future resource usage based on historical resource usage information to determine predicted resource usage information of the target database cluster.
[0078] S540: Obtain maximum resource allocation information in the resource adjustment message.
[0079] The maximum resource allocation information may be the maximum resource that the target database cluster allows to allocate, which is configured by the user based on business requirements.
[0080] S550: Compare the maximum resource allocation information with the predicted resource usage information, and determine the target resource allocation information to be adjusted based on the comparison result.
[0081] Specifically, the maximum resource allocation information is compared with the predicted resource usage information. If the predicted resource usage information is greater than or equal to the maximum resource allocation information, the target resource allocation information to be adjusted is determined to be the maximum resource allocation information. If the predicted resource usage information is less than the maximum resource allocation information, the target resource allocation information to be adjusted is determined to be the predicted resource usage information, so that the target resource allocation information does not exceed the maximum resource allocation information, thereby meeting the business needs.
[0082] S560: Based on the resource control method of the target database cluster, adjust the current resource allocation information of the target database cluster to the target resource allocation information.
[0083] The resource control method of the target database cluster may refer to a method for controlling resource allocation of the target database cluster. For example, the resource control method may include an operator controller method or an interface control method. The operator controller method uses the operator controller in the Kubernetes container orchestration system to allocate resources. The interface control method uses an external server to allocate resources, so it is necessary to call the interface of the external server to control resource allocation.
[0084] Specifically, based on the resource control method of the target database cluster, the current resource allocation information of the target database cluster can be directly adjusted to the target resource allocation information. Alternatively, it is detected whether the current resource allocation information of the target database cluster is the same as the target resource allocation information. If the current resource allocation information is the same as the target resource allocation information, it indicates that there is no need to adjust the resources allocated to the database at present, and the resource adjustment operation can be ended at this time. If the current resource allocation information is different from the target resource allocation information, it indicates that the resources allocated to the database need to be adjusted at present. At this time, based on the resource control method of the target database cluster, the current resource allocation information of the target database cluster is adjusted to the target resource allocation information.
[0085] Exemplarily, step S560 may include: if the resource control mode of the target database cluster is the operator controller mode, then the current resource allocation information in the custom resource object of the target database cluster is modified to the target resource allocation information, so that the operator controller of the target database cluster performs resource reallocation according to the target resource allocation information; if the resource control mode of the target database cluster is the interface control mode, then the target resource allocation information is sent to the external server by calling the external server interface of the target database cluster, so that the external server performs resource reallocation according to the target resource allocation information.
[0086] Specifically, when the resource control mode of the target database cluster is the operator controller mode, the current resource allocation information in the custom resource object of the target database cluster can be modified to the predicted resource usage information, so that the operator controller of the target database cluster reallocates resources according to the predicted resource usage information. When the resource control mode of the target database cluster is the interface control mode, by calling the external server interface of the target database cluster, the predicted resource usage information is sent to the external server through HTTP requests and other methods, so that the external server reallocates resources according to the predicted resource usage information. By adjusting the current allocated resources of the target database cluster to the future usage resources, the allocated resources of the target database cluster are always adapted to the database service pressure, thereby improving the utilization rate of database resources.
[0087] The technical solution of this embodiment compares the maximum resource allocation information in the resource adjustment message with the predicted resource usage information, determines the target resource allocation information to be adjusted based on the comparison result, and adjusts the current resource allocation information of the target database cluster to the target resource allocation information based on the resource control method of the target database cluster, thereby avoiding that the allocated resources exceed the maximum resources allowed to be allocated, and realizing the serverless database.
[0088] The following is an embodiment of a database resource adjustment device provided in an embodiment of the present invention. The device and the database resource adjustment methods of the above-mentioned embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the database resource adjustment device, reference can be made to the embodiment of the above-mentioned database resource adjustment method.
[0089] Figure 6 This is a schematic diagram of the structure of a database resource adjustment device provided by an embodiment of the present invention. This embodiment is applicable to the case where the resource allocation information of a database cluster is dynamically adjusted, and is particularly applicable to the application scenario where the database cluster is dynamically expanded and reduced. Figure 6 As shown, the device specifically includes: a resource adjustment message acquisition module 610, a historical resource usage information acquisition module 620, a predicted resource usage information determination module 630 and a current resource allocation information adjustment module 640.
[0090] Among them, the resource adjustment message acquisition module 610 is used to obtain the resource adjustment message corresponding to the target database cluster to be adjusted; the historical resource usage information acquisition module 620 is used to obtain the historical resource usage information of the target database cluster based on the resource adjustment message; the predicted resource usage information determination module 630 is used to predict future resource usage based on the historical resource usage information and determine the predicted resource usage information of the target database cluster; the current resource allocation information adjustment module 640 is used to adjust the current resource allocation information of the target database cluster based on the resource control method of the target database cluster and the predicted resource usage information.
[0091] The technical solution of this embodiment obtains historical resource usage information of the target database cluster based on the resource adjustment message corresponding to the target database cluster to be adjusted, and predicts future resource usage based on the historical resource usage information to determine the predicted resource usage information of the target database cluster; based on the resource control method of the target database cluster and the predicted resource usage information, the current resource allocation information of the target database cluster is dynamically adjusted, so that the adjusted resource allocation information is adapted to the future resource usage, thereby adapting to the dynamically changing database service pressure, thereby improving the database resource utilization rate.
[0092] Optionally, the target database cluster includes multiple database nodes, each database node is a containerized database deployment node, and the kernel layer of each database node supports a shared storage service to store data in a shared storage cloud;
[0093] Each database node is a weak-state service, and the proxy component in the target database cluster destroys the database node after migrating the established session connection in the database node to be destroyed to the database node that has not been destroyed.
[0094] Optionally, the resource adjustment message acquisition module 610 is specifically configured to:
[0095] Receive a resource adjustment message corresponding to a target database cluster to be adjusted sent by a control plane component; the resource adjustment message is generated based on a custom resource object written to implement resource adjustment of the target database cluster; wherein the custom resource object includes database type information corresponding to the target database cluster, maximum resource allocation information, resource adjustment cycle information, and latest adjustment time information.
[0096] Optionally, the historical resource usage information acquisition module 620 is specifically used to:
[0097] If it is detected that the resource adjustment condition is currently met based on the resource adjustment period information and the latest adjustment time information in the resource adjustment message, then historical resource usage information of the target database cluster is acquired based on the resource adjustment message;
[0098] The current resource allocation information adjustment module 640 is also used to update the latest adjustment time information in the resource adjustment message in the control plane component after adjusting the current resource allocation information of the target database cluster based on the resource control method of the target database cluster and the predicted resource usage information, so as to trigger the re-sending of the updated resource adjustment message.
[0099] Optionally, the historical resource usage information acquisition module 620 is specifically used to:
[0100] Based on the resource adjustment message, an information acquisition request corresponding to the target database cluster is generated; the information acquisition request is sent to a data acquisition component, and the data acquisition component is used to collect resource usage information of each database cluster in real time; and the historical resource usage information of the target database cluster returned by the data acquisition component based on the information acquisition request is received.
[0101] Optionally, the current resource allocation information adjustment module 640 includes:
[0102] A maximum resource allocation information acquisition unit, configured to acquire the maximum resource allocation information in the resource adjustment message;
[0103] a target resource allocation information determining unit, configured to compare the maximum resource allocation information with the predicted resource usage information, and determine the target resource allocation information to be adjusted based on the comparison result;
[0104] The current resource allocation information adjustment unit is used to adjust the current resource allocation information of the target database cluster to the target resource allocation information based on the resource control mode of the target database cluster.
[0105] Optionally, the current resource allocation information adjustment unit is specifically configured to:
[0106] If the resource control mode of the target database cluster is the operator controller mode, the current resource allocation information in the custom resource object of the target database cluster is modified to the target resource allocation information, so that the operator controller of the target database cluster performs resource reallocation according to the target resource allocation information;
[0107] If the resource regulation mode of the target database cluster is an interface control mode, the target resource allocation information is sent to the external server by calling the external server interface of the target database cluster, so that the external server reallocates resources according to the target resource allocation information.
[0108] Optionally, the historical resource usage information includes: at least one of the historical usage quantity of database nodes of the target database cluster and the historical usage computing resource information of the database nodes;
[0109] The predicted resource usage information includes: at least one of the predicted usage quantity of database nodes of the target database cluster and the predicted usage computing resource information of the database nodes;
[0110] The current resource allocation information includes: at least one of the number of database node allocations and database node computing resource allocation information of the target database cluster.
[0111] The database resource adjustment device provided in the embodiment of the present invention can execute the database resource adjustment method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the database resource adjustment method.
[0112] It is worth noting that in the embodiment of the above-mentioned database resource adjustment device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0113] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 7 A block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 7 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0114] like Figure 7 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0115] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0116] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0117] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory 30 (RAM) and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 not shown, usually called a "hard drive"). Although Figure 7Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0118] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0119] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0120] The processing unit 16 executes various functional applications and data processing by running the program stored in the system memory 28, for example, implementing a database resource adjustment method provided by any embodiment of the present invention, the method comprising:
[0121] Obtain resource adjustment information corresponding to the target database cluster to be adjusted;
[0122] Based on the resource adjustment message, acquiring historical resource usage information of the target database cluster;
[0123] Perform future resource usage prediction based on the historical resource usage information to determine predicted resource usage information of the target database cluster;
[0124] Based on the resource control mode of the target database cluster and the predicted resource usage information, current resource allocation information of the target database cluster is adjusted.
[0125] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the database resource adjustment method provided by any embodiment of the present invention.
[0126] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the steps of the database resource adjustment method provided in any embodiment of the present invention are implemented. The method includes:
[0127] Obtain resource adjustment information corresponding to the target database cluster to be adjusted;
[0128] Based on the resource adjustment message, acquiring historical resource usage information of the target database cluster;
[0129] Perform future resource usage prediction based on the historical resource usage information to determine predicted resource usage information of the target database cluster;
[0130] Based on the resource control mode of the target database cluster and the predicted resource usage information, current resource allocation information of the target database cluster is adjusted.
[0131] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0132] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0133] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0134] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0135] An embodiment of the present invention further provides a computer program product, including a computer program, which, when executed by a processor, implements the database resource adjustment method provided by any embodiment of the present invention.
[0136] In the process of implementation, the computer program product can be written in one or more programming languages or a combination thereof to perform the computer program code of the present invention, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0137] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0138] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A database resource adjustment method, characterized in that: include: Obtain resource adjustment information corresponding to the target database cluster to be adjusted; Based on the resource adjustment message, acquiring historical resource usage information of the target database cluster; Perform future resource usage prediction based on the historical resource usage information to determine predicted resource usage information of the target database cluster; Based on the resource control mode of the target database cluster and the predicted resource usage information, current resource allocation information of the target database cluster is adjusted.
2. The method according to claim 1, characterized in that The target database cluster includes multiple database nodes, each of which is a containerized database deployment node, and the kernel layer of each database node supports shared storage services to store data in a shared storage cloud; Each database node is a weak-state service, and the proxy component in the target database cluster destroys the database node after migrating the established session connection in the database node to be destroyed to the database node that has not been destroyed.
3. The method according to claim 1, characterized in that The obtaining of a resource adjustment message corresponding to the target database cluster to be adjusted includes: Receive a resource adjustment message corresponding to a target database cluster to be adjusted sent by a control plane component; the resource adjustment message is generated based on a custom resource object written to implement resource adjustment of the target database cluster; The custom resource object includes database type information, maximum resource allocation information, resource adjustment cycle information and latest adjustment time information corresponding to the target database cluster.
4. The method according to claim 3, characterized in that The acquiring the historical resource usage information of the target database cluster based on the resource adjustment message includes: If it is detected that the resource adjustment condition is currently met based on the resource adjustment period information and the latest adjustment time information in the resource adjustment message, then historical resource usage information of the target database cluster is acquired based on the resource adjustment message; After adjusting the current resource allocation information of the target database cluster based on the resource control mode of the target database cluster and the predicted resource usage information, the method further includes: The latest adjustment time information in the resource adjustment message in the control plane component is updated to trigger the resending of the updated resource adjustment message.
5. The method according to claim 1, characterized in that The acquiring the historical resource usage information of the target database cluster based on the resource adjustment message includes: Based on the resource adjustment message, generate an information acquisition request corresponding to the target database cluster; Sending the information acquisition request to a data collection component, wherein the data collection component is used to collect resource usage information of each database cluster in real time; Receive the historical resource usage information of the target database cluster returned by the data acquisition component based on the information acquisition request.
6. The method according to claim 1, characterized in that The adjusting the current resource allocation information of the target database cluster based on the resource control mode of the target database cluster and the predicted resource usage information includes: Acquire maximum resource allocation information in the resource adjustment message; Comparing the maximum resource allocation information with the predicted resource usage information, and determining target resource allocation information to be adjusted based on the comparison result; Based on the resource control mode of the target database cluster, the current resource allocation information of the target database cluster is adjusted to the target resource allocation information.
7. The method according to claim 6, characterized in that The resource control method based on the target database cluster, adjusting the current resource allocation information of the target database cluster to the target resource allocation information, includes: If the resource control mode of the target database cluster is the operator controller mode, modify the current resource allocation information in the custom resource object of the target database cluster to the target resource allocation information, so that the operator controller of the target database cluster performs resource reallocation according to the target resource allocation information; If the resource regulation mode of the target database cluster is an interface control mode, the target resource allocation information is sent to the external server by calling the external server interface of the target database cluster, so that the external server reallocates resources according to the target resource allocation information.
8. The method according to any one of claims 1 to 7, characterized in that: The historical resource usage information includes: at least one of the historical usage quantity of database nodes of the target database cluster and the historical usage computing resource information of the database nodes; The predicted resource usage information includes: at least one of the predicted usage quantity of database nodes of the target database cluster and the predicted usage computing resource information of the database nodes; The current resource allocation information includes: at least one of the number of database node allocations and database node computing resource allocation information of the target database cluster.
9. A database resource adjustment device, characterized in that: include: A resource adjustment message acquisition module is used to acquire a resource adjustment message corresponding to a target database cluster to be adjusted; A historical resource usage information acquisition module, used to acquire historical resource usage information of the target database cluster based on the resource adjustment message; A predicted resource usage information determination module, configured to perform future resource usage prediction based on the historical resource usage information and determine the predicted resource usage information of the target database cluster; The current resource allocation information adjustment module is used to adjust the current resource allocation information of the target database cluster based on the resource control mode of the target database cluster and the predicted resource usage information.
10. An electronic device, characterized in that: The electronic device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the database resource adjustment method as described in any one of claims 1-8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the database resource adjustment method as described in any one of claims 1 to 8 is implemented.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the database resource adjustment method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Resource quota management method and device based on database
CN112445857A
Resource scheduling method and device, electronic equipment and storage medium
CN117492977A
Cited By
Resource data processing method and device, storage medium and electronic equipment
CN121563159A