A dynamic database connection pool adjustment method and system
By collecting real-time operational status data of the dynamic database connection pool through the configuration center, and calculating the connection number adjustment index in conjunction with connection requests, the maximum number of connections in the connection pool is dynamically updated. This solves the problem that a single fixed connection pool configuration cannot meet business needs, and improves the service capabilities of the connection pool and the stability of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUANENG INFORMATION TECH CO LTD
- Filing Date
- 2024-04-30
- Publication Date
- 2026-06-05
AI Technical Summary
In existing technologies, a single, fixed database connection pool configuration is difficult to meet the needs of business development, resulting in excessive performance overhead, affecting website response speed, and may even cause server crashes.
The configuration center collects real-time operational status data of the dynamic database connection pool, calculates the connection number adjustment index based on connection requests, and dynamically updates the maximum number of connections in the connection pool to optimize the service capacity of the connection pool.
This improved the connection pool's external service capabilities, ensured the stable operation of business systems, and avoided performance issues caused by improper connection pool configuration.
Smart Images

Figure CN119474046B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method and system for adjusting dynamic database connection pools. Background Technology
[0002] Database connections are a critical, limited, and expensive resource. Creating and releasing database connections is a time-consuming operation, and frequent such operations consume significant performance resources, leading to decreased website response times and, in severe cases, server crashes. To conserve performance, application systems typically employ database connection pools. However, with the rapid growth of businesses today, a single, fixed database connection pool configuration is no longer sufficient to meet the needs of business development.
[0003] Therefore, the present invention provides a dynamic database connection pool adjustment method and system to dynamically adjust the maximum number of connections in the connection pool, thereby effectively improving the external service capabilities of the connection pool and ensuring the stable operation of the business system. Summary of the Invention
[0004] This invention provides a dynamic database connection pool adjustment method and system, which utilizes the real-time collected operating status data of the target dynamic database connection pool from the configuration center, calculates the connection number adjustment index by combining it with connection requests, and then uses the connection number adjustment index to dynamically update the maximum number of connections in the connection pool, thereby effectively improving the external service capability of the connection pool and ensuring the stable operation of the business system.
[0005] This invention provides a method for adjusting a dynamic database connection pool, comprising:
[0006] Step 1: Collect the running status data of the target dynamic database connection pool in real time and send it to the configuration center;
[0007] Step 2: The configuration center determines the connection number adjustment index based on the received connection pool's running status data and the current target dynamic database connection pool's connection requests;
[0008] Step 3: Based on the number of connections, adjust the index, configure the center to dynamically update the maximum number of connections in the connection pool, and notify the connection pool module to update.
[0009] Preferably, the runtime status data of the target dynamic database connection pool is collected in real time and sent to the configuration center, including:
[0010] Create a pre-built connection pool interface;
[0011] The target client uses the pre-set connection pool interface to collect real-time running status data of the target dynamic database connection pool;
[0012] The configuration center receives the running status data sent by the target client.
[0013] Preferably, the configuration center is used to store and manage connection pool configurations, and supports dynamic configuration updates at runtime without requiring a service restart.
[0014] Preferably, the configuration center determines the connection number adjustment index based on the received connection pool's operational status data and the current target dynamic database connection pool's connection requests, including:
[0015] Obtain connection requests from the target dynamic database connection pool and determine the number of new connections;
[0016] The number of idle connections in the current connection pool's running status data is extracted and compared with the number of newly added connections;
[0017] If the number of idle connections is not less than the number of new connections, and the difference is greater than the preset difference threshold, then the output connection number adjustment index is zero.
[0018] If the number of idle connections is not less than the number of new connections, and the difference is not greater than a preset difference threshold, then the number of new connections is used to adjust the current running status data to obtain the pre-running status data for the next time.
[0019] Extract the historical number of new connections within a preset time period from the connection request database and treat it as the first data;
[0020] A regression prediction algorithm is introduced to predict the number of new connections at the next time step based on the first data.
[0021] The number of new connections at the next moment is combined with the pre-running status data as key data for analysis to obtain the connection number adjustment index;
[0022] If the number of idle connections is less than the number of new connections, the number of new connections is combined with the current operating status data as key data for analysis to obtain the connection number adjustment index.
[0023] Preferably, the formula for calculating the connection number adjustment index is as follows:
[0024] In the formula, L represents the connection number adjustment index; This represents the maximum number of connections in the connection pool at the current moment. This represents the number of idle connections at the current moment. This represents the number of new connections at the current moment. This represents the number of connections released at the current moment; This is expressed as the average difference between the number of new connections and the number of released connections at each moment during the expected stable connection pool period t. This represents the impact index of the current connection addition and release status on the stability of the connection pool; m represents the number of connections in the connection pool with a reference count greater than the preset reference threshold at the current moment. This represents the current utilization of data connections in the connection pool. This is expressed as an index representing the impact of data connection reference frequency on the stability of the connection pool. This represents the fine-tuning coefficient for adjusting the connection pool stability index based on the number of connections. This is expressed as the loss factor generated by calculating the connection number adjustment index; Represents a constant.
[0025] Preferably, based on the connection number adjustment index, the configuration center dynamically updates the maximum number of connections in the connection pool and notifies the connection pool module to update, including:
[0026] The connection adjustment index is compared with a preset state adjustment threshold. When the connection adjustment index is not greater than the preset state adjustment threshold, it is determined that the current target dynamic database connection pool does not need to update the maximum number of connections in the connection pool.
[0027] Otherwise, it is determined that the current target dynamic database connection pool needs to update the maximum number of connections. In this case, the connection number adjustment index is used to calculate the mode selection index, where the calculation formula for the mode selection index is as follows:
[0028] In the formula, Represented as the pattern selection index; This represents the connection number adjustment exponent at time t. This is represented as a preset adjustment threshold; This is represented as the preset mode selection factor;
[0029] If the mode selection index is in the emergency adjustment index range, then the current connection update mode is determined to be the emergency adjustment mode;
[0030] If the mode selection index is within the dynamic adjustment index range, then the current connection update mode is determined to be the dynamic adjustment mode;
[0031] The maximum number of connections in the current connection pool is adjusted using the calculated connection number adjustment index to obtain the optimized maximum number of connections;
[0032] Based on the connection update mode and the optimized maximum number of connections, the configuration center matching the current connection pool generates an update notification;
[0033] Decouple the configuration center of the current connection pool from the business logic;
[0034] The system receives update notifications generated by the configuration center through a pre-created configuration update interface, and then uses an asynchronous notification mechanism to notify the connection pool module to perform updates.
[0035] When the connection update mode in the update notification received by the connection pool module is emergency adjustment mode, the maximum number of connections will be updated to the optimized maximum number of connections.
[0036] When the connection update mode in the update notification received by the connection pool module is dynamic adjustment mode, the number of connection updates for each time is obtained;
[0037] The maximum number of connections is dynamically updated using the number of connections updated each time until it is updated to the optimized maximum number of connections.
[0038] Preferably, the number of updates per connection is obtained, including:
[0039] Extract the historical number of released connections and the historical number of deleted connections from the current key data in the connection pool database, and construct the connection release curve and the connection deletion curve respectively.
[0040] By analyzing the connection release curve and the connection deletion curve, the characteristic values of connection release change and deletion change of the current connection pool can be obtained in sequence.
[0041] Obtain the proportion of connections whose release time is greater than the average release time of connections in the key data, and consider it as the first proportion;
[0042] The proportion of connections whose release time is no greater than the average release time of connections in the key data is considered as the second proportion.
[0043] The reusability coefficient of the connection pool is calculated by combining the release connection change characteristic value, the first ratio, the second ratio, and the deletion change characteristic value.
[0044] The abnormal waiting coefficient of data connections in the connection pool is calculated by using the average frequency of connection timeouts and the average number of connection retries due to timeouts from the key data.
[0045] The connection number update index is calculated by weighting the reusability coefficient and abnormal waiting coefficient of the connection pool.
[0046] The optimized maximum number of connections is compared with the maximum number of connections in the connection pool at the current moment to determine the connection difference.
[0047] The connection update index and connection difference are analyzed and calculated to determine the number of connection updates each time.
[0048] This invention provides a dynamic database connection pool adjustment system, comprising:
[0049] Data acquisition module: Collects real-time running status data of the target dynamic database connection pool and sends it to the configuration center;
[0050] Index Analysis Module: The configuration center determines the connection number adjustment index based on the received connection pool operation status data and the current target dynamic database connection requests;
[0051] Adjustment module: Based on the number of connections, adjust the index, dynamically update the maximum number of connections in the connection pool in the configuration center, and notify the connection pool module to update.
[0052] Compared with the prior art, the beneficial effects of this application are as follows:
[0053] By utilizing the configuration center to collect real-time operational status data of the target dynamic database connection pool, and combining this data with connection requests to calculate a connection number adjustment index, the maximum number of connections in the connection pool is dynamically updated using this index. This effectively improves the connection pool's external service capabilities and ensures the stable operation of the business system.
[0054] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.
[0055] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0056] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0057] Figure 1 This is a flowchart of a dynamic database connection pool adjustment method according to an embodiment of the present invention;
[0058] Figure 2 This is a structural diagram of a dynamic database connection pool adjustment system according to an embodiment of the present invention. Detailed Implementation
[0059] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0060] This invention provides a method for adjusting a dynamic database connection pool, such as... Figure 1 As shown, it includes:
[0061] Step 1: Collect the running status data of the target dynamic database connection pool in real time and send it to the configuration center;
[0062] Step 2: The configuration center determines the connection number adjustment index based on the received connection pool's running status data and the current target dynamic database connection pool's connection requests;
[0063] Step 3: Based on the number of connections, adjust the index, configure the center to dynamically update the maximum number of connections in the connection pool, and notify the connection pool module to update.
[0064] In this embodiment, the database connection pool refers to the creation of a certain number of database connection objects during program initialization and their storage in a memory area. It allows the application to reuse an existing database connection instead of establishing a new one. The running status data includes the number of connected connections, the number of idle connections, the average connection release time, the average connection timeout frequency, and the average number of connection retries after timeout, etc.
[0065] In this embodiment, the configuration center is used to store and manage the connection pool configuration, and to support dynamic updates of the configuration at runtime without restarting the service; the connection number adjustment index is used to adjust the maximum number of connections in the connection pool at the current moment to obtain the optimized maximum number of connections; the connection pool module is used to update the maximum number of connections based on the received update notification.
[0066] The beneficial effects of the above technical solution are: by utilizing the configuration center to collect real-time running status data of the target dynamic database connection pool, and combining it with connection requests to calculate the connection number adjustment index, the maximum number of connections in the connection pool is dynamically updated using the connection number adjustment index, thereby effectively improving the external service capability of the connection pool and ensuring the stable operation of the business system.
[0067] This invention provides a method for adjusting a dynamic database connection pool, which involves real-time collection of the operating status data of the target dynamic database connection pool and sending it to a configuration center, including:
[0068] Create a pre-built connection pool interface;
[0069] The target client uses the pre-set connection pool interface to collect real-time running status data of the target dynamic database connection pool;
[0070] The configuration center receives the running status data sent by the target client.
[0071] In this embodiment, a pre-configured connection pool interface is used to collect the running status data of the target dynamic database connection pool in real time. The running status data includes the number of connected connections, the number of idle connections, the average connection release time, the average connection timeout frequency, and the average number of connection retries after timeout, etc.
[0072] In this embodiment, the target client refers to the target platform that needs to use a database connection; the configuration center is used to store and manage the connection pool configuration, and supports dynamic updates of the configuration at runtime without restarting the service.
[0073] The beneficial effects of the above technical solution are: by creating a pre-set connection pool interface, the target client collects the running status data of the target dynamic database connection pool in real time, and the configuration center receives the running status data sent by the target client, providing data support for subsequent adjustments to the dynamic database connection pool.
[0074] This invention provides a method for adjusting a dynamic database connection pool. The configuration center determines a connection number adjustment index based on received connection pool operation status data and the current connection requests for the target dynamic database connection pool. The method includes:
[0075] Obtain connection requests from the target dynamic database connection pool and determine the number of new connections;
[0076] The number of idle connections in the current connection pool's running status data is extracted and compared with the number of newly added connections;
[0077] If the number of idle connections is not less than the number of new connections, and the difference is greater than the preset difference threshold, then the output connection number adjustment index is zero.
[0078] If the number of idle connections is not less than the number of new connections, and the difference is not greater than a preset difference threshold, then the number of new connections is used to adjust the current running status data to obtain the pre-running status data for the next time.
[0079] Extract the historical number of new connections within a preset time period from the connection request database and treat it as the first data;
[0080] A regression prediction algorithm is introduced to predict the number of new connections at the next time step based on the first data.
[0081] The number of new connections at the next moment is combined with the pre-running status data as key data for analysis to obtain the connection number adjustment index;
[0082] If the number of idle connections is less than the number of new connections, the number of new connections is combined with the current operating status data as key data for analysis to obtain the connection number adjustment index.
[0083] In this embodiment, a connection request refers to a connection request sent by the target client to the target dynamic database connection pool; the database connection pool refers to a certain number of database connection objects created during program initialization and stored in a memory area, which allows the application to reuse an existing database connection instead of establishing a new one; the number of new connections refers to the number of database connection requests from the target client at the current moment.
[0084] In this embodiment, the number of idle connections refers to the number of idle connections in the connection pool; the preset difference threshold is set in advance.
[0085] In this embodiment, the pre-running status data refers to the running status data obtained by adjusting the current running status data using the number of new connections, including the estimated number of connected connections, the estimated number of idle connections, etc.; the preset time period is set in advance; the key data refers to the number of new connections and running status data at the current moment, or the number of new connections and pre-running status data at the next moment.
[0086] In this embodiment, the connection request database is composed of connection request data, including request time, number of connection requests, request sending address, etc.; the first data refers to the historical number of newly added connections, that is, the number of historical requests from the target client to connect to the database; the connection number adjustment index is used to adjust the maximum number of connections in the connection pool at the current moment to obtain the optimized maximum number of connections.
[0087] The beneficial effects of the above technical solution are: by combining and analyzing the operation status data and connection requests of the connection pool through the configuration center, the connection number adjustment index is calculated to adjust the maximum number of connections of the connection pool at the current moment, so as to accurately obtain the maximum number of connections to meet the connection requests of the current connection pool, thereby ensuring the effective service capacity of the connection pool.
[0088] This invention provides a method for adjusting a dynamic database connection pool. The formula for calculating the connection number adjustment index is as follows:
[0089] In the formula, L represents the connection number adjustment index; This represents the maximum number of connections in the connection pool at the current moment. This represents the number of idle connections at the current moment. This represents the number of new connections at the current moment. This represents the number of connections released at the current moment; This is expressed as the average difference between the number of new connections and the number of released connections at each moment during the expected stable connection pool period t. This represents the impact index of the current connection addition and release status on the stability of the connection pool; m represents the number of connections in the connection pool with a reference count greater than the preset reference threshold at the current moment. This represents the current utilization of data connections in the connection pool. This is expressed as an index representing the impact of data connection reference frequency on the stability of the connection pool. This represents the fine-tuning coefficient for adjusting the connection pool stability index based on the number of connections. This is expressed as the loss factor generated by calculating the connection number adjustment index; Represents a constant.
[0090] The beneficial effects of the above technical solution are: by combining the number of new connections and the running status data to calculate the connection number adjustment index, the maximum number of connections in the dynamic database connection pool can be adjusted, thereby effectively improving the external service capabilities of the connection pool and ensuring the stable operation of the business system.
[0091] This invention provides a dynamic database connection pool adjustment method, which adjusts the connection pool based on the connection number adjustment index, dynamically updates the maximum number of connections in the connection pool in the configuration center, and notifies the connection pool module to update, including:
[0092] The connection adjustment index is compared with a preset state adjustment threshold. When the connection adjustment index is not greater than the preset state adjustment threshold, it is determined that the current target dynamic database connection pool does not need to update the maximum number of connections in the connection pool.
[0093] Otherwise, it is determined that the current target dynamic database connection pool needs to update the maximum number of connections. In this case, the connection number adjustment index is used to calculate the mode selection index, where the calculation formula for the mode selection index is as follows:
[0094] In the formula, Represented as the pattern selection index; This represents the connection number adjustment exponent at time t. This is represented as a preset adjustment threshold; This is represented as the preset mode selection factor;
[0095] If the mode selection index is in the emergency adjustment index range, then the current connection update mode is determined to be the emergency adjustment mode;
[0096] If the mode selection index is within the dynamic adjustment index range, then the current connection update mode is determined to be the dynamic adjustment mode;
[0097] The maximum number of connections in the current connection pool is adjusted using the calculated connection number adjustment index to obtain the optimized maximum number of connections;
[0098] Based on the connection update mode and the optimized maximum number of connections, the configuration center matching the current connection pool generates an update notification;
[0099] Decouple the configuration center of the current connection pool from the business logic;
[0100] The system receives update notifications generated by the configuration center through a pre-created configuration update interface, and then uses an asynchronous notification mechanism to notify the connection pool module to perform updates.
[0101] When the connection update mode in the update notification received by the connection pool module is emergency adjustment mode, the maximum number of connections will be updated to the optimized maximum number of connections.
[0102] When the connection update mode in the update notification received by the connection pool module is dynamic adjustment mode, the number of connection updates for each time is obtained;
[0103] The maximum number of connections is dynamically updated using the number of connections updated each time until it is updated to the optimized maximum number of connections.
[0104] In this embodiment, the preset state adjustment threshold is set in advance; the mode selection index is used to determine the current connection update mode, wherein the connection update mode includes two modes: emergency adjustment mode and dynamic adjustment mode; the emergency adjustment mode refers to immediately updating the maximum number of connections in the connection pool at the current moment to the optimized maximum number of connections; the dynamic adjustment mode refers to updating the maximum number of connections multiple times based on the number of connections updated each time until the optimized maximum number of connections is reached; the optimized maximum number of connections is obtained by adjusting the maximum number of connections in the current connection pool using the calculated connection number adjustment index.
[0105] In this embodiment, the update notification refers to the one generated by the configuration center based on the optimized maximum number of connections and the selected connection update mode, and is received by the pre-created configuration update interface. The purpose of decoupling the configuration center from the business logic is to enable the connection pool to independently adjust the maximum number of connections based on the updates from the configuration center. The configuration update interface is used to receive the update notification generated by the configuration center.
[0106] In this embodiment, the asynchronous notification mechanism refers to a mechanism that allows a process or thread to be notified when an event occurs and to take immediate action without being blocked. It is used to notify the connection pool module to update the connection pool module based on the connection update mode.
[0107] The beneficial effects of the above technical solution are as follows: by adjusting the maximum number of connections in the current connection pool using the connection number adjustment index, an optimized maximum number of connections is obtained; the connection update mode is determined and combined with the optimized maximum number of connections, and the configuration center generates an update notification; the configuration update interface is used to receive the update notification generated by the configuration center, and then the connection pool module is notified to accurately update the maximum number of connections according to the asynchronous notification mechanism, which can effectively improve the external service capabilities of the connection pool.
[0108] This invention provides a method for adjusting a dynamic database connection pool, which obtains the number of connection updates each time, including:
[0109] Extract the historical number of released connections and the historical number of deleted connections from the current key data in the connection pool database, and construct the connection release curve and the connection deletion curve respectively.
[0110] By analyzing the connection release curve and the connection deletion curve, the characteristic values of connection release change and deletion change of the current connection pool can be obtained in sequence.
[0111] Obtain the proportion of connections whose release time is greater than the average release time of connections in the key data, and consider it as the first proportion;
[0112] The proportion of connections whose release time is no greater than the average release time of connections in the key data is considered as the second proportion.
[0113] The reusability coefficient of the connection pool is calculated by combining the release connection change characteristic value, the first ratio, the second ratio, and the deletion change characteristic value.
[0114] The abnormal waiting coefficient of data connections in the connection pool is calculated by using the average frequency of connection timeouts and the average number of connection retries due to timeouts from the key data.
[0115] The connection number update index is calculated by weighting the reusability coefficient and abnormal waiting coefficient of the connection pool.
[0116] The optimized maximum number of connections is compared with the maximum number of connections in the connection pool at the current moment to determine the connection difference.
[0117] The connection update index and connection difference are analyzed and calculated to determine the number of connection updates each time.
[0118] In this embodiment, the connection pool related database is a database composed of operational status data such as historical connection release data, connection deletion data, connection pool utilization, average connection timeout frequency, and average number of connection retries after timeout; the historical preset time period is set in advance.
[0119] In this embodiment, the historical number of released connections refers to the number of database connections released by the client at each moment within a preset historical time period; the historical number of deleted connections refers to the number of connections deleted by the connection pool at each moment within a preset historical time period whose reference count is greater than a specified value.
[0120] In this embodiment, the connection release curve is constructed from the historical number of connections released over a preset time period; the connection deletion curve is constructed from the historical number of connections deleted over a preset time period; the connection release change feature value is used to describe the change characteristics of the connection release in the connection pool over a certain period of time; and the deletion change feature value is used to describe the change characteristics of the connection deletion in the connection pool over a certain period of time.
[0121] In this embodiment, the first ratio refers to the proportion of connections whose release time is greater than the average release time of connections in the key data to the total number of connections in the connection pool; the second ratio refers to the proportion of connections whose release time is not greater than the average release time of connections in the key data to the total number of connections in the connection pool.
[0122] In this embodiment, the reusability coefficient is used to describe the resource reuse status of the connection pool at the current moment; the abnormal waiting coefficient is used to describe the connection abnormality and handling status of the connection pool; the connection number update index is an index that determines the number of connection updates each time based on the analysis of the reusability coefficient, the abnormal waiting coefficient and the connection difference. It can also be used to describe the performance of the connection pool at the current moment, where the connection difference refers to the difference between the maximum number of optimized connections and the maximum number of connections in the connection pool at the current moment.
[0123] The beneficial effects of the above technical solution are as follows: by combining the analysis of connection pool release, connection deletion and abnormal waiting handling, the connection number update index is calculated; by analyzing the difference between the connection number update index and the maximum number of optimized connections and the maximum number of connections in the connection pool at the current time, the number of connections updated each time is obtained, thereby ensuring the dynamic update effect of the maximum number of connections in the dynamic adjustment mode.
[0124] This invention provides a dynamic database connection pool adjustment system, such as... Figure 2 As shown, it includes:
[0125] Data acquisition module: Collects real-time running status data of the target dynamic database connection pool and sends it to the configuration center;
[0126] Index Analysis Module: The configuration center determines the connection number adjustment index based on the received connection pool operation status data and the current target dynamic database connection requests;
[0127] Adjustment module: Based on the number of connections, adjust the index, dynamically update the maximum number of connections in the connection pool in the configuration center, and notify the connection pool module to update.
[0128] The beneficial effects of the above technical solution are: by utilizing the configuration center to collect real-time running status data of the target dynamic database connection pool, and combining it with connection requests to calculate the connection number adjustment index, the maximum number of connections in the connection pool is dynamically updated using the connection number adjustment index, thereby effectively improving the external service capability of the connection pool and ensuring the stable operation of the business system.
[0129] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for adjusting a dynamic database connection pool, characterized in that, include: Step 1: Collect the running status data of the target dynamic database connection pool in real time and send it to the configuration center; Step 2: The configuration center determines the connection number adjustment index based on the received connection pool's running status data and the current target dynamic database connection pool's connection requests; Step 3: Based on the number of connections, adjust the index, configure the center to dynamically update the maximum number of connections in the connection pool, and notify the connection pool module to update it; The configuration center determines the connection number adjustment index based on the received connection pool's operational status data and the current connection requests for the target dynamic database connection pool, including: Obtain connection requests from the target dynamic database connection pool and determine the number of new connections; The number of idle connections in the current connection pool's running status data is extracted and compared with the number of newly added connections; If the number of idle connections is not less than the number of new connections, and the difference is greater than the preset difference threshold, then the output connection number adjustment index is zero. If the number of idle connections is not less than the number of new connections, and the difference is not greater than a preset difference threshold, then the number of new connections is used to adjust the current running status data to obtain the pre-running status data for the next time. Extract the historical number of new connections within a preset time period from the connection request database and treat it as the first data; A regression prediction algorithm is introduced to predict the number of new connections at the next time step based on the first data. The number of new connections at the next moment is combined with the pre-running status data as key data for analysis to obtain the connection number adjustment index; If the number of idle connections is less than the number of new connections, the number of new connections is combined with the current running status data as key data for analysis to obtain the connection number adjustment index. The formula for calculating the connection number adjustment index is as follows: In the formula, L represents the connection number adjustment index; This represents the maximum number of connections in the connection pool at the current moment. This represents the number of idle connections at the current moment. This represents the number of new connections at the current moment. This represents the number of connections released at the current moment; denoted as the average difference between the number of new connections and the number of released connections at each moment within the expected stable connection pool period t; μ1 represents the impact index of the current connection addition-release situation on the stability of the connection pool; m represents the number of connections in the connection pool with a reference count greater than the preset reference threshold at the current moment; denoted as the utilization of data connections in the connection pool at the current moment; μ2 represents the impact index of data connection reference frequency on the stability of the connection pool; ρ represents the fine-tuning coefficient of the connection pool stability adjustment index for the number of connections; δ represents the loss factor generated by calculating the number of connections adjustment index; and e represents a constant.
2. The dynamic database connection pool adjustment method according to claim 1, characterized in that, Real-time collection of runtime status data of the target dynamic database connection pool and sending it to the configuration center, including: Create a pre-built connection pool interface; The target client uses the pre-set connection pool interface to collect real-time running status data of the target dynamic database connection pool; The configuration center receives the running status data sent by the target client.
3. The dynamic database connection pool adjustment method according to claim 2, characterized in that, The configuration center is used to store and manage connection pool configurations, and supports dynamic configuration updates at runtime without restarting the service.
4. The dynamic database connection pool adjustment method according to claim 1, characterized in that, Based on the connection number adjustment index, the configuration center dynamically updates the maximum number of connections in the connection pool and notifies the connection pool module to update, including: The connection adjustment index is compared with a preset state adjustment threshold. When the connection adjustment index is not greater than the preset state adjustment threshold, it is determined that the current target dynamic database connection pool does not need to update the maximum number of connections in the connection pool. Otherwise, it is determined that the current target dynamic database connection pool needs to update the maximum number of connections. In this case, the connection number adjustment index is used to calculate the mode selection index, where the calculation formula for the mode selection index is as follows: In the formula, Represented as the pattern selection index; This represents the connection number adjustment exponent at time t. This is represented as a preset adjustment threshold; This is represented as the preset mode selection factor; If the mode selection index is in the emergency adjustment index range, then the current connection update mode is determined to be the emergency adjustment mode; If the mode selection index is within the dynamic adjustment index range, then the current connection update mode is determined to be the dynamic adjustment mode; The maximum number of connections in the current connection pool is adjusted using the calculated connection number adjustment index to obtain the optimized maximum number of connections; Based on the connection update mode and the optimized maximum number of connections, the configuration center matching the current connection pool generates an update notification; Decouple the configuration center of the current connection pool from the business logic; The system receives update notifications generated by the configuration center through a pre-created configuration update interface, and then uses an asynchronous notification mechanism to notify the connection pool module to perform updates. When the connection update mode in the update notification received by the connection pool module is emergency adjustment mode, the maximum number of connections will be updated to the optimized maximum number of connections. When the connection update mode in the update notification received by the connection pool module is dynamic adjustment mode, the number of connection updates for each time is obtained; The maximum number of connections is dynamically updated using the number of connections updated each time until it is updated to the optimized maximum number of connections.
5. The dynamic database connection pool adjustment method according to claim 4, characterized in that, Get the number of updates per connection, including: Extract the historical number of released connections and the historical number of deleted connections from the current key data in the connection pool database, and construct the connection release curve and the connection deletion curve respectively. By analyzing the connection release curve and the connection deletion curve, the characteristic values of connection release change and deletion change of the current connection pool can be obtained in sequence. Obtain the proportion of connections whose release time is greater than the average release time of connections in the key data, and consider it as the first proportion; The proportion of connections whose release time is no greater than the average release time of connections in the key data is considered as the second proportion. The reusability coefficient of the connection pool is calculated by combining the release connection change characteristic value, the first ratio, the second ratio, and the deletion change characteristic value. The abnormal waiting coefficient of data connections in the connection pool is calculated by using the average frequency of connection timeouts and the average number of connection retries due to timeouts from the key data. The connection number update index is calculated by weighting the reusability coefficient and abnormal waiting coefficient of the connection pool. The optimized maximum number of connections is compared with the maximum number of connections in the connection pool at the current moment to determine the connection difference. The connection update index and connection difference are analyzed and calculated to determine the number of connection updates each time.
6. A dynamic database connection pool adjustment system, characterized in that, include: Data acquisition module: Collects real-time running status data of the target dynamic database connection pool and sends it to the configuration center; Index Analysis Module: The configuration center determines the connection number adjustment index based on the received connection pool operation status data and the current target dynamic database connection requests; Adjustment module: Based on the number of connections, adjust the index, dynamically update the maximum number of connections in the connection pool in the configuration center, and notify the connection pool module to update.