A connection pool partitioning method and device

By dividing the database connection pool into pools, using clustering algorithms to analyze query request statistics, and allocating sub-pools and connections, the problem of no connections in the connection pool caused by slow queries is solved, and the reliability and stability of the database are improved.

CN114996342BActive Publication Date: 2024-09-03PING AN BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210741925.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-27
Publication Date
2024-09-03
Estimated Expiration
2042-06-27

AI Technical Summary

Technical Problem

When accessing the database through the connection pool, slow query requests cause the connection pool to have no connections available within a certain period of time, causing the application to be unable to connect to the database, reducing the reliability and stability of the database.

Method used

By collecting the query request execution statistics of the server to be optimized, using a clustering algorithm for analysis, the connection pool is divided into multiple sub-pools, and the number of connections is allocated to each sub-pool. When a query request from the application is received, the connection pool is divided into sub-pools. Allocate the target sub-pool and target connection, connect to the database through the target sub-pool and target connection, and obtain the query results.

Benefits of technology

It effectively avoids the impact of slow queries on the system, prevents applications from being unable to connect to the database, improves the reliability and stability of the database, and ensures the normal operation of the system and the continuity of important businesses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114996342B
    Figure CN114996342B
Patent Text Reader

Abstract

The present application provides a connection pool sub-pooling method and device, the connection pool sub-pooling method includes: collecting execution statistics of the current query request of the server to be optimized; using a clustering algorithm to perform cluster analysis on the execution statistics to obtain analysis results; according to the analysis results, dividing the connection pool into multiple sub-pools, and allocating a corresponding number of connections to each sub-pool; when receiving a target query request initiated by an application, allocating a target sub-pool and a target connection to the target query request according to the multiple sub-pools; connecting to the database through the target sub-pool, the target connection and the target query request to query data and obtain query results. It can be seen that the implementation of this implementation method can avoid the impact of slow queries on the system, thereby avoiding the situation where the application cannot connect to the database, and improving the reliability and stability of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a connection pool partitioning method and device. Background Art

[0002] At present, the connection pool is a very important middleware for applications to connect to databases. Since the cost of establishing a connection is too high, most database application systems currently use a connection pool as a medium for applications to access the database. The application first accesses the connection pool to obtain an available connection, and then directly uses this connection to access the database, saving the overhead of creating a connection for the database. However, in practice, it is found that when accessing the database through the connection pool, there will be slow SQL query requests, resulting in no connection available in the connection pool within a certain period of time, which will cause the application to be unable to connect to the database, making the entire system unavailable. It can be seen that the slow query in the prior art has a great impact on the system, causing the application to be unable to connect to the database, reducing the reliability and stability of the database. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a connection pool partitioning method and device, which can avoid the impact of slow queries on the system, thereby avoiding the situation where the application cannot connect to the database, and improving the reliability and stability of the database.

[0004] A first aspect of an embodiment of the present application provides a connection pool partitioning method, including:

[0005] Collect the execution statistics of the query request of the current server to be optimized;

[0006] Using a clustering algorithm to perform cluster analysis on the execution statistical information to obtain an analysis result;

[0007] According to the analysis result, the connection pool is divided into a plurality of sub-pools, and a corresponding number of connections is allocated to each sub-pool;

[0008] When receiving a target query request initiated by an application, allocating a target sub-pool and a target connection to the target query request according to the plurality of sub-pools;

[0009] The database is connected through the target sub-pool, the target connection and the target query request to perform data query and obtain the query result.

[0010] In the above implementation process, the method can give priority to collecting the execution statistics of the query request of the current server to be optimized; then use the clustering algorithm to perform cluster analysis on the execution statistics to obtain the analysis results; then divide the connection pool into multiple sub-pools according to the analysis results, and allocate the corresponding number of connections to each sub-pool; when receiving the target query request initiated by the application, allocate the target sub-pool and target connection to the target query request according to the multiple sub-pools; finally, connect to the database through the target sub-pool, target connection and target query request to query the data and obtain the query results. It can be seen that the implementation of this implementation method can avoid the impact of slow queries on the system, thereby avoiding the situation where the application cannot connect to the database, and improving the reliability and stability of the database.

[0011] Further, allocating a target sub-pool and a target connection to the target query request according to the plurality of sub-pools includes:

