Connection pool management method and device, equipment and storage medium

By receiving the connection pool operation data sent by the client, dynamically adjusting the connection pool parameters, solving the problem that the connection pool parameters cannot be dynamically adjusted in the existing technology, and improving the effect of connection pool management.

CN119814554AActive Publication Date: 2025-04-11CHINA UNITED NETWORK COMM GRP CO LTD +2

Patent Information

Application Number
CN202311311017.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-10
Publication Date
2025-04-11
Estimated Expiration
2043-10-10

AI Technical Summary

Technical Problem

In the prior art, the connection pool parameters are generally set by technicians based on experience in advance and cannot be dynamically adjusted, resulting in poor connection pool management when there are dynamic changes in communication between the client and the server.

Method used

By receiving the running data for the target connection pool sent by the client, dynamically adjusting the connection pool parameters, such as the number of core threads, based on these data, to ensure that the parameters are more in line with the real usage of the target connection pool.

Benefits of technology

Dynamic adjustment of target connection pool parameters is achieved, the accuracy of connection pool parameters is improved, and the connection pool management effect is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119814554A_ABST
    Figure CN119814554A_ABST
Patent Text Reader

Abstract

The invention provides a connection pool management method and device, equipment and a storage medium, and relates to the technical field of computers. The method is applied to configuration equipment and comprises the steps that operation data sent by a client side and aiming at a target connection pool are received, the target connection pool is a connection pool related to a target application, the operation data comprise the number of times that the target connection pool accesses a server side in a preset time interval, and the server side is used for providing background service for the target application; based on the operation data, connection pool parameters corresponding to the target connection pool are adjusted to obtain adjusted connection pool parameters, and the connection pool parameters are used for describing the target connection pool; and sending the adjusted connection pool parameters to the client, so that the client configures the target connection pool based on the adjusted connection pool parameters. The adjusted connection pool parameters are more fit with the real use condition of the target connection pool, dynamic adjustment of the connection pool parameters of the target connection pool is achieved, and then the connection pool management effect is improved.
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 management method, device, equipment and storage medium. Background Art

[0002] With the rapid development of computer technology, most Internet applications currently use a client-server connection structure to enable the client to obtain the data it expects from the server. When the client establishes an underlying TCP (Transmission Control Protocol) connection with the server, it needs to go through a three-way handshake with the server, including a series of system calls that have a large overhead on machine resources, such as I / O (Input / Output) operations and network monitoring.

[0003] In the related art, by putting the connection resources into a management container in advance, this management container is called a connection pool. When the client accesses the server, it first obtains an available connection from the connection pool, and then uses the connection to communicate with the server. The connection pool is obtained by configuring the connection pool parameters. However, in the related art, the connection pool parameters are generally set in advance by the technicians based on experience. However, the communication between the client and the server is dynamically changing. How to dynamically adjust the connection pool parameters to better manage the connection pool has become an urgent problem to be solved. Summary of the invention

[0004] The present application provides a connection pool management method, apparatus, device and storage medium, which realizes dynamic adjustment of connection pool parameters of a target connection pool, improves the correctness of the connection pool parameters, and further improves the connection pool management effect.

[0005] In a first aspect, the present application provides a connection pool management method, which is applied to a configuration device, and the method includes:

[0006] Receive operation data for a target connection pool sent by a client, the target connection pool being a connection pool related to a target application, the operation data including the number of times the target connection pool accesses a server within a preset time interval, the server being used to provide background services for the target application;

[0007] Based on the operation data, adjusting the connection pool parameters corresponding to the target connection pool to obtain adjusted connection pool parameters, wherein the connection pool parameters are used to describe the target connection pool;

[0008] The adjusted connection pool parameters are sent to the client, so that the client configures the target connection pool based on the adjusted connection pool parameters.

[0009] Optionally, the connection pool parameter includes the number of core threads; and adjusting the connection pool parameter corresponding to the target connection pool based on the running data to obtain the adjusted connection pool parameter includes:

[0010] Determine the ratio between the operation data and the interval length corresponding to the preset time interval as the access frequency corresponding to the target connection pool, wherein the access frequency indicates the frequency of the target connection pool accessing the server;

[0011] Based on the access frequency, the number of core threads corresponding to the target connection pool is adjusted to obtain an adjusted number of core threads, and the access frequency is positively correlated with the number of core threads.

[0012] Optionally, before receiving the operation data for the target connection pool sent by the client, the method further includes:

[0013] Receiving an initialization request for the target connection pool sent by the client;

[0014] Obtaining the stored initial connection pool parameters corresponding to the client;

[0015] The initial connection pool parameters are sent to the client, so that the client initializes the target connection pool according to the initial connection pool parameters.

[0016] Optionally, the process of determining the initial connection pool parameters includes:

[0017] Receiving a registration request for the target connection pool sent by the client, wherein the registration request carries connection pool information corresponding to the target connection pool;

[0018] Storing the connection pool information in the registration information group corresponding to the server;

[0019] Based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, initial connection pool parameters corresponding to the target connection pool are determined, and the initial connection pool parameters are stored.

[0020] Optionally, the connection pool information includes an Internet Protocol IP address of the server; and storing the connection pool information in a registration information group corresponding to the server includes:

[0021] If there is a registration information group corresponding to the IP address, storing the connection pool information in the registration information group corresponding to the IP address;

[0022] If the registration information group corresponding to the IP address does not exist, a registration information group corresponding to the IP address is created, and the connection pool information is stored in the registration information group.

[0023] Optionally, the preset configuration information includes a preset idle thread survival time, a preset time unit corresponding to the preset idle thread survival time, a preset thread factory, and a preset rejection strategy;

[0024] The determining, based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, the initial connection pool parameters corresponding to the target connection pool include:

[0025] Using a preset formula, based on the maximum number of connections corresponding to the server and the number of computing cores corresponding to the client, determine the initial number of core threads and the initial maximum number of threads;

[0026] The initial connection pool parameters are composed of the initial core thread number, the initial maximum thread number, the preset idle thread survival time, the preset time unit corresponding to the preset idle thread survival time, the preset thread factory and the preset rejection strategy.

[0027] Optionally, after determining the initial connection pool parameters corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, the method further includes:

[0028] If it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed user connections is less than the sum of the remaining number of connection pools, the target connection pool is placed in a waiting queue until it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed user connections is greater than or equal to the sum of the remaining number of connection pools, and the initial connection pool parameters corresponding to the target connection pool are determined again based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client;

[0029] If it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed connections of the user is greater than or equal to the sum of the numbers of remaining connection pools, the step of storing the initial connection pool parameters is performed.

[0030] Optionally, the method further comprises:

