TECHNICAL FIELD

This application relates to the field of database cluster technologies, and more particularly, to an application program management method and apparatus.

BACKGROUND

A large-scale application system typically runs on a database cluster system. When the large-scale application system runs on this database cluster with a shared-everything architecture, application partitioning is usually performed, such that an application accessing same or a same type of data runs on a same database node, to reduce data communication between database clusters and avoid performance degradation caused by an increasing amount of traffic between the clusters, so as to avoid application performance degradation.

In an existing partition technology, partitioning is usually performed based on an application module. Each application module runs on a specified database node (Database Instance). This partition mode may cause overload of a database node, for example, overload of a central processing unit (CPU).

SUMMARY

This application provides an application program management method and apparatus, to dynamically adjust a database node on which an application program runs, so as to avoid overload of the database node.

According to a first aspect, an application program management method is provided. The method is performed in a database cluster system including at least two database nodes, at least one database object is stored in each database node, and the method includes: running an application program on a first database node in a first time period; determining a target database node based on at least one historical database object accessed by the application program in the first time period, where the target database node stores the historical database object; and running the application program on the target database node in a second time period.

Based on the foregoing technical solution, according to the application program management method in this embodiment of this application, the target database node may be determined based on the historical database object accessed by the application program, such that the application program running on the first database node is migrated to and runs on the target database node. Compared with the prior art, this method can avoid a problem that an application program of an application module cannot be split to perform adjustment between database nodes when a database node is overloaded. Therefore, in this embodiment of this application, a relationship between an application program and a running database node is dynamic, and may be adjusted based on a load of the database cluster system, a status of a database node on which a database object is located, or the like.

With reference to the first aspect, in embodiments of the first aspect, the running an application program on a first database node in a first time period includes: running a first application module on the first database node in the first time period, where the application program is any application program in the first application module.

The application module is classification of a type of application programs. Running application programs of a same type on a same database node can reduce data communication between database clusters, and avoid performance degradation of the database cluster system caused by an increasing amount of traffic between the clusters, thereby avoiding application performance degradation.

With reference to the first aspect, in embodiments of the first aspect, the method further includes: determining a first application program from the first application module; the determining a target database node based on at least one historical database object accessed by the application program in the first time period includes: calculating a data amount proportion of at least one second database node to obtain at least one value, where the second database node includes the target database node, and the data amount proportion is a proportion of a data amount that the first application program accesses the historical database object on the second database node in the first time period to a total access amount, where the total access amount is a total data amount accessed by the first application program in the first time period; and determining a maximum value in the at least one value, where a database node corresponding to the maximum value is the target database node; and the running the application program on the target database node in a second time period includes: running the first application program on the target database node in the second time period.

One first application program is determined from the first application module, and the first application program is migrated from the first database node to the target database node, to reduce a load of the first database node. In addition, the maximum value means that the first application program accesses a maximum quantity of database objects on the database node. Migrating the first application program to the database node can reduce data communication between the database clusters.

With reference to the first aspect, in embodiments of the first aspect, the running the application program on the target database node in a second time period includes: when central processing unit (CPU) utilization of the target database node is less than a first threshold, running the application program on the target database node in the second time period.

To ensure a load of the target database node, for example, the CPU utilization of the target database node, the CPU utilization of the target database node is further determined before the application program is migrated to the target database node. The application program is migrated to and runs on the target database node only when the CPU utilization of the target database node is less than a threshold.

With reference to the first aspect, in embodiments of the first aspect, the method further includes: collecting running information of the database cluster system in real time, where the running information of the database cluster system includes load information of the database cluster system and information about communication performance of the database cluster system; and determining, based on the running information of the database cluster system, whether the application program runs on the target database node in the second time period.

Adjusting the node on which the application program runs may affect the communication performance of the database cluster system. Therefore, the running information of the database cluster system needs to be collected in real time. The running information includes the load information and the information about the communication performance of the database cluster system. The application program is migrated to and runs on the target database node only when the running information meets a condition. Therefore, not only the database node on which the application program runs can be dynamically adjusted, but also the communication performance of the database cluster system can be ensured.

With reference to the first aspect, in embodiments of the first aspect, the determining whether the application program runs on the target database node in the second time period includes: when the communication performance of the database cluster system meets a first condition, determining that the application program runs on the target database node in the second time period; or when CPU utilization of the first database node exceeds a second threshold, determining that the application program runs on the target database node in the second time period.

When the communication performance of the database cluster system meets a condition, the application program can be migrated. Alternatively, when the CPU utilization of the first database node exceeds a threshold, to reduce the load of the first database node, the application program on the first database node is migrated to and runs on another database node.

With reference to the first aspect, in embodiments of the first aspect, the at least one historical database object is stored on the at least one second database node; and the determining a target database node based on at least one historical database object accessed by the application program in the first time period includes: determining the target database node from the at least one second database node according to a preset mapping relationship, where the mapping relationship is a relationship between the application program and a database node capable of running the application program; and/or determining the target database node from the at least one second database node based on a second application module, where an application program in the second application module runs on the target database node, and the application program and the application program in the second application module are application programs of a same type.

In this embodiment of this application, there are many manners of determining a plurality of database nodes by using the historical database object, and determining the target database node from the plurality of database nodes. In a manner, the database node capable of running the application program may be determined, according to the preset mapping relationship, from the plurality of database nodes. Alternatively, the application program may be configured on a database node on which an application program of a same type runs.

With reference to the first aspect, in embodiments of the first aspect, the method further includes: periodically detecting running information of the application program, where the running information of the application program includes database node information accessed by the application program.

The running information of the application program is periodically detected, and the database node on which the application program runs may be dynamically adjusted based on a running status of the application program and the database node information, to ensure the overall communication performance of the database cluster system.

According to a second aspect, an application program management apparatus is provided. The apparatus includes units configured to perform the operations of the application program management method in any one of the first aspect and the embodiments of the first aspect.

According to a third aspect, an application program management device is provided. The device may be the application program management apparatus in the foregoing method designs, or may be a chip configured in the application program management apparatus. The device includes a processor, a memory, a communications interface, and a bus. The processor, the memory, and the communications interface communicate with each other by using the bus, or may implement communication by wireless transmission or by another means. The memory is configured to store an instruction, and the processor is configured to execute the instruction stored in the memory. The memory stores program code, and the processor may invoke the program code stored in the memory to perform the application program management method in any one of the first aspect and the embodiments of the first aspect.

According to a fourth aspect, a chip system is provided. The chip system includes a processor, and is configured by an application program management apparatus to implement the functions in the foregoing aspects, for example, running, collection, determining, or data and/or information processing in the foregoing method. In one embodiment, the chip system further includes a memory. The memory is configured to store a program instruction and data for the application program management apparatus. Further, the program instruction stored in the memory includes an instruction used to perform the application program management method in any one of the first aspect and the embodiments of the first aspect.

In one embodiment, the chip system may include a chip, or may include a chip and another discrete device.

According to a fifth aspect, a computer program product is provided. The computer program product includes computer program code. When the computer program code is run on a computer, the computer is enabled to perform the application program management method in any one of the first aspect and the embodiments of the first aspect.

According to a sixth aspect, a computer-readable medium is provided. The computer-readable medium stores program code executed by an application program management apparatus. The program code includes an instruction used to perform the application program management method in any one of the first aspect and the embodiments of the first aspect.

In this application, the embodiments provided in the foregoing aspects may be further combined to provide more embodiments.