[0012] Obtaining query statement parameters of the target query request;

[0013] By using a pre-built response prediction model and the query statement parameters, the predicted execution information of the target query request is estimated; wherein the predicted execution information includes the predicted execution frequency of the target query request and the predicted response time of the target query request;

[0014] A target sub-pool and a target connection are allocated to the target query request from the plurality of sub-pools according to the prediction execution information.

[0015] Furthermore, before estimating the predicted execution information of the target query request by using the pre-built response prediction model and the query statement parameters, the method further includes:

[0016] Get query statement samples;

[0017] The original model is trained using a preset algorithm and the query sentence samples to obtain a trained response prediction model.

[0018] Furthermore, after connecting to a database through the target sub-pool, the target connection and the target query request to perform data query and obtaining the query result, the method further includes:

[0019] Acquire actual execution information of the query request during the preset time period when actually performing data query; wherein the actual execution information includes the actual execution frequency of the target query request during the data query and the actual response time of the target query request during the data query;

[0020] Adding the actual execution information to the execution statistical information to obtain updated execution information;

[0021] A clustering algorithm is used to re-perform clustering analysis on the update execution information to obtain an analysis result; and the connection pool is divided into a plurality of sub-pools according to the analysis result.

[0022] Further, according to the analysis result, the connection pool is divided into a plurality of sub-pools, and a corresponding number of connections is allocated to each of the sub-pools, including:

[0023] Determining the categories and total number of categories of the execution statistics information;

[0024] Divide the connection pool into multiple sub-pools, the number of which is the total number of categories;

[0025] Determining a category weight for each of the categories based on the business type of the system;

[0026] Determine, according to the execution statistical information, all execution frequencies corresponding to each of the categories and all response times corresponding to each of the categories;

[0027] The number of connections configured for each of the sub-pools is calculated according to all the execution frequencies, all the response times, the category weights, and a preset total number of configurable connections.

[0028] A second aspect of an embodiment of the present application provides a connection pool sub-pool device, the connection pool sub-pool device comprising:

[0029] A collection unit, used to collect execution statistics of the query request of the current server to be optimized;

[0030] A clustering unit, used for performing cluster analysis on the execution statistical information using a clustering algorithm to obtain an analysis result;

[0031] A pool division unit, used to divide the connection pool into multiple sub-pools according to the analysis result, and allocate a corresponding number of connections to each sub-pool;

[0032] an allocating unit, configured to allocate a target sub-pool and a target connection to the target query request according to the plurality of sub-pools when receiving a target query request initiated by an application;

[0033] The query unit is used to connect to the database through the target sub-pool, the target connection and the target query request to perform data query and obtain the query result.

[0034] In the above implementation process, the connection pool sub-pool device can collect the execution statistics of the query request of the current server to be optimized through the collection unit; perform cluster analysis on the execution statistics using the clustering algorithm through the clustering unit to obtain the analysis result; divide the connection pool into multiple sub-pools according to the analysis result through the sub-pool unit, and allocate the corresponding number of connections to each sub-pool; when receiving the target query request initiated by the application, the allocation unit allocates the target sub-pool and the target connection to the target query request according to the multiple sub-pools; and then connects to the database through the target sub-pool, the target connection and the target query request through the query unit to query the data and obtain the query result. It can be seen that the implementation of this implementation method can avoid the impact of slow queries on the system, thereby avoiding the situation where the application cannot connect to the database, and improving the reliability and stability of the database.

[0035] Furthermore, the allocation unit comprises:

[0036] An acquisition subunit, configured to acquire query statement parameters of a target query request when receiving a target query request initiated by an application;

[0037] An estimation subunit, configured to estimate the predicted execution information of the target query request by using a pre-built response prediction model and the query statement parameters; wherein the predicted execution information includes the predicted execution frequency of the target query request and the predicted response time of the target query request;

[0038] An allocating subunit is used to allocate a target subpool and a target connection for the target query request from the plurality of subpools according to the predicted execution information.

[0039] Furthermore, the connection pool sub-pool device also includes:

[0040] An acquisition unit is used to obtain actual execution information of the query request when actually performing data query in a preset time period after connecting to the database through the target sub-pool, the target connection and the target query request to perform data query and obtaining the query result; wherein the actual execution information includes the actual execution frequency of the target query request when performing data query and the actual response time of the target query request when performing data query;