[0031] Using a correction formula, respectively determining the correction trend information and the connection number correction value corresponding to the target connection pool, wherein the correction trend information indicates that the connection number increases or decreases;

[0032] If the waiting queue is empty, adjusting the connection pool parameters corresponding to the target connection pool according to the correction trend information and the connection number correction value, the waiting queue including a plurality of connection pools whose connection pool parameters are to be determined and arranged in sequence;

[0033] If the waiting queue is not empty, the target connection pool is put into the waiting queue, and corresponding connection pool parameters are determined for the connection pools in the waiting queue in turn.

[0034] In a second aspect, the present application provides a connection pool management device, which is arranged in a configuration device, and includes:

[0035] A receiving module, configured to receive operation data for a target connection pool sent by a client, wherein the target connection pool is a connection pool related to a target application, and the operation data includes the number of times the target connection pool accesses a server within a preset time interval, and the server is configured to provide background services for the target application;

[0036] An adjustment module, configured to adjust a connection pool parameter corresponding to the target connection pool based on the operation data to obtain an adjusted connection pool parameter, wherein the connection pool parameter is used to describe the target connection pool;

[0037] The sending module is used to send the adjusted connection pool parameters to the client, so that the client configures the target connection pool based on the adjusted connection pool parameters.

[0038] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory and a transceiver respectively communicatively connected to the processor;

[0039] The memory stores computer-executable instructions; the transceiver is used to send and receive data with a client or a server;

[0040] The processor executes the computer-executable instructions stored in the memory to implement the connection pool management method as described in any one of the first aspects.

[0041] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the connection pool management method described in any one of the first aspects.

[0042] In a fifth aspect, the present application provides a computer program product, comprising computer execution instructions, which, when executed by a processor, implement the connection pool management method described in any one of the first aspects.

[0043] The connection pool management method, apparatus, device and storage medium provided in the present application obtain the operation data of the target connection pool through the client during the operation of the target connection pool, and send the operation data to the configuration device, so that the configuration device adjusts the target connection pool based on the operation data. Since the operation data includes the number of times the target connection pool accesses the server within a preset time interval, the operation data can reflect the usage of the target connection pool, so that the adjusted connection pool parameters are more in line with the actual usage of the target connection pool, thereby realizing dynamic adjustment of the connection pool parameters of the target connection pool, improving the correctness of the connection pool parameters, and further improving the connection pool management effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0045] Figure 1 is a schematic diagram showing an application scenario according to an exemplary embodiment;

[0046] Figure 2 is a flow chart of a connection pool management method according to an exemplary embodiment;

[0047] Figure 3 is a flow chart of a connection pool management method according to another exemplary embodiment;

[0048] Figure 4 is a schematic diagram showing the relationship between a server and a connection pool according to an exemplary embodiment;

[0049] Figure 5 is a schematic diagram of a process for determining initial connection pool parameters according to an exemplary embodiment;

[0050] Figure 6 is a schematic diagram showing a connection pool parameter dynamic adjustment process according to an exemplary embodiment;

[0051] Figure 7 is a schematic diagram showing a connection object usage process according to an exemplary embodiment;

[0052] Figure 8 is a structural schematic diagram of a connection pool management device according to an exemplary embodiment;

[0053] Fig. 9 The diagram is a schematic structural diagram of an electronic device according to an exemplary embodiment.

[0054] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0055] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0056] The terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the following embodiments, "multiple" means more than two, unless otherwise clearly and specifically defined.

[0057] First, the terms involved in this application are explained:

[0058] Number of core threads: refers to the number of long-term surviving or resident threads in the connection pool.

[0059] Maximum number of threads: refers to the maximum number of threads allowed to be created in the connection pool.

[0060] Idle thread survival time: refers to the survival time corresponding to the idle thread. When there is no task in the task queue of the connection pool and the idle time corresponding to the idle thread reaches this survival time, the idle thread will be destroyed. The number of destroyed threads = maximum number of threads - number of core threads.

[0061] Time unit: refers to the unit for describing the survival time of idle threads.

[0062] Task queue: refers to the queue where the connection pool stores tasks, which is used to store tasks to be executed in the connection pool.

[0063] Thread factory: refers to the method called when the connection pool creates a new thread.

[0064] Rejection strategy: refers to the strategy for rejecting requests when the task queue is full and the number of worker threads is greater than or equal to the maximum number of threads in the connection pool.

[0065] The principle of connection pool operation:

[0066] Step S1: For the task to be executed, first determine whether the current number of threads in the connection pool has reached the number of core threads. If not, create a new thread to execute the task, and after the task is completed, keep the thread in the connection pool without destroying it. If the current number of threads has reached the number of core threads, proceed to step S2.

[0067] Step S2: Determine whether the task queue is full. If not, submit the task to the task queue; if full, proceed to step S3;

[0068] Step S3: Determine whether the current number of threads in the connection pool has reached the maximum number of threads. If not, create a new thread to execute the task. If it has reached the maximum number of threads, use a rejection strategy to process the task.

[0069] Among them, when the current number of threads in the connection pool reaches the maximum number of threads, whenever the idle time corresponding to a certain thread reaches the idle thread survival time, the thread is destroyed until the current number of threads in the connection pool is equal to the number of core threads.

[0070] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.

[0071] With the rapid development of computer technology, most Internet applications currently use a client-server connection structure to enable the client to obtain the data it expects from the server. When the client establishes an underlying TCP connection with the server, it needs to go through a three-way handshake with the server, including a series of system calls that consume a lot of machine resources, such as I / O (Input / Output) operations and network monitoring.

[0072] In the related technology, connection pool is a relatively important middleware. By pre-placing the connection resources in a management container, which is called a connection pool, when the client accesses the server, it first obtains an available connection from the connection pool, and then uses the connection to communicate with the server. Taking the database connection pool for accessing the database as an example, when the client accesses the database server, it first accesses the connection pool, obtains an available connection, and then uses the connection to communicate with the server. With the connection pool, the client usually no longer needs to create a new database connection when connecting to the database server, thereby improving system performance.

[0073] Among them, the connection pool is obtained through the connection pool parameter configuration. However, in the related technology, the connection pool parameters are generally set in advance by the technical staff based on experience. However, the communication between the client and the server is dynamic. How to dynamically adjust the connection pool parameters to better manage the connection pool has become an urgent problem to be solved.

