Connection pool management method and device, electronic equipment and storage medium
By monitoring the resource information of the connection pool in real time and adjusting its capacity, the problem of insufficient dynamic adjustment speed of the connection pool is solved, realizing rapid response and resource optimization of the connection pool, and avoiding connection exhaustion and waste.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-03-17
AI Technical Summary
Existing technologies lack sufficient dynamic adjustment speed for connection pools, leading to connection exhaustion or resource waste, especially in high-concurrency and load-fluctuation scenarios where response is delayed.
By acquiring resource information of the connection pool within the current monitoring period, and determining when the capacity adjustment conditions are met based on the resource information, the capacity of the connection pool is adjusted in real time. The adjusted capacity is applied to the operation of the connection pool in the next monitoring period, including expansion or reduction, to avoid device restart.
This enables dynamic adjustment of connection pool capacity, improving speed and avoiding resource waste caused by connection exhaustion or idle connections, thereby enhancing system availability and resource utilization efficiency.
Smart Images

Figure CN121681084A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a method, apparatus, electronic device, and storage medium for managing connection pools. Background Technology
[0002] Connection pooling is a database connection buffering technology that optimizes application performance by pre-creating and reusing connections. Its core principle is to initialize idle connections when the server starts, allocate them directly when needed, and return them to the pool after use instead of closing them. This avoids the overhead of frequent connection establishment, reduces network and driver layer consumption, and prevents resource overload by limiting the maximum number of connections.
[0003] In some scenarios, it is necessary to be able to dynamically adjust the size of the connection pool. In high-concurrency scenarios, such as during e-commerce promotions when sudden surges in traffic may occur at any time, traditional fixed-size connection pools are prone to exhausting connection resources or causing performance bottlenecks. In scenarios with fluctuating loads, such as live streaming and big data queries where there are obvious shifts between load peaks and troughs, there is a greater need for dynamic adjustment of the connection pool.
[0004] In existing technologies, most connection pools passively adjust their dynamic settings, only expanding connections when they are exhausted. Furthermore, manual modification of connection pool parameters and a restart are required for these changes to take effect, resulting in a relatively slow response. During sudden load fluctuations, this can easily lead to connection exhaustion or increased system response latency. Under low load conditions, the connection pool's recycling speed is slow, or idle connections remain open for extended periods, causing the connection pool to occupy system resources for extended periods. Therefore, existing connection pool dynamic adjustment technologies are insufficient in speed, easily leading to connection exhaustion or resource waste. Summary of the Invention
[0005] The purpose of this invention is to provide a method, apparatus, electronic device, and storage medium for managing dynamic connection pools, thereby improving the dynamic adjustment speed of connection pools and avoiding connection exhaustion or resource waste. The specific technical solution is as follows: In a first aspect of this invention, a method for managing a dynamic connection pool is provided, comprising: Within the current monitoring period, acquire the resource information of the connection pool, which is information reflecting the performance indicators of the connection pool; When the capacity adjustment conditions are met based on the resource information, the capacity of the connection pool is adjusted, and the adjusted capacity is applied to the operation of the connection pool in the next monitoring cycle.
[0006] In a second aspect of the invention, a management device for a dynamic connection pool is also provided, comprising: The resource acquisition module is used to acquire the resource information of the connection pool within the current monitoring period. The resource information is information that reflects the performance indicators of the connection pool. The capacity adjustment module is used to adjust the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information, and the adjusted capacity is applied to the operation of the connection pool in the next monitoring cycle.
[0007] In another aspect of the present invention, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus. Memory, used to store computer programs; When a processor executes a program stored in memory, it implements the steps of any of the above-described dynamic link pool management methods.
[0008] In another aspect of the present invention, a computer-readable storage medium is also provided, wherein instructions are stored therein, which, when executed on a computer, cause the computer to perform any of the above-described dynamic connection pool management methods.
[0009] In another aspect of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the dynamic connection pool management methods described above.
[0010] The dynamic connection pool management method, device, electronic device, and storage medium provided in this invention adjust the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information of the connection pool during the current monitoring period. The adjusted capacity is then used for the operation of the connection pool in the next monitoring period. This achieves the adjustment of the connection pool capacity based on the resource information of the connection pool, and the adjustment can take effect immediately without the need for device restart. This can improve the dynamic adjustment speed of the connection pool and avoid resource waste caused by connection exhaustion or a large number of idle connections. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0012] Figure 1 This is a flowchart of a connection pool management method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a connection pool management device provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0013] The technical solutions of the present invention will now be described with reference to the accompanying drawings in the embodiments of the present invention.
[0014] Figure 1 This is a flowchart illustrating a connection pool management method provided in an embodiment of the present invention. This connection pool management method can be executed by electronic devices such as servers. Figure 1 As shown, the method may include the following steps: Step 110: Within the current monitoring period, obtain the resource information of the connection pool, which is information reflecting the performance indicators of the connection pool.
[0015] The resource information of the connection pool can include the number of active connections, the number of idle connections, request response time, queuing time, and system load (CPU, memory, I / O). The number of active connections refers to the number of connections currently processing business in the connection pool. The number of idle connections refers to the number of connections in the connection pool that are not in use. The connection pool can be any dynamically adjustable connection pool, such as HikariCP, C3P0, DBCP, or Tomcat JDBC Pool.
[0016] Within the current monitoring period, resource information of the connection pool can be collected. A monitoring period can be a fixed time length, such as collecting connection pool resource information every certain period of time (e.g., 1 second, 30 seconds, 1 minute, etc.); or, a monitoring period can also be a time length that slides according to a sliding window, that is, the resource information of the connection pool can also be statistically analyzed according to the sliding window to obtain the resource information within the sliding window, and adjacent monitoring periods can have some overlap in statistical time.
[0017] Step 120: When the capacity adjustment conditions are met based on the resource information, the capacity of the connection pool is adjusted, and the adjusted capacity is applied to the operation of the connection pool in the next monitoring cycle.
[0018] Capacity adjustment conditions may include expansion conditions and / or reduction conditions.
[0019] In one exemplary embodiment, real-time collected resource information can be compared with capacity adjustment conditions to determine whether the real-time collected resource information meets the capacity adjustment conditions. If the resource information meets the capacity adjustment conditions, the capacity of the connection pool is adjusted, and the adjusted capacity is applied to the operation of the connection pool in the next monitoring cycle. Adjusting the capacity of the connection pool can include increasing or decreasing the number of connections in the connection pool.
[0020] In another exemplary embodiment, resource information based on sliding window statistics can be compared with capacity adjustment conditions to determine whether the resource information based on sliding window statistics meets the capacity adjustment conditions. If the resource information based on sliding window statistics meets the capacity adjustment conditions, the capacity of the connection pool is adjusted, and the adjusted capacity is applied to the operation of the connection pool in the next monitoring cycle. Alternatively, the trend of resource information change can be determined based on the resource information based on sliding window statistics, and the resource information for the next monitoring cycle can be predicted based on the trend. The predicted resource information is then compared with the capacity adjustment conditions to determine whether the predicted resource information meets the capacity adjustment conditions. If the predicted resource information meets the capacity adjustment conditions, the capacity of the connection pool is adjusted.
[0021] The connection pool management method provided in this invention adjusts the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information of the connection pool during the current monitoring period. The adjusted capacity is used for the operation of the connection pool in the next monitoring period. This realizes the adjustment of the connection pool capacity based on the resource information of the connection pool. The adjustment takes effect immediately without the need for device restart, which can improve the dynamic adjustment speed of the connection pool and avoid resource waste caused by connection exhaustion or too many idle connections.
[0022] In some embodiments of the present invention, adjusting the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information may include: When the resource information meets the expansion conditions, the connection pool is expanded; or, When the resource information meets the scaling-down conditions, the connection pool is scaled down.
[0023] The capacity adjustment conditions can include expansion conditions and / or reduction conditions. Expansion conditions determine whether the number of connections in the connection pool can meet the demand. Reduction conditions determine whether there are too many idle connections in the connection pool.
[0024] When determining whether to adjust the capacity of the connection pool, you can check whether the resource information of the connection pool meets the conditions for expansion and reduction.
[0025] In an exemplary embodiment, the resource information of the connection pool can be compared with the expansion conditions to determine whether the resource information of the connection pool meets the expansion conditions. If the resource information of the connection pool meets the expansion conditions, the connection pool is expanded, that is, the number of connections in the connection pool is increased. If the resource information of the connection pool does not meet the expansion conditions, the connection pool does not need to be expanded. Based on the resource information and expansion conditions, dynamic expansion processing of the connection pool is realized, which can avoid connection exhaustion.
[0026] In another exemplary embodiment, the resource information of the connection pool can be compared with the scaling-down conditions to determine whether the resource information of the connection pool meets the scaling-down conditions. If the resource information of the connection pool meets the scaling-down conditions, the connection pool is scaled down, that is, the number of connections in the connection pool is reduced. If the resource information of the connection pool does not meet the scaling-down conditions, the connection pool does not need to be scaled down. Based on the resource information and scaling-down conditions, dynamic scaling-down processing of the connection pool is realized, which can avoid resource waste caused by a large number of idle connections.
[0027] In some embodiments of the present invention, the resource information includes the number of active connections and the number of requests in the queue; The step of expanding the connection pool when the resource information meets the expansion conditions may include: expanding the connection pool when the number of active connections is greater than a first target ratio of the current configured number of connections in the connection pool, and when the number of requests in queue is greater than a first target number.
[0028] The scaling conditions can include a first target percentage where the number of active connections exceeds the currently configured number of connections in the connection pool, and a first target number where the number of queued requests exceeds a first target number. The first target percentage and the first target number can be set according to requirements; for example, the first target percentage could be 80%, 90%, etc., and the first target number could be 0, etc. The currently configured number of connections is the maximum number of connections currently configured for the connection pool.
[0029] The system checks whether the number of active connections in the resource information is greater than the first target ratio of the current configured connection count of the connection pool, and whether the number of queued requests is greater than the first target number. If the number of active connections is greater than the first target ratio of the current configured connection count, and the number of queued requests is greater than the first target number, it indicates that there are too many requests and the number of connections in the connection pool cannot meet the demand. In this case, the connection pool can be expanded to increase the number of connections in the connection pool. If the number of active connections is not greater than the first target ratio of the current configured connection count, or the number of queued requests is less than or equal to the first target number, it indicates that the number of connections in the connection pool can meet the demand, and the connection pool does not need to be expanded.
[0030] By scaling up the connection pool when the number of active connections exceeds the first target proportion of the currently configured number of connections and the number of queued requests exceeds the first target number, the connection pool can be scaled up in a timely manner to avoid connection exhaustion.
[0031] Based on the above technical solution, the expansion process of the connection pool may include: determining the difference between the maximum number of connections in the connection pool and the current configured number of connections, determining the minimum of the difference and the second target number as the number of connections to be added, adding the number of connections to be added to the connection pool, and adding the number of connections to be added to the current configured number of connections.
[0032] The maximum number of connections is the maximum number of connections that can be configured for the connection pool.
[0033] When expanding a connection pool, the number of connections in the pool is increased. This is done by determining the difference between the maximum number of connections and the currently configured number, and comparing this difference with a second target number. The minimum of this difference and the second target number is determined as the number of connections to be added. This prevents the connection pool from exceeding its maximum allowable capacity after expansion. Adding the required number of connections to the pool involves creating new connections for that number, and simultaneously increasing the current configured number of connections by the number of connections to be added. This expands the connection pool while ensuring its capacity matches the maximum number of connections. Furthermore, it eliminates the need for maintenance personnel to configure the current connection count based on experience, reducing the complexity of connection pool configuration and enabling automated tuning. The second target number can be set according to requirements, for example, 10, 20, etc.
[0034] In other embodiments of the present invention, the resource information includes the number of idle connections and system load; The step of scaling down the connection pool when the resource information meets the scaling-down conditions may include: scaling down the connection pool when the number of idle connections in a first target time period is greater than a second target ratio of the current configured number of connections in the connection pool, and the system load is less than a third target ratio of the system load capacity.
[0035] The scaling-down conditions can include a second target ratio where the number of idle connections within a first target time period is greater than the currently configured number of connections in the connection pool, and a third target ratio where the system load is less than the system load capacity. The second and third target ratios can be set according to requirements; for example, the second target ratio could be 50%, and the third target ratio could be 20%. The third target ratio where the system load is less than the system load capacity can include at least one of the following: CPU utilization less than the third target ratio, memory usage less than the third target ratio, and I / O utilization less than the third target ratio. The first target time period can be set according to requirements; for example, it could be 5 minutes, 10 minutes, etc.
[0036] The system determines whether the number of idle connections within the first target time period is greater than the second target ratio of the current configured connection count of the connection pool, and whether the system load is less than the third target ratio of the system load capacity. If the number of idle connections within the first target time period is greater than the second target ratio of the current configured connection count, and the system load is less than the third target ratio of the system load capacity, it indicates that there are fewer requests and more connections in the connection pool are idle. In this case, the connection pool can be scaled down to reduce the number of connections in the pool. If the number of idle connections within the first target time period is not greater than the second target ratio of the current configured connection count, or the system load is greater than or equal to the third target ratio of the system load capacity, it indicates that there are not many idle connections in the connection pool, and the connection pool does not need to be scaled down.
[0037] When the number of idle connections during the first target time period exceeds the second target proportion of the currently configured number of connections, and the system load is less than the third target proportion of the system load capacity, the connection pool is scaled down. This allows for timely scaling down of the connection pool, avoiding resource waste caused by a large number of idle connections. Furthermore, it eliminates the need for operations personnel to configure the number of connections based on experience, reducing the complexity of connection pool configuration and enabling automated tuning.
[0038] Based on the above technical solution, the scaling down of the connection pool may include: reducing the number of connections by a third target every target duration, and reducing the current configured connection number by the third target number, such that the current configured connection number after reducing the third target number is greater than or equal to the minimum number of connections in the connection pool.
[0039] When scaling down the connection pool, the number of connections can be reduced by a third target number every target duration, i.e., the number of connections of the third target number can be closed to release resources. At the same time, the current configured number of connections in the connection pool can be reduced by the third target number. This can gradually reduce the capacity of the connection pool, which can avoid situations where traffic surges cannot be handled in time while reducing resource waste and ensuring the high availability of the system.
[0040] In some embodiments of the present invention, adjusting the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information may include: Based on the resource information and historical resource information from historical monitoring periods, the resource prediction information of the connection pool in the next monitoring period is determined by a time series prediction model. When the resource prediction information meets the capacity adjustment conditions, the capacity of the connection pool is adjusted.
[0041] Historical resource information can be a sequence of resource information for each historical monitoring period.
[0042] Time series prediction models (such as LSTM models) can be used to predict the resource information of the connection pool in the next monitoring period based on current and historical resource information. This yields resource prediction information, which is then used to determine whether the resource prediction information meets the capacity adjustment conditions. If the resource prediction information meets the capacity adjustment conditions, the capacity of the connection pool is adjusted. This allows for early adjustment of the connection pool capacity based on short-term load changes in the system, avoiding connection exhaustion or waste of system resources due to lag in dynamic adjustment.
[0043] Based on the above technical solution, after adjusting the capacity of the connection pool, the method may further include: sending the capacity adjustment information of the connection pool to other devices in a distributed environment.
[0044] In a microservices and distributed environment, services are deployed on different devices in a distributed manner, and the traffic of each device is basically the same. After the current device adjusts the capacity of the connection pool, it can send the capacity adjustment information to other devices in the distributed environment. In this way, other devices can also adjust the connection pool based on the capacity adjustment information, which can realize connection pool collaboration among multiple instances, share monitoring data, and automatically allocate connection resources.
[0045] Figure 2 This is a schematic diagram of the structure of a connection pool management device provided in an embodiment of the present invention, as shown below. Figure 2 As shown, the device includes: The resource acquisition module 210 is used to acquire the resource information of the connection pool within the current monitoring period. The resource information is information that reflects the performance indicators of the connection pool. The capacity adjustment module 220 is used to adjust the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information, and the adjusted capacity is applied to the operation of the connection pool in the next monitoring cycle.
[0046] Optionally, the capacity adjustment module includes: The expansion unit is used to expand the connection pool when the resource information meets the expansion conditions; or, The scaling-down unit is used to perform scaling-down processing on the connection pool when the resource information meets the scaling-down conditions.
[0047] Optionally, the resource information includes the number of active connections and the number of requests in the queue; The expansion unit is specifically used for: When the number of active connections is greater than a first target ratio of the current configured number of connections in the connection pool, and the number of queued requests is greater than a first target number, the connection pool is expanded.
[0048] Optionally, the expansion process for the connection pool includes: Determine the difference between the maximum number of connections in the connection pool and the current configured number of connections, and determine the minimum of the difference and the second target number as the number of connections to be added. Add the number of connections to be added to the connection pool, and increase the current configured number of connections by the number of connections to be added.
[0049] Optionally, the resource information includes the number of idle connections and system load; The shrinkage unit is specifically used for: When the number of idle connections during the first target time period is greater than the second target ratio of the current configured number of connections in the connection pool, and the system load is less than the third target ratio of the system load capacity, the connection pool is scaled down.
[0050] Optionally, the process of reducing the size of the connection pool includes: Every target duration, the number of connections is reduced by the third target number, and the current configured number of connections is reduced by the third target number. The current configured number of connections after reducing the third target number is greater than or equal to the minimum number of connections in the connection pool.
[0051] Optionally, the capacity adjustment module includes: The resource prediction unit is used to determine the resource prediction information of the connection pool in the next monitoring period based on the resource information and the historical resource information of the historical monitoring period through a time series prediction model. A capacity adjustment unit is used to adjust the capacity of the connection pool when the resource prediction information meets the capacity adjustment conditions.
[0052] Optionally, the device further includes: The adjustment information sending module is used to send the capacity adjustment information of the connection pool to other devices in the distributed environment.
[0053] The connection pool management device provided in this embodiment of the invention adjusts the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information of the connection pool during the current monitoring period. The adjusted capacity is used for the operation of the connection pool in the next monitoring period. This realizes the adjustment of the connection pool capacity based on the resource information of the connection pool. The adjustment takes effect immediately without the need for device restart, which can improve the dynamic adjustment speed of the connection pool and avoid resource waste caused by connection exhaustion or too many idle connections.
[0054] This invention also provides an electronic device, such as... Figure 3As shown, it includes a processor 301, a communication interface 302, a memory 303, and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304. Memory 303 is used to store computer programs; When processor 301 executes a program stored in memory 303, it performs the following steps: Within the current monitoring period, acquire the resource information of the connection pool, which is information reflecting the performance indicators of the connection pool; When the capacity adjustment conditions are met based on the resource information, the capacity of the connection pool is adjusted, and the adjusted capacity is applied to the operation of the connection pool in the next monitoring cycle.
[0055] Optionally, adjusting the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information includes: When the resource information meets the expansion conditions, the connection pool is expanded; or, When the resource information meets the scaling-down conditions, the connection pool is scaled down.
[0056] Optionally, the resource information includes the number of active connections and the number of requests in the queue; The step of expanding the connection pool when the resource information meets the expansion conditions includes: When the number of active connections is greater than a first target ratio of the current configured number of connections in the connection pool, and the number of queued requests is greater than a first target number, the connection pool is expanded.
[0057] Optionally, the expansion process for the connection pool includes: Determine the difference between the maximum number of connections in the connection pool and the current configured number of connections, and determine the minimum of the difference and the second target number as the number of connections to be added. Add the number of connections to be added to the connection pool, and increase the current configured number of connections by the number of connections to be added.
[0058] Optionally, the resource information includes the number of idle connections and system load; The step of scaling down the connection pool when the resource information meets the scaling-down conditions includes: When the number of idle connections during the first target time period is greater than the second target ratio of the current configured number of connections in the connection pool, and the system load is less than the third target ratio of the system load capacity, the connection pool is scaled down.
[0059] Optionally, the process of reducing the size of the connection pool includes: Every target duration, the number of connections is reduced by the third target number, and the current configured number of connections is reduced by the third target number. The current configured number of connections after reducing the third target number is greater than or equal to the minimum number of connections in the connection pool.
[0060] Optionally, adjusting the capacity of the connection pool when the capacity adjustment conditions are met based on the resource information includes: Based on the resource information and historical resource information from historical monitoring periods, the resource prediction information of the connection pool in the next monitoring period is determined by a time series prediction model. When the resource prediction information meets the capacity adjustment conditions, the capacity of the connection pool is adjusted.
[0061] Optionally, after adjusting the capacity of the connection pool, the method further includes: The capacity adjustment information of the connection pool is sent to other devices in the distributed environment.
[0062] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.
[0063] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0064] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0065] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0066] In another embodiment of the present invention, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the connection pool management methods described in the above embodiments.
[0067] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the connection pool management methods described in the above embodiments.
[0068] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0069] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0070] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0071] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method of managing a connection pool, characterized by, The method comprises the following steps: In a current monitoring period, resource information of a connection pool is acquired, the resource information being information reflecting performance indicators of the connection pool; When it is determined that a capacity adjustment condition is met according to the resource information, the capacity of the connection pool is adjusted, and the adjusted capacity is applied to the connection pool in a next monitoring period.
2. The method of claim 1, wherein, The step of adjusting the capacity of the connection pool when the capacity adjustment condition is met according to the resource information comprises: When the resource information meets an expansion condition, the connection pool is expanded; or When the resource information meets a contraction condition, the connection pool is contracted.
3. The method of claim 2, wherein, The resource information comprises an active connection number and a request queue number; The step of expanding the connection pool when the resource information meets the expansion condition comprises: When the active connection number is greater than a first target proportion of a current configured connection number of the connection pool, and the request queue number is greater than a first target quantity, the connection pool is expanded.
4. The method according to claim 2 or 3, characterized in that, The step of expanding the connection pool comprises: A difference between a maximum connection number of the connection pool and the current configured connection number is determined, and a minimum value between the difference and a second target quantity is determined as a to-be-increased connection number, the connection pool is increased by the to-be-increased connection number, and the current configured connection number is increased by the to-be-increased connection number.
5. The method of claim 2, wherein, The resource information comprises an idle connection number and a system load; The step of contracting the connection pool when the resource information meets the contraction condition comprises: When an idle connection number in a first target time period is greater than a second target proportion of a current configured connection number of the connection pool, and the system load is less than a third target proportion of a system load capacity, the connection pool is contracted.
6. The method according to claim 2 or 5, characterized in that, The step of contracting the connection pool comprises: Every target time length, a third target quantity of connections is reduced, and the current configured connection number is reduced by the third target quantity, and the current configured connection number after the third target quantity of connections is reduced is greater than or equal to a minimum connection number of the connection pool.
7. The method according to any one of claims 1-3, 5, characterized in that, The step of adjusting the capacity of the connection pool when the capacity adjustment condition is met according to the resource information comprises: According to the resource information and historical resource information of a historical monitoring period, resource prediction information of the connection pool in a next monitoring period is determined through a time series prediction model; When the resource prediction information meets the capacity adjustment condition, the capacity of the connection pool is adjusted.
8. The method according to any one of claims 1-3, 5, characterized in that, After the capacity of the connection pool is adjusted, the method further comprises the following step: Capacity adjustment information of the connection pool is sent to other devices in a distributed environment.
9. A management apparatus of a connection pool, characterized by, The method comprises the following steps: A resource acquisition module is configured to acquire resource information of a connection pool in a current monitoring period, the resource information being information reflecting performance indicators of the connection pool; A capacity adjustment module is configured to adjust the capacity of the connection pool when a capacity adjustment condition is met according to the resource information, and the adjusted capacity is applied to the connection pool in a next monitoring period.
10. An electronic device, comprising: The computer program product comprises a computer readable storage medium and a computer program. The computer readable storage medium stores the computer program. The processor is configured to execute the program stored in the memory to implement the method steps of any one of claims 1-8.
11. A computer readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the method of any one of claims 1-8.
12. A computer program product comprising computer program instructions, characterised in that, The computer program instructions, when executed on the computer, cause the computer to perform the method of any one of claims 1-8.