[0041] an adding unit, configured to add the actual execution information to the execution statistical information to obtain updated execution information;

[0042] The clustering unit is further used to use a clustering algorithm to re-cluster the update execution information to obtain an analysis result; and trigger the pool division unit to divide the connection pool into multiple sub-pools according to the analysis result.

[0043] Furthermore, the allocation unit further includes:

[0044] The acquisition subunit is further configured to acquire a query statement sample before estimating the predicted execution information of the target query request by using the pre-built response prediction model and the query statement parameters;

[0045] The training subunit is used to train the original model through a preset algorithm and the query sentence samples to obtain a trained response prediction model.

[0046] Furthermore, the sub-pool unit comprises:

[0047] A determination subunit, used to determine the category and total number of categories of the execution statistical information;

[0048] A division subunit, used for dividing the connection pool into a plurality of sub-pools, the number of which is the total number of categories;

[0049] The determination subunit is further used to determine the category weight of each category according to the service type of the system;

[0050] The determining subunit is further used to determine all execution frequencies corresponding to each of the categories and all response times corresponding to each of the categories according to the execution statistical information;

[0051] The calculation subunit is used to calculate the number of connections configured for each of the sub-pools according to all the execution frequencies, all the response times, the category weights and a preset total number of configurable connections.

[0052] A third aspect of an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the connection pool partitioning method described in any one of the first aspects of the embodiments of the present application.

[0053] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, the connection pool partitioning method described in any one of the first aspect of the embodiment of the present application is executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0055] Figure 1A schematic diagram of a connection pool partitioning method provided in an embodiment of the present application;

[0056] Figure 2 A flow chart of another connection pool partitioning method provided in an embodiment of the present application;

[0057] Figure 3 A schematic diagram of the structure of a connection pool sub-pool device provided in an embodiment of the present application;

[0058] Figure 4 A schematic diagram of the structure of another connection pool sub-pool device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0060] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0061] Example 1

[0062] Please see Figure 1 , Figure 1 A schematic diagram of a connection pool partitioning method is provided for an embodiment of the present application. The connection pool partitioning method includes:

[0063] S101. Collect execution statistics of query requests of the current server to be optimized.

[0064] In this embodiment, the method can collect SQL execution statistics of the current server query request to be optimized.

[0065] S102: Use a clustering algorithm to perform cluster analysis on the execution statistical information to obtain analysis results.

[0066] In this embodiment, the method can use a clustering algorithm to perform clustering analysis on the SQL execution time and frequency to obtain analysis results.

[0067] S103. According to the analysis result, the connection pool is divided into a plurality of sub-pools, and a corresponding number of connections is allocated to each sub-pool.

[0068] S104: When a target query request initiated by an application is received, a target sub-pool and a target connection are allocated to the target query request according to multiple sub-pools.

[0069] S105. Connect to the database through the target sub-pool, the target connection and the target query request to perform data query and obtain the query result.

[0070] In this embodiment, two parameters in the connection pool will directly affect the normal use of the connection pool, and this method uses these two parameters as the basis for pool division. Among them:

[0071] SQL execution frequency: the average number of times a SQL statement is executed per unit time, represented by f.

[0072] SQL response time: The time it takes for a SQL statement to be sent from the application to the database to return all results, represented by t.

[0073] Specifically, this method can use clustering analysis algorithms to perform clustering analysis on SQL execution information, such as KNN, K-MEANS, DBSCAN, etc. Here, OPTICS is used as an example to establish a model.

[0074] If there are n objects (f, t) in the data sample, define according to the number of objects:

[0075] ;

[0076] Among them, MinPts is the minimum number of points (number of objects).

[0077] The minimum radius is .

[0078] Core point: If the number of points contained within the radius of a point is not less than the minimum number of points, then the point is a core point. Core distance:

[0079] ;

[0080] Reachable distance:

[0081] ;

[0082] Among them, D (p, q) is the distance function of p and q, and the distance between two objects can be calculated using methods such as Euclidean distance or Manhattan distance.

[0083] In the data sample, OPTICS is used to perform cluster analysis on the data and obtain all clusters.

[0084] In this embodiment, the execution subject of the method may be a computing device such as a computer or a server, and no limitation is made in this embodiment.