[0074] In view of the technical problem that the resource usage gap between working nodes in the related technology is large, resulting in poor dynamic scheduling effect, the inventor found in the research that in order to solve this problem, the connection pool parameters can be dynamically adjusted during the operation of the connection pool, and further, they can be adjusted according to the operation status of the connection pool. Specifically, during the operation of the target connection pool, the client obtains the operation data of the target connection pool and sends the operation data to the configuration device, so that the configuration device adjusts the target connection pool based on the operation data. Since the operation data includes the number of times the target connection pool accesses the server within a preset time interval, the operation data can reflect the usage of the target connection pool, so that the adjusted connection pool parameters are more in line with the actual usage of the target connection pool, realizing the dynamic adjustment of the connection pool parameters of the target connection pool, improving the correctness of the connection pool parameters, and thus improving the connection pool management effect.

[0075] The following introduces the application scenarios of the connection pool management method provided in the embodiments of the present application.

[0076] Figure 1 is a schematic diagram showing an application scenario according to an exemplary embodiment. Figure 1 As shown, the application scenario includes: a configuration device 1, a client 2 and a server 3. Each device is connected via a network.

[0077] The configuration device 1 is used to manage the connection pool, the client 2 refers to the client device, the server 3 refers to the server device, and the client 2 and the server 3 communicate with each other through the connection object in the connection pool. In this embodiment, the configuration device 1 receives the operation data for the target connection pool sent by the client 2, adjusts the connection pool parameters corresponding to the target connection pool based on the operation data to obtain the adjusted connection pool parameters, and then sends the adjusted connection pool parameters to the client 2, so that the client 2 configures the target connection pool based on the adjusted connection pool parameters.

[0078] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0079] Figure 2 The flowchart of a connection pool management method according to an exemplary embodiment is shown. The execution subject of the connection pool management method provided in this application is a connection pool management device, which is integrated in a configuration device, and the configuration device is used to manage the connection pool. Figure 2 As shown, the connection pool management method provided in this embodiment includes the following steps:

[0080] Step S101, receiving operation data for a target connection pool sent by a client, the target connection pool is a connection pool related to a target application, the operation data includes the number of times the target connection pool accesses a server within a preset time interval, and the server is used to provide background services for the target application.

[0081] Among them, the target connection pool is a connection pool provided by the server, which is used for the client to communicate with the server through the connection in the target connection pool. A target application is deployed in the client, and the target application can be any type of application, and the background server of the target application is the server. The client obtains the operating data of the target connection pool in real time and sends the operating data to the configuration device. Optionally, the client sends the acquired operating data to the configuration device at fixed intervals. The fixed interval is the interval length corresponding to the preset time interval, that is, the time interval between the start time and the end time in the preset time interval. The preset time interval can be set as needed, and this embodiment does not limit this. For example, the preset time interval can be any time interval with an interval length of 5 minutes, such as 1 o'clock to 1:05, and the preset time interval can be any time interval with an interval length of 10 minutes, such as 2 o'clock to 2:10.

[0082] Step S102: Based on the operation data, the connection pool parameters corresponding to the target connection pool are adjusted to obtain the adjusted connection pool parameters, where the connection pool parameters are used to describe the target connection pool.

[0083] The operation data can reflect the actual operation status of the target connection pool within a preset time interval, so that the connection pool parameters of the target connection pool can be adjusted according to the operation data, so that the adjusted connection pool parameters are closer to the actual operation status of the target connection pool. The connection pool parameters include any one of the number of core threads, the maximum number of threads, the idle thread survival time, the time unit corresponding to the idle thread survival time, the task queue, the thread factory and the rejection strategy.

[0084] Step S103: sending the adjusted connection pool parameters to the client, so that the client configures the target connection pool based on the adjusted connection pool parameters.

[0085] In this embodiment, after the adjusted connection pool parameters are obtained, the adjusted connection pool parameters are sent to the client, so that the client configures the target connection pool.

[0086] In this embodiment, during the operation of the target connection pool, the client obtains the operation data of the target connection pool and sends the operation data to the configuration device, so that the configuration device adjusts the target connection pool based on the operation data. Since the operation data includes the number of times the target connection pool accesses the server within a preset time interval, the operation data can reflect the usage of the target connection pool, so that the adjusted connection pool parameters are more in line with the actual usage of the target connection pool, thereby realizing dynamic adjustment of the connection pool parameters of the target connection pool, improving the correctness of the connection pool parameters, and further improving the connection pool management effect.

[0087] Figure 3 1 is a flow chart of a connection pool management method according to another exemplary embodiment. The execution subject of the connection pool management method provided in this application is a connection pool management device, which is integrated in the configuration device. Figure 3 As shown, the connection pool management method provided in this embodiment includes the following steps:

[0088] Step S201, receiving operation data for a target connection pool sent by a client, the target connection pool is a connection pool related to a target application, the operation data includes the number of times the target connection pool accesses a server within a preset time interval, and the server is used to provide background services for the target application.

[0089] In some embodiments, the implementation of step S201 is similar to that of step S101 and will not be described in detail herein.

[0090] For example, Figure 4 is a schematic diagram showing the relationship between a server and a connection pool according to an exemplary embodiment. Figure 4 As shown, the server provides multiple connection pools: connection pool A, connection pool B, etc. The configuration center monitors the operation data of the connection pool. Each connection pool has a corresponding user, such as user 1, user 2, user 3, user 4, etc. The user is a database connection user or an ssh connection user, and ssh refers to the Secure Shell protocol (Secure Shell).

[0091] In this embodiment, after step S201, the configuration device adjusts the connection pool parameters corresponding to the target connection pool based on the operation data to obtain the adjusted connection pool parameters, and the connection pool parameters are used to describe the target connection pool. Optionally, the connection pool parameters include the number of core threads. Accordingly, based on the operation data, the connection pool parameters corresponding to the target connection pool are adjusted to obtain the adjusted connection pool parameters. The implementation method includes the following steps S202-S203.

[0092] Step S202: The ratio between the running data and the interval length corresponding to the preset time interval is determined as the access frequency corresponding to the target connection pool, where the access frequency indicates how frequently the target connection pool accesses the server.

[0093] Among them, the operating data includes the number of times the target connection pool accesses the server within a preset time interval. The more times, the more frequent the access, and the fewer times, the less frequent the access. Accordingly, the difference between the operating data and the interval length corresponding to the preset time interval can indicate the frequency of the target connection pool accessing the server within the preset time interval, and therefore the wallpaper can be determined as the access frequency corresponding to the target connection pool.

[0094] Step S203: Based on the access frequency, the number of core threads corresponding to the target connection pool is adjusted to obtain an adjusted number of core threads, wherein the access frequency is positively correlated with the number of core threads.