[0085] In this embodiment, the execution subject of the method may also be a smart device such as a smart phone, a tablet computer, etc., which is not limited in this embodiment.

[0086] It can be seen that the connection pool splitting method described in this embodiment can be implemented through intelligent splitting of the database connection pool, thereby controlling the number of connections occupied by slow queries within a certain range, reducing the impact of slow queries on the database, ensuring the normal operation of the system, and improving the reliability and stability of the database. At the same time, the method can also ensure that important services of the system continue to operate normally, reduce system failures, and reduce economic losses to enterprises.

[0087] Example 2

[0088] Please see Figure 2 , Figure 2 A schematic diagram of a connection pool partitioning method is provided for an embodiment of the present application. The connection pool partitioning method includes:

[0089] S201. Collect execution statistics of query requests of the current server to be optimized.

[0090] S202: Use a clustering algorithm to perform cluster analysis on the execution statistical information to obtain analysis results.

[0091] S203: Determine the categories and total number of categories of execution statistical information.

[0092] S204: Divide the connection pool into a plurality of sub-pools, where the number of sub-pools is the total number of categories.

[0093] S205: Determine the category weight of each category according to the business type of the system.

[0094] S206: Determine all execution frequencies corresponding to each category and all response times corresponding to each category according to the execution statistical information.

[0095] In this embodiment, the execution frequency is the sql execution frequency and the response time is the sql response time.

[0096] S207: Calculate the number of connections configured for each sub-pool according to all execution frequencies, all response times, category weights, and a preset total number of configurable connections.

[0097] In this embodiment, if the data samples are divided into i classes S1, S2, S3...S i(The clusters are arranged in ascending order of the distance between the core point and the origin), and the connection pool can be divided into j sub-pools. In production systems, especially transaction systems, SQLs with high execution frequency and short execution time are mainly important transaction SQLs. It is necessary to give priority to the normal execution of these SQLs. Therefore, this method can set weights for each class according to the business type of the system: P1, P2, P3...P i For very important queries with high execution frequency and short execution time, the weight assigned to this class can be greater than 1, so that its subpool is allocated with more connections; while for SQLs that execute slowly, its class is assigned a weight value less than 1, so that it is allocated with fewer connections, further reducing the impact of slow queries on the application system.

[0098] If the total number of connections that can be configured in the connection pool is m, the number of connections configured in a sub-pool is calculated using the frequency and time consumption of all queries in this cluster. The formula is as follows:

[0099] ;

[0100] CP j Indicates the number of connections configured in the jth subpool;

[0101] m represents the total number of configurable connections that can be preset;

[0102] f(S ji ) represents all execution frequencies of the i-th class in the j-th subpool;

[0103] t(S ji ) represents all response times of the i-th class in the j-th subpool;

[0104] P j represents the category weight of the jth category;

[0105] n is the total number of samples of execution statistics.

[0106] S208: When a target query request initiated by an application is received, a query statement sample and query statement parameters of the target query request are obtained.

[0107] S209: Train the original model using a preset algorithm and query statement samples to obtain a trained response prediction model.

[0108] In this embodiment, the preset algorithm is a linear regression algorithm or a nonlinear regression algorithm.

[0109] In this embodiment, the response prediction model is a SQL response time model.

[0110] S210. Estimate predicted execution information of a target query request using a pre-built response prediction model and query statement parameters; wherein the predicted execution information includes a predicted execution frequency of the target query request and a predicted response time of the target query request.

[0111] S211 . Allocate a target sub-pool and a target connection for a target query request from multiple sub-pools according to the predicted execution information.

[0112] In this embodiment, the method can use linear regression or nonlinear regression to take the SQL parameters (i.e., query statement parameters) as input feature vectors to estimate the SQL response time (i.e., predicted response time). Then, the method selects the sub-pool to be used according to the predicted response time and frequency.

[0113] S212. Connect to the database through the target sub-pool, the target connection and the target query request to perform data query and obtain the query result.

[0114] As an optional implementation, after connecting to the database through the target sub-pool, the target connection and the target query request to query data and obtaining the query result, the method further includes:

[0115] Acquire actual execution information of the query request during the preset time period when actually performing data query; wherein the actual execution information includes the actual execution frequency of the target query request during the data query and the actual response time of the target query request during the data query;

[0116] Add the actual execution information to the execution statistics to obtain updated execution information;