[0095] Among them, the greater the access frequency, the more the target connection pool needs for resident threads, and the greater the number of core threads required, while the smaller the access frequency, the less the target connection pool needs for resident threads, and the smaller the number of core threads required. Accordingly, the access frequency is positively correlated with the number of core threads. Thus, the number of core threads corresponding to the target connection pool can be adjusted based on the access frequency. It should be noted that the technical personnel can flexibly set the implementation method of step S203 as needed, and this embodiment does not limit this. In an optional implementation method, the configuration device stores the corresponding relationship between the access frequency and the number of core threads in advance, and the corresponding relationship satisfies the condition that the access frequency is positively correlated with the number of core threads, so that after determining the access frequency, the number of core threads corresponding to the determined access frequency is queried from the stored corresponding relationship between the access frequency and the number of core threads, and the number of core threads is used as the adjusted number of core threads.

[0096] In this embodiment, the greater the access frequency, the more the target connection pool requires resident threads, and the larger the number of core threads required, while the smaller the access frequency, the smaller the target connection pool requires resident threads, and the smaller the number of core threads required. Therefore, by adjusting the number of core threads corresponding to the target connection pool based on the access frequency, the adjusted number of core threads can better meet the current operating conditions of the target connection pool.

[0097] Step S204: sending the adjusted connection pool parameters to the client, so that the client configures the target connection pool based on the adjusted connection pool parameters.

[0098] In some embodiments, the implementation of step S204 is similar to the implementation of step S103 and will not be described in detail here.

[0099] In the present application, the above embodiment describes the process of dynamically adjusting the connection pool parameters corresponding to the target connection pool during the operation of the target connection pool by the configuration device. Before running the target connection pool, the client needs to initialize the target connection pool first. Accordingly, based on the above embodiment, the initialization process of the target connection pool is described below.

[0100] In an optional embodiment, before receiving the operating data for the target connection pool sent by the client, the connection pool management method provided by the present application also includes the following steps: when there is a connection demand, the client sends an initialization request for the target connection pool to the configuration device; accordingly, the configuration device receives the initialization request for the target connection pool sent by the client; obtains the stored initial connection pool parameters corresponding to the client; and sends the initial connection pool parameters to the client, so that the client initializes the target connection pool according to the initial connection pool parameters.

[0101] Among them, when the client has a task to be executed, it can be considered that the client has a connection demand, and at this time, an initialization request for the target connection pool is sent to the configuration device. Among them, a task refers to a task implemented by communicating with the server, for example, a task is to obtain data from a database, and the server is the server corresponding to the database. The related technology is to load and initialize the connection pool into the memory when the project starts, but at this time there is often no task submitted to the connection pool, resulting in the connection in the connection pool being idle, causing unnecessary thread and memory overhead. In this embodiment, the client that uses the connection pool to connect to the server uses a lazy loading method. When the project starts, the connection pool is not loaded and initialized first, and when there is a task to be executed, the connection pool is loaded and initialized, thereby reducing the phenomenon that the client occupies threads and consumes memory and CPU (Central Processing Unit) resources when the business is idle.

[0102] In this embodiment, the configuration device stores the initial connection pool parameters corresponding to the client in advance. After receiving the initialization request sent by the client, the stored initial connection pool parameters are obtained and sent to the client, so that the client can initialize the target connection pool according to the initial connection pool parameters, thereby saving client resources through lazy loading.

[0103] In the above optional embodiment, the configuration device stores the initial connection pool parameters corresponding to the target connection pool in advance. In an optional embodiment, the process of determining the initial connection pool parameters includes the following steps: receiving a registration request for the target connection pool sent by the client, the registration request carrying the connection pool information corresponding to the target connection pool; storing the connection pool information in the registration information group corresponding to the server; determining the initial connection pool parameters corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, and storing the initial connection pool parameters.

[0104] Wherein, there are multiple servers, and the configuration device stores registration information groups corresponding to each server, and the registration information groups store connection pool information corresponding to at least one connection pool provided by the corresponding server. The configuration device stores preset configuration information in advance, and illustratively, the preset configuration information includes a preset idle thread survival time, a preset time unit corresponding to the preset idle thread survival time, a preset thread factory, and a preset rejection policy. The preset configuration information can be set as needed, and this embodiment does not limit this. Wherein, the maximum number of connections corresponding to the server refers to the maximum value of the number of connections that the server can establish.

[0105] In this embodiment, in the process of registering the target connection pool, the initial connection pool parameters corresponding to the target connection pool are determined, thereby providing data support for the subsequent initialization of the target connection pool.

[0106] In an optional implementation of the above optional embodiment, the connection pool information includes an identifier of the server, which is exemplarily an IP address. Accordingly, the implementation of storing the connection pool information in the registration information group corresponding to the server includes the following two cases:

[0107] In the first case, if there is a registration information group corresponding to the IP address, the connection pool information is stored in the registration information group corresponding to the IP address. In this case, if there is a registration information group corresponding to the IP address, it means that the registration information group corresponding to the server to which the IP address belongs has been stored, and the connection pool information corresponding to the target connection pool can be stored in the registration information group. The group name of the registration information group can be the IP address of the server.

[0108] In the second case, if there is no registration information group corresponding to the IP address, a registration information group corresponding to the IP address is created, and the connection pool information is stored in the registration information group. In this case, if there is no registration information group corresponding to the IP address, it means that the registration information group corresponding to the server to which the IP address belongs is not stored. Then, a registration information group corresponding to the IP address is first created, and then the connection pool information is stored in the created registration information group. Specifically, a group is created with the IP address as the group name, and the ssh parameters are obtained from the server through the corresponding user name and password of the server, and saved in the group.

[0109] In the above optional implementation method, the registration information group corresponding to the server is stored using the IP address corresponding to the server as the group name. When storing the connection pool information, it is first determined whether there is a registration information group corresponding to the IP address, and the connection pool information is stored according to the corresponding situation, thereby reducing the occurrence of connection pool information storage failure.

[0110] In an optional implementation of the above optional embodiment, the preset configuration information includes a preset idle thread survival time, a preset time unit corresponding to the preset idle thread survival time, a preset thread factory, and a preset rejection policy; accordingly, based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, the implementation method of determining the initial connection pool parameters corresponding to the target connection pool includes: using a preset formula to determine the initial core thread number and the initial maximum thread number based on the maximum number of connections corresponding to the server and the number of computing cores corresponding to the client; the initial core thread number, the initial maximum thread number, the preset idle thread survival time, the preset time unit corresponding to the preset idle thread survival time, the preset thread factory, and the preset rejection policy form the initial connection pool parameters.

[0111] In the above optional implementation method, the number of computing cores corresponding to the client can reflect the performance of the client. The larger the number of computing cores, the stronger the performance, and the smaller the number of computing cores, the weaker the performance. By adopting a preset formula, the initial number of core threads and the initial maximum number of threads can be determined more accurately based on the maximum number of connections corresponding to the server and the number of computing cores corresponding to the client. On this basis, the initial connection pool parameters can be determined in combination with the preset configuration information, and the determination efficiency is higher.

[0112] Exemplarily, the preset formula includes a formula for determining the initial number of core threads and a formula for determining the initial maximum number of threads. The formula for determining the initial number of core threads is shown in the following formula 1:

[0113]

[0114] Among them, Mn represents the initial core thread number corresponding to the nth client, Cn represents the computing core number corresponding to the nth client, n∈(1,D), D represents the total number of clients, D is a positive integer greater than 1, and S represents the maximum number of connections corresponding to the server.

[0115] In one possible situation, if the number of computing cores corresponding to a certain client is too large, the initial number of core threads determined by the above formula 1 is also too large, so that the client will occupy more connection resources on the server side, resulting in other clients not being able to get connection resources. In this case, based on formula 1, the initial number of core threads can be further calculated by the following formula 2 to obtain an updated initial number of core threads.

[0116]

[0117] Wherein, Mn′ represents the updated initial core thread number corresponding to the n-th client, and Mn represents the initial core thread number corresponding to the n-th client calculated by formula one.

[0118] For example, the maximum number of connections corresponding to the server is 1000, the number of computing cores corresponding to client A is 996, and the number of computing cores corresponding to client B is 2. According to formula 1, the initial number of core threads corresponding to client A is 995, and the initial number of core threads corresponding to client B is 0. It can be seen that when the difference between the number of computing cores corresponding to client A and client B is large, client B may not be allocated connection resources. On this basis, further calculation is performed through formula 2, and the updated initial number of core threads corresponding to client A is 18, and the updated initial number of core threads corresponding to client B is 1.

[0119] On the basis of Formula 1, Formula 2 is used to further calculate the initial number of core threads, ensuring that when the number of connections provided by the server is insufficient, each connection pool can be allocated at least one connection, and the connection is allocated according to the performance of the client. It also ensures that when the number of connections provided by the server is sufficient, each connection pool can obtain a more reasonable number of core threads, thereby reducing the phenomenon of individual clients being allocated a large number of invalid threads.

[0120] Accordingly, the formula for determining the initial maximum number of threads is shown in the following formula 3:

[0121]

[0122] Where Wn represents the initial maximum number of threads corresponding to the nth client, and β represents a random factor with a value of 0, -1 or 1.

[0123] To determine the initial maximum number of threads, a percentage of the allocated number of threads is added to the initial number of core threads and the logarithm is taken. This allows the corresponding maximum number of threads to be obtained through the client's performance when there are excess connections. By adding a random factor, the actual future operation of the connection pool can be estimated and judged, reducing the need for capacity expansion.

[0124] Among them, the constraints of formula 1 and formula 2 are The constraints of formula 3 are That is, if the maximum number of connections corresponding to the server is less than the total number of the initial core threads corresponding to the client and less than the total number of the maximum number of threads, each client will take the form of a queue to preemptively obtain the number of connections, and if the number of connections is not obtained, it needs to wait in the waiting queue and perform an alarm. In this embodiment, the above-mentioned preset formula, constraint formula, relevant parameters of the preset formula and relevant parameters of the constraint formula, waiting queue and alarm prompt interface are exposed for users to modify according to needs, for example, in the form of config (configuration file).

[0125] The above optional implementation is described by taking the number of clients being greater than 1 as an example. When the number of clients is 1, after the initial number of core threads and the initial maximum number of threads are determined respectively by the formula for determining the initial number of core threads and the formula for determining the initial maximum number of threads, further calculation is required, specifically, half of the determined initial number of core threads is determined as the final initial number of core threads, and half of the determined initial number of maximum threads is determined as the final initial number of maximum threads.

[0126] Based on the above optional implementation, optionally, if there is a fixed number of user connections, before using a preset formula to determine the initial number of core threads and the initial maximum number of threads based on the maximum number of connections corresponding to the server and the number of computing cores corresponding to the client, the difference between the maximum number of connections corresponding to the server and the fixed number of user connections is determined as the updated maximum number of connections, and then the preset formula is used to determine the initial number of core threads and the initial maximum number of threads based on the updated maximum number of connections and the number of computing cores corresponding to the client. The fixed number of user connections is the number of connections set by the user in advance according to demand.

[0127] On the basis of the above optional implementation, optionally, after determining the initial connection pool parameters corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, the connection pool management method provided by the present application also includes the following two cases:

[0128] In the first case, if it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed user connections is less than the sum of the number of remaining connection pools, the target connection pool is placed in a waiting queue until it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed user connections is greater than or equal to the sum of the number of remaining connection pools, and the initial connection pool parameters corresponding to the target connection pool are determined again based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client. Among them, the difference between the maximum number of connections and the number of fixed user connections is regarded as the number of available connections provided by the server. If the difference is less than the sum of the number of remaining connection pools, it means that the difference is small, the number of available connections is insufficient, and the connection cannot be allocated to the target connection pool at present. The determined initial connection pool parameters are unavailable. In this case, the target connection pool can be placed in a waiting queue first, until the difference is greater than or equal to the sum of the number of remaining connection pools. At this time, the number of available connections is sufficient, and then the connection pool is allocated connections in sequence according to the order of at least one connection pool in the waiting queue, that is, the initial connection pool parameters corresponding to the connection pool are determined.

[0129] In the second case, if it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed connections of the user is greater than or equal to the sum of the number of remaining connection pools, the step of storing the initial connection pool parameters is performed. Wherein, if the number of available connections is sufficient, the determined initial connection pool parameters are available, and the determined initial connection pool parameters are directly stored.

[0130] For example, Figure 5 is a schematic diagram showing a process for determining initial connection pool parameters according to an exemplary embodiment. Figure 5 As shown, at the beginning, the connection pool is registered, and the server information, that is, the maximum number of connections, is obtained. First, it is determined whether there is a fixed number of user connections. If not, a preset formula is used to determine the initial connection pool parameters based on the maximum number of connections and the number of computing cores corresponding to the client, and then it is determined whether the number of available connections is sufficient; if so, the difference between the maximum number of connections corresponding to the server and the number of user fixed connections is determined as the updated maximum number of connections, and then a preset formula is used to determine the initial connection pool parameters based on the updated maximum number of connections and the number of computing cores corresponding to the client, and then it is determined whether the number of available connections is sufficient; when the number of available connections is sufficient, the determined initial connection pool parameters are stored and the connection pool configuration is refreshed; when the number of available connections is insufficient, the target connection pool is placed in a waiting queue, on the one hand, an alarm is processed, and on the other hand, dynamic adjustment of the cluster is waited for.