[0117] Use a clustering algorithm to re-perform clustering analysis on the update execution information to obtain analysis results; and execute step S203.

[0118] In this embodiment, the method can use the sub-pool to complete the database operation and record the sql information (frequency, response time). Specifically, the method can dynamically adjust the connection pool configuration according to the collected sql information during the low-peak business period in the early morning of each day.

[0119] In this embodiment, the execution subject of the method may be a computing device such as a computer or a server, and no limitation is made in this embodiment.

[0120] In this embodiment, the execution subject of the method may also be a smart device such as a smart phone, a tablet computer, etc., which is not limited in this embodiment.

[0121] It can be seen that the connection pool splitting method described in this embodiment can be implemented through intelligent splitting of the database connection pool, thereby controlling the number of connections occupied by slow queries within a certain range, reducing the impact of slow queries on the database, ensuring the normal operation of the system, and improving the reliability and stability of the database. At the same time, the method can also ensure that important services of the system continue to operate normally, reduce system failures, and reduce economic losses to enterprises.

[0122] Example 3

[0123] Please see Figure 3 , Figure 3 The schematic diagram of the structure of a connection pool sub-pool device provided in the embodiment of the present application. Figure 3 As shown, the connection pool sub-pool device includes:

[0124] The collecting unit 310 is used to collect the execution statistics of the query request of the current server to be optimized;

[0125] A clustering unit 320, configured to perform cluster analysis on the execution statistical information using a clustering algorithm to obtain an analysis result;

[0126] A pooling unit 330 is used to divide the connection pool into multiple sub-pools according to the analysis result, and allocate a corresponding number of connections to each sub-pool;

[0127] The allocation unit 340 is configured to allocate a target sub-pool and a target connection to the target query request according to the multiple sub-pools when receiving a target query request initiated by an application;

[0128] The query unit 350 is used to connect to the database through the target sub-pool, the target connection and the target query request to perform data query and obtain the query result.

[0129] In this embodiment, the explanation of the connection pool sub-pool device can refer to the description in Embodiment 1 or Embodiment 2, and will not be further elaborated in this embodiment.

[0130] It can be seen that the connection pool sub-pooling device described in this embodiment can be implemented to intelligently sub-pool the database connection pool, thereby controlling the number of connections occupied by slow queries within a certain range, thereby reducing the impact of slow queries on the database, ensuring the normal operation of the system, and improving the reliability and stability of the database. At the same time, the device can also ensure that important services of the system continue to operate normally, reduce system failures, and reduce economic losses of enterprises.

[0131] Example 4

[0132] Please see Figure 4 , Figure 4 The schematic diagram of the structure of a connection pool sub-pool device provided in the embodiment of the present application. Figure 4As shown, the connection pool sub-pool device includes:

[0133] The collecting unit 310 is used to collect the execution statistics of the query request of the current server to be optimized;

[0134] A clustering unit 320, configured to perform cluster analysis on the execution statistical information using a clustering algorithm to obtain an analysis result;

[0135] A pooling unit 330 is used to divide the connection pool into multiple sub-pools according to the analysis result, and allocate a corresponding number of connections to each sub-pool;

[0136] The allocation unit 340 is configured to allocate a target sub-pool and a target connection to the target query request according to the multiple sub-pools when receiving a target query request initiated by an application;

[0137] The query unit 350 is used to connect to the database through the target sub-pool, the target connection and the target query request to perform data query and obtain the query result.

[0138] As an optional implementation, the allocating unit 340 includes:

[0139] The acquisition subunit 341 is used to acquire the query statement parameters of the target query request when receiving the target query request initiated by the application;

[0140] The estimation subunit 342 is used to estimate the predicted execution information of the target query request by using the pre-built response prediction model and query statement parameters; wherein the predicted execution information includes the predicted execution frequency of the target query request and the predicted response time of the target query request;

[0141] The allocation subunit 343 is used to allocate a target subpool and a target connection for a target query request from multiple subpools according to the prediction execution information.

[0142] As an optional implementation, the connection pool sub-pool device further includes:

[0143] The acquisition unit 360 is used to connect to the database through the target sub-pool, the target connection and the target query request to perform data query, and after obtaining the query result, obtain the actual execution information of the query request when actually performing data query within a preset time period; wherein the actual execution information includes the actual execution frequency of the target query request when performing data query and the actual response time of the target query request when performing data query;