[0131] In the above optional implementation, through instance and weight analysis, connection resources are allocated to the target connection pool according to the performance of the client. When the connection resources are less, it can be guaranteed as much as possible that the client can be allocated a certain amount of connection resources, and the user can customize the allocation through the user's fixed number of connections, so as to make full use of limited connection resources more efficiently.

[0132] On the basis of the above embodiment, the configuration device can also dynamically adjust the number of core threads and the maximum number of threads corresponding to the target connection pool at fixed time intervals. The time interval can be set as needed, for example, the time interval is 5 seconds, 10 seconds, etc. In an optional embodiment, the connection pool management method provided by the present application also includes: using a correction formula to respectively determine the correction trend information and the connection number correction value corresponding to the target connection pool, the correction trend information indicates that the number of connections increases or decreases; if the waiting queue is empty, the connection pool parameters corresponding to the target connection pool are adjusted according to the correction trend information and the connection number correction value, and the waiting queue includes a plurality of connection pools whose connection pool parameters are to be determined in sequence; if the waiting queue is not empty, the target connection pool is placed in the waiting queue, and the corresponding connection pool parameters are determined for the connection pools in the waiting queue in turn.

[0133] Among them, if the revised trend information indicates that the number of connections has increased, the number of connections corresponding to the target connection pool needs to be expanded; if the revised trend information indicates that the number of connections has decreased, the number of connections corresponding to the target connection pool needs to be shrunk. Shrinking or expanding the number of connections is achieved by adjusting the connection pool parameters, specifically, the number of core threads and the maximum number of threads. The connection number correction value is the specific value that needs to be adjusted, and the connection number correction value includes the core thread number correction value and the maximum thread number correction value. Optionally, the correction formula refers to the following formula 4:

[0134] Formula 4:

[0135] Where P represents the difference between the currently calculated weight and the weight sum calculated last time, t represents the length of the most recent time period, Ct represents the number of tasks submitted to the target connection pool in the most recent time period, S represents the set of most recent time periods, S∈{10,30,60,600…}, P0 represents the weight sum calculated last time, c1 represents the core thread number correction value, and c2 represents the maximum thread number correction value. The constraint condition of formula 4 is In this embodiment, the above correction formula and various parameters in the formula can be exposed so that the user can modify them as needed.

[0136] Among them, the implementation method of adjusting the connection pool parameters corresponding to the target connection pool according to the corrected trend information and the connection number correction value includes: if the corrected trend information indicates that the number of connections has increased, then the sum of the number of core threads in the connection pool parameters and the core thread number correction value is determined as the updated number of core threads, and the sum of the maximum number of threads in the connection pool parameters and the maximum thread number correction value is determined as the updated maximum number of threads; if the corrected trend information indicates that the number of connections has decreased, then the difference between the number of core threads in the connection pool parameters and the core thread number correction value is determined as the updated number of core threads, and the difference between the maximum number of threads in the connection pool parameters and the maximum thread number correction value is determined as the updated maximum number of threads.

[0137] For example, Figure 6 is a schematic diagram showing a connection pool parameter dynamic adjustment process according to an exemplary embodiment. Figure 6 As shown, at the beginning, the ssh related parameters of the server are refreshed and saved every 10 seconds, and then the correction formula is used to determine P, and it is judged whether P is greater than 0. When P is greater than 0, it means that the target connection pool needs to be expanded, and when P is less than 0, it means that the target connection pool needs to be shrunk. Use the correction formula to determine the connection number correction value corresponding to the target connection pool, and then compare the ssh related parameters with the ssh related parameters obtained last time. The ssh related parameters include the maximum number of connections, that is, the maximum number of connections is compared with the maximum number of connections obtained last time, and the change value of the maximum number of connections is determined, that is, the difference between the two, and then it is judged whether the waiting queue is empty, that is, whether there is a connection pool waiting to be allocated in the waiting queue. When the waiting queue is empty, dynamically adjust the connection pool parameters according to the strategy and refresh the connection pool configuration. Specifically, if there is at least one connection pool that needs to be expanded and the number of connections remaining on the server is greater than 0, then according to the proportion of c, it is preferentially allocated to the connection pool with a higher c, where the maximum number of connections corresponding to the server minus the number of connections already used is the number of connections remaining; if there is at least one connection pool that needs to be expanded and the number of connections remaining on the server is 0, then when the highest c value is 3 times higher than the lowest c value, the number of connections with the lowest c value is recycled and allocated to the connection pool with the highest c value; if there is at least one connection pool that needs to be shrunk, it can be shrunk according to the revised trend information and the connection number revision value. When there is a connection pool in the waiting queue, determine whether the number of connections remaining on the server is greater than the number of connection pools waiting in the waiting queue. When the number of remaining connections is greater than the number of connection pools waiting in the waiting queue, first allocate a connection number to each waiting connection pool to achieve full allocation, and then use the formula to calculate Mn and Wn, and allocate the remaining connections according to the proportion; when the number of remaining connections is less than the number of connection pools waiting in the waiting queue, allocate a connection number to the connection pools in turn on a first-come, first-served basis, and the remaining connection pools that have not been allocated a connection number continue to wait in the waiting queue, and an alarm is triggered.

[0138] In the above optional embodiment, a dynamic adjustment scheme is provided. Through dynamic configuration strategy and dynamic recovery strategy, when P is greater than 0, it indicates that expansion is required, and when P is less than 0, it indicates that contraction is required. When the target connection pool needs to be expanded or contracted twice in a row, the connection pool parameters of the target connection pool are dynamically adjusted, wherein the dynamic adjustment of the number of core threads and the maximum number of threads takes into account the concurrency of the client, the concurrency of the target connection pool, its own performance and the difference from the previous time, and is constrained by constraints. By combining the concurrency of the connection pool in the most recent time period, the weight difference and the performance of the client, it is calculated whether the connection pool needs to be expanded or contracted, and when system resources are seriously insufficient, connection resources are allocated preferentially to connection pools with higher concurrency, so that the system resources of the client and the server are more fully utilized, and the connection pool is guaranteed to work normally as much as possible, thereby improving the overall resource utilization of the cluster.

[0139] For example, Figure 7 is a schematic diagram showing a connection object usage process according to an exemplary embodiment. Figure 7 As shown, in this embodiment, when it is necessary to obtain a connection object from the connection pool, first determine whether there is an idle connection object; when there is an idle connection object, use the idle connection object; when there is no idle connection object, determine whether the current maximum number of threads and the number of core threads have reached the threshold, and expose these two parameters, so that the two parameters can be dynamically adjusted without shutting down the connection pool, thereby achieving the effect of dynamically adjusting the size of the connection pool. If it is reached, wait in the waiting queue; if it is not reached, call the thread factory to create a connection object; after using the connection object, return the connection object to the connection pool.

[0140] The connection pool technology currently used, most of them are to load and initialize the connection pool into the memory when the project is started, and there is often no task submitted to the connection pool at this time, resulting in resident connection during the idle period, causing unnecessary thread and memory overhead. The scheme used in this application can allow the client using the connection pool method to connect to the server in a distributed scenario through lazy loading. When the project is started, the connection pool is not loaded and initialized, and when there is a task that needs to be executed, the connection pool is loaded and initialized, thereby avoiding the client from occupying threads when the business is idle, consuming memory and CPU and other resources. In addition, the present invention uses a unified configuration to manage the seven parameters of the number of core threads, the maximum number of threads, the idle thread survival time, the time unit corresponding to the idle thread survival time, the task queue, the thread factory and the rejection strategy of the client. When the client needs to initialize the connection pool, it will first obtain the corresponding ssh parameters of the server through the configuration device, and then determine the connection pool parameters through calculation, and send the connection pool parameters to the client, thereby completing the initial allocation of the connection pool. Moreover, in this application, the client using the connection pool will send the connection pool operation status to the configuration device, so that the configuration device can dynamically adjust the number of core threads and the maximum number of threads of the connection pool according to the client connection pool operation status, so as to achieve dynamic contraction, recycling and management of the connection pool. This application implements configuration monitoring, instance and weight analysis, dynamic configuration strategy and dynamic recycling strategy through containers.

[0141] Figure 8 is a schematic diagram of the structure of a connection pool management device according to an exemplary embodiment. Figure 8 As shown, in this embodiment, the connection pool management device 300 can be set in the configuration device, and the connection pool management device 300 includes:

[0142] The receiving module 301 is used to receive the operation data for the target connection pool sent by the client. The target connection pool is a connection pool related to the target application. The operation data includes the number of times the target connection pool accesses the server within a preset time interval. The server is used to provide background services for the target application.

[0143] An adjustment module 302, configured to adjust connection pool parameters corresponding to the target connection pool based on the operation data to obtain adjusted connection pool parameters, where the connection pool parameters are used to describe the target connection pool;

[0144] The sending module 303 is used to send the adjusted connection pool parameters to the client, so that the client configures the target connection pool based on the adjusted connection pool parameters.

[0145] Optionally, the connection pool parameters include the number of core threads; the adjustment module 302 is used to:

[0146] The ratio between the running data and the interval length corresponding to the preset time interval is determined as the access frequency corresponding to the target connection pool, where the access frequency indicates how frequently the target connection pool accesses the server;

[0147] Based on the access frequency, the number of core threads corresponding to the target connection pool is adjusted to obtain the adjusted number of core threads, and the access frequency is positively correlated with the number of core threads.

[0148] Optionally, the apparatus 300 further includes an initialization module, wherein the initialization module is configured to:

[0149] Receive the initialization request for the target connection pool sent by the client;

[0150] Get the initial connection pool parameters corresponding to the stored client;

[0151] Send the initial connection pool parameters to the client so that the client initializes the target connection pool according to the initial connection pool parameters.

[0152] Optionally, the apparatus 300 further includes a determining module, the determining module being configured to:

[0153] Receive a registration request for a target connection pool sent by a client, where the registration request carries connection pool information corresponding to the target connection pool;

[0154] Store the connection pool information in the registration information group corresponding to the server;

[0155] Based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, the initial connection pool parameters corresponding to the target connection pool are determined, and the initial connection pool parameters are stored.

[0156] Optionally, the connection pool information includes an Internet Protocol IP address of the server; a determination module is used to:

[0157] If there is a registration information group corresponding to the IP address, the connection pool information is stored in the registration information group corresponding to the IP address;

[0158] If there is no registration information group corresponding to the IP address, a registration information group corresponding to the IP address is created, and the connection pool information is stored in the registration information group.

[0159] Optionally, the preset configuration information includes a preset idle thread survival time, a preset time unit corresponding to the preset idle thread survival time, a preset thread factory, and a preset rejection strategy;

[0160] Identify modules for:

[0161] Using a preset formula, based on the maximum number of connections corresponding to the server and the number of computing cores corresponding to the client, the initial number of core threads and the initial maximum number of threads are determined;

[0162] The initial connection pool parameters are composed of the initial number of core threads, the initial maximum number of threads, the preset idle thread survival time, the preset time unit corresponding to the preset idle thread survival time, the preset thread factory, and the preset rejection strategy.

[0163] Optionally, a module is determined to:

[0164] If it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed user connections is less than the sum of the remaining number of connection pools, the target connection pool is placed in a waiting queue until it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed user connections is greater than or equal to the sum of the remaining number of connection pools, and the initial connection pool parameters corresponding to the target connection pool are determined again based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client;

[0165] If it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed connections of the user is greater than or equal to the sum of the number of remaining connection pools, the initial connection pool parameters are stored.

[0166] Optionally, the adjustment module 302 is further configured to:

[0167] Adopting a correction formula, respectively determining the correction trend information and the connection number correction value corresponding to the target connection pool, the correction trend information indicating that the connection number increases or decreases;

[0168] If the waiting queue is empty, the connection pool parameters corresponding to the target connection pool are adjusted according to the correction trend information and the connection number correction value, and the waiting queue includes a plurality of connection pools whose connection pool parameters are to be determined and arranged in sequence;

[0169] If the waiting queue is not empty, the target connection pool is placed in the waiting queue, and corresponding connection pool parameters are determined for the connection pools in the waiting queue in turn.

[0170] The connection pool management device provided in this embodiment can execute the technical solution of the corresponding method embodiment. Its implementation principle and technical effect are similar to those of the corresponding method embodiment, and will not be described in detail here.

[0171] The configuration device in the embodiment of the present application can be provided as an electronic device. Accordingly, the embodiment of the present application also provides an electronic device. The electronic device is intended to be a digital computer in various forms, such as a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers.

[0172] Fig. 9FIG. 1 is a schematic diagram showing the structure of an electronic device according to an exemplary embodiment. Fig. 9 As shown, the electronic device 400 includes: a processor 401, and a memory 402 and a transceiver 403 which are respectively communicatively connected to the processor 401.

[0173] The memory 402 stores computer-executable instructions; the transceiver 403 is used to send and receive data with the client or server.

[0174] The processor 401 executes the computer execution instructions stored in the memory 402 to implement the connection pool management method provided in the present application.

[0175] In the embodiment of the present application, the memory 402 and the transceiver 403 are respectively connected to the processor 401 through a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0176] The components, their connections and relationships, and their functions shown herein are only examples and are not intended to limit the implementation of the present application described and / or required herein. The various components are interconnected using different buses and can be installed on a common motherboard or in other ways as needed.