[0144] An adding unit 370, configured to add the actual execution information to the execution statistical information to obtain updated execution information;

[0145] The clustering unit 320 is further configured to use a clustering algorithm to re-cluster the update execution information to obtain an analysis result; and trigger the pool division unit to divide the connection pool into a plurality of sub-pools according to the analysis result.

[0146] As an optional implementation manner, the allocating unit 340 further includes:

[0147] The acquisition subunit 341 is further used to acquire a query statement sample before estimating the predicted execution information of the target query request through the pre-built response prediction model and query statement parameters;

[0148] The training subunit 344 is used to train the original model through a preset algorithm and query sentence samples to obtain a trained response prediction model.

[0149] As an optional implementation, the pooling unit 330 includes:

[0150] A determination subunit 331 is used to determine the categories and the total number of categories of the execution statistics information;

[0151] A division subunit 332, for dividing the connection pool into a plurality of sub-pools, the number of which is the total number of categories;

[0152] The determination subunit 331 is further used to determine the category weight of each category according to the service type of the system;

[0153] The determination subunit 331 is further used to determine all execution frequencies corresponding to each category and all response times corresponding to each category according to the execution statistical information;

[0154] The calculation subunit 333 is used to calculate the number of connections configured for each sub-pool according to all execution frequencies, all response times, category weights and a preset total number of configurable connections.

[0155] In this embodiment, the explanation of the connection pool sub-pool device can refer to the description in Embodiment 1 or Embodiment 2, and will not be further elaborated in this embodiment.

[0156] It can be seen that the connection pool sub-pooling device described in this embodiment can be implemented to intelligently sub-pool the database connection pool, thereby controlling the number of connections occupied by slow queries within a certain range, thereby reducing the impact of slow queries on the database, ensuring the normal operation of the system, and improving the reliability and stability of the database. At the same time, the device can also ensure that important services of the system continue to operate normally, reduce system failures, and reduce economic losses of enterprises.

[0157] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the connection pool partitioning method in Embodiment 1 or Embodiment 2 of the present application.

[0158] An embodiment of the present application provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and executed by a processor, the connection pool partitioning method in Embodiment 1 or Embodiment 2 of the present application is executed.

[0159] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0160] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0161] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.

[0162] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.

[0163] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0164] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

Claims

1. A connection pool sub-pooling method, characterized in that: include: Collect the execution statistics of the query request of the current server to be optimized; wherein the execution statistics include SQL execution time and frequency; Using a clustering algorithm to perform cluster analysis on the execution statistical information to obtain an analysis result; According to the analysis result, the connection pool is divided into a plurality of sub-pools, and a corresponding number of connections is allocated to each sub-pool; When receiving a target query request initiated by an application, allocating a target sub-pool and a target connection to the target query request according to the plurality of sub-pools; Connecting to a database through the target sub-pool, the target connection and the target query request to perform data query and obtain query results; Wherein, allocating a target sub-pool and a target connection to the target query request according to the plurality of sub-pools comprises: Obtaining query statement parameters of the target query request; By using a pre-built response prediction model and the query statement parameters, the predicted execution information of the target query request is estimated; wherein the predicted execution information includes the predicted execution frequency of the target query request and the predicted response time of the target query request; Allocating a target sub-pool and a target connection for the target query request from the plurality of sub-pools according to the predicted execution information; Before estimating the predicted execution information of the target query request by using the pre-built response prediction model and the query statement parameters, the method further includes: Get query statement samples; The original model is trained by using a preset algorithm and the query sentence sample to obtain a trained response prediction model; According to the analysis result, the connection pool is divided into a plurality of sub-pools, and a corresponding number of connections is allocated to each sub-pool, including: Determining the categories and total number of categories of the execution statistics information; Divide the connection pool into multiple sub-pools, the number of which is the total number of categories; Determining a category weight for each of the categories based on the business type of the system; The corresponding weight is greater than the weight corresponding to the slow-executing category; Determine, according to the execution statistical information, all execution frequencies corresponding to each of the categories and all response times corresponding to each of the categories; Calculate the number of connections configured for each of the sub-pools according to all the execution frequencies, all the response times, the category weights, and a preset total number of configurable connections; The categories include a first category and a second category, the first category corresponds to a high execution frequency, the first category also corresponds to a short response time; the second category corresponds to a long response time; the category weight of the first category is greater than the category weight of the second category; The calculation formula for calculating the number of connections configured for each sub-pool is: ; Among them, CP j represents the number of connections configured in the jth sub-pool; m represents the total number of configurable connections; f(S ji ) represents all execution frequencies of the i-th class in the j-th subpool; t(S ji ) represents all response times of the i-th class in the j-th subpool; P j represents the class weight of the jth class; n represents the total number of samples for executing statistical information.