[0177] In an exemplary embodiment, a computer-readable storage medium is further provided, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the connection pool management method provided in the present application.

[0178] In an exemplary embodiment, a computer program product is also provided, including computer execution instructions. When the computer execution instructions in the computer program product are executed by a processor, they are used to implement the connection pool management method provided in the present application.

[0179] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0180] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0181] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0182] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0183] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a central processing unit (CPU), a graphics processing unit (GPU), an application specific integrated circuit (ASIC), a digital signal processor (DSP), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller, a microprocessor or other electronic components. Unless otherwise specified, the memory may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a USB flash drive, random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), enhanced dynamic random access memory (EDRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), resistive random access memory (RRAM), high-bandwidth memory HBM (High-BandwidthMemory), hybrid memory cube HMC (Hybrid Memory Cube), magnetic storage, flash memory, magnetic disk, optical disk, mobile hard disk or disk, etc.

[0184] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the methods of each embodiment of the present application.

[0185] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0186] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0187] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. A connection pool management method, characterized in that: Applied to configuring a device, the method comprises: Receive operation data for a target connection pool sent by a client, the target connection pool being a connection pool related to a target application, the operation data including the number of times the target connection pool accesses a server within a preset time interval, the server being used to provide background services for the target application; Based on the operation data, adjusting the connection pool parameters corresponding to the target connection pool to obtain adjusted connection pool parameters, wherein the connection pool parameters are used to describe the target connection pool; The adjusted connection pool parameters are sent to the client, so that the client configures the target connection pool based on the adjusted connection pool parameters.

2. The method according to claim 1, characterized in that The connection pool parameters include the number of core threads; and adjusting the connection pool parameters corresponding to the target connection pool based on the operation data to obtain the adjusted connection pool parameters includes: Determine the ratio between the operation data and the interval length corresponding to the preset time interval as the access frequency corresponding to the target connection pool, wherein the access frequency indicates the frequency of the target connection pool accessing the server; Based on the access frequency, the number of core threads corresponding to the target connection pool is adjusted to obtain an adjusted number of core threads, and the access frequency is positively correlated with the number of core threads.

3. The method according to claim 1, characterized in that Before receiving the operation data for the target connection pool sent by the client, the method further includes: Receiving an initialization request for the target connection pool sent by the client; Obtaining the stored initial connection pool parameters corresponding to the client; The initial connection pool parameters are sent to the client, so that the client initializes the target connection pool according to the initial connection pool parameters.

4. The method according to claim 3, characterized in that The process of determining the initial connection pool parameters includes: Receiving a registration request for the target connection pool sent by the client, wherein the registration request carries connection pool information corresponding to the target connection pool; Storing the connection pool information in the registration information group corresponding to the server; Based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, initial connection pool parameters corresponding to the target connection pool are determined, and the initial connection pool parameters are stored.

5. The method according to claim 4, characterized in that The connection pool information includes an Internet Protocol IP address of the server; and storing the connection pool information in a registration information group corresponding to the server includes: If there is a registration information group corresponding to the IP address, storing the connection pool information in the registration information group corresponding to the IP address; If the registration information group corresponding to the IP address does not exist, a registration information group corresponding to the IP address is created, and the connection pool information is stored in the registration information group.

6. The method according to claim 4, characterized in that The preset configuration information includes a preset idle thread survival time, a preset time unit corresponding to the preset idle thread survival time, a preset thread factory, and a preset rejection strategy; The determining the initial connection pool parameters corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client includes: Using a preset formula, based on the maximum number of connections corresponding to the server and the number of computing cores corresponding to the client, determine the initial number of core threads and the initial maximum number of threads; The initial connection pool parameters are composed of the initial core thread number, the initial maximum thread number, the preset idle thread survival time, the preset time unit corresponding to the preset idle thread survival time, the preset thread factory and the preset rejection strategy.

7. The method according to claim 4, characterized in that After determining the initial connection pool parameters corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client, the method further includes: If it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed user connections is less than the sum of the remaining number of connection pools, the target connection pool is placed in a waiting queue until it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed user connections is greater than or equal to the sum of the remaining number of connection pools, and the initial connection pool parameters corresponding to the target connection pool are determined again based on the preset configuration information corresponding to the client, the maximum number of connections corresponding to the server, and the number of computing cores corresponding to the client; If it is determined that the difference between the maximum number of connections corresponding to the server and the number of fixed connections of the user is greater than or equal to the sum of the numbers of remaining connection pools, the step of storing the initial connection pool parameters is performed.

8. The method according to claim 1, characterized in that The method further comprises: Using a correction formula, respectively determining the correction trend information and the connection number correction value corresponding to the target connection pool, wherein the correction trend information indicates that the connection number increases or decreases; If the waiting queue is empty, adjusting the connection pool parameters corresponding to the target connection pool according to the correction trend information and the connection number correction value, the waiting queue including a plurality of connection pools whose connection pool parameters are to be determined and arranged in sequence; If the waiting queue is not empty, the target connection pool is put into the waiting queue, and corresponding connection pool parameters are determined for the connection pools in the waiting queue in turn.

9. A connection pool management device, characterized in that: Settings in the configuration device include: A receiving module, configured to receive operation data for a target connection pool sent by a client, wherein the target connection pool is a connection pool related to a target application, and the operation data includes the number of times the target connection pool accesses a server within a preset time interval, and the server is configured to provide background services for the target application; An adjustment module, configured to adjust a connection pool parameter corresponding to the target connection pool based on the operation data to obtain an adjusted connection pool parameter, wherein the connection pool parameter is used to describe the target connection pool; The sending module is used to send the adjusted connection pool parameters to the client, so that the client configures the target connection pool based on the adjusted connection pool parameters.

10. An electronic device, characterized in that: include: A processor, and a memory and a transceiver respectively communicatively connected to the processor; The memory stores computer-executable instructions; the transceiver is used to send and receive data with a client or a server; The processor executes the computer-executable instructions stored in the memory to implement the connection pool management method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the connection pool management method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Management system of cluster database connection pool

    CN112069237A

  • Method and device for adjusting capacity of connection pool, storage medium and electronic equipment

    CN112181652A

  • Thread pool adjustment method and device thereof, storage medium and electronic equipment

    CN113157410A

  • System and method for using quality of service with workload management in an application server environment

    US20120311138A1

Cited By

  • Method for switching data source when springboot service interface is called based on xxl-job timed task

    CN120066747A

  • Method for switching data sources when calling the springboot service interface based on the xxl-job timed task

    CN120066747B