2. The connection pool sub-pooling method according to claim 1, characterized in that: After the database is connected to perform data query through the target sub-pool, the target connection and the target query request to obtain the query result, the method further includes: Acquire actual execution information of the query request when actually performing data query within a preset time period; wherein the actual execution information includes the actual execution frequency of the target query request when performing data query and the actual response time of the target query request when performing data query; Adding the actual execution information to the execution statistical information to obtain updated execution information; A clustering algorithm is used to re-perform clustering analysis on the update execution information to obtain an analysis result; and the connection pool is divided into a plurality of sub-pools according to the analysis result.

3. A connection pool sub-pool device, characterized in that: The connection pool sub-pool device comprises: A collecting unit, used to collect execution statistics of the query request of the current server to be optimized; wherein the execution statistics include SQL execution time and frequency; A clustering unit, used for performing cluster analysis on the execution statistical information using a clustering algorithm to obtain an analysis result; A pool division unit, used to divide the connection pool into multiple sub-pools according to the analysis result, and allocate a corresponding number of connections to each sub-pool; an allocating unit, configured to allocate a target sub-pool and a target connection to the target query request according to the plurality of sub-pools when receiving a target query request initiated by an application; A query unit, used to connect to a database through the target sub-pool, the target connection and the target query request to perform data query and obtain a query result; Wherein, the allocation unit comprises: An acquisition subunit, configured to acquire query statement parameters of a target query request when receiving a target query request initiated by an application; An estimation subunit, configured to estimate the predicted execution information of the target query request by using a pre-built response prediction model and the query statement parameters; wherein the predicted execution information includes the predicted execution frequency of the target query request and the predicted response time of the target query request; an allocating subunit, configured to allocate a target subpool and a target connection for the target query request from the plurality of subpools according to the predicted execution information; Wherein, the connection pool sub-pool device also includes: An acquisition unit is used to obtain actual execution information of the query request when actually performing data query within a preset time period after connecting to the database through the target sub-pool, the target connection and the target query request to perform data query and obtaining the query result; wherein the actual execution information includes the actual execution frequency of the target query request when performing data query and the actual response time of the target query request when performing data query; an adding unit, configured to add the actual execution information to the execution statistical information to obtain updated execution information; The clustering unit is further used to re-cluster the update execution information using a clustering algorithm to obtain an analysis result; and trigger the pool division unit to divide the connection pool into multiple sub-pools according to the analysis result; Wherein, the sub-pool unit comprises: A determination subunit, used to determine the category and total number of categories of the execution statistical information; A division subunit, used for dividing the connection pool into a plurality of sub-pools, the number of which is the total number of categories; The determination subunit is further used to determine the category weight of each category according to the service type of the system; The determining subunit is further used to determine all execution frequencies corresponding to each of the categories and all response times corresponding to each of the categories according to the execution statistical information; A calculation subunit, configured to calculate the number of connections configured for each of the subpools according to all the execution frequencies, all the response times, the category weights, and a preset total number of configurable connections; The categories include a first category and a second category, the first category corresponds to a high execution frequency, the first category also corresponds to a short response time; the second category corresponds to a long response time; the category weight of the first category is greater than the category weight of the second category; The calculation formula for calculating the number of connections configured for each sub-pool is: ; Among them, CP j represents the number of connections configured in the jth sub-pool; m represents the total number of configurable connections; f(S ji ) represents all execution frequencies of the i-th class in the j-th subpool; t(S ji ) represents all response times of the i-th class in the j-th subpool; P j represents the class weight of the jth class; n represents the total number of samples for executing statistical information.

4. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the connection pool partitioning method according to any one of claims 1 to 2.

5. A readable storage medium, characterized in that: The readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the connection pool partitioning method according to any one of claims 1 to 2 is executed.