[go: up one dir, main page]

CN119814554A - Connection pool management method, device, equipment and storage medium - Google Patents

Connection pool management method, device, equipment and storage medium Download PDF

Info

Publication number
CN119814554A
CN119814554A CN202311311017.4A CN202311311017A CN119814554A CN 119814554 A CN119814554 A CN 119814554A CN 202311311017 A CN202311311017 A CN 202311311017A CN 119814554 A CN119814554 A CN 119814554A
Authority
CN
China
Prior art keywords
connection pool
client
target
parameters
connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311311017.4A
Other languages
Chinese (zh)
Other versions
CN119814554B (en
Inventor
冯强
徐益军
杨贵森
谯磊
刘阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China United Network Communications Group Co Ltd
Unicom Digital Technology Co Ltd
Unicom Cloud Data Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Unicom Digital Technology Co Ltd
Unicom Cloud Data Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China United Network Communications Group Co Ltd, Unicom Digital Technology Co Ltd, Unicom Cloud Data Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202311311017.4A priority Critical patent/CN119814554B/en
Publication of CN119814554A publication Critical patent/CN119814554A/en
Application granted granted Critical
Publication of CN119814554B publication Critical patent/CN119814554B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Computer And Data Communications (AREA)

Abstract

本申请提供一种连接池管理方法、装置、设备及存储介质,涉及计算机技术领域。该方法应用于配置设备,该方法包括:接收客户端发送的针对目标连接池的运行数据,目标连接池为目标应用相关的连接池,运行数据包括目标连接池在预设时间区间内访问服务端的次数,服务端用于为目标应用提供后台服务;基于运行数据,对目标连接池对应的连接池参数进行调整,以获得调整后的连接池参数,连接池参数用于描述目标连接池;向客户端发送调整后的连接池参数,以使客户端基于调整后的连接池参数对目标连接池进行配置。调整后的连接池参数更加贴合目标连接池的真实使用情况,实现了对目标连接池的连接池参数的动态调整,进而改善了连接池管理效果。

The present application provides a connection pool management method, device, equipment and storage medium, and relates to the field of computer technology. The method is applied to a configuration device, and the method includes: 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; based on the operation data, adjusting the connection pool parameters corresponding to the target connection pool to obtain adjusted connection pool parameters, and the connection pool parameters are used to describe the target connection pool; 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 in line with the actual usage of the target connection pool, and the dynamic adjustment of the connection pool parameters of the target connection pool is realized, thereby improving the connection pool management effect.

Description

Connection pool management method, device, equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for managing a connection pool.
Background
With the rapid development of computer technology, most of internet applications currently adopt a structure that a client is connected with a server to realize that the client obtains data expected by the client from the server. When the client establishes a bottom layer TCP (Transmission Control Protocol ) connection with the server, the client needs to undergo three-way handshake with the server, and the three-way handshake includes a series of system calls with high cost on machine resources, such as Input/Output (I/O) operation, network monitoring and the like.
In the related art, by putting connection resources in advance in a management container, which is called a connection pool, a client obtains an available connection from the connection pool when accessing a server, and then uses the connection to communicate with a server. The connection pool is configured by the connection pool parameters, however, in the related art, the connection pool parameters are generally set by a technician according to experience in advance, but there is dynamic variation in communication between the client and the server, and how to dynamically adjust the connection pool parameters to better manage the connection pool becomes a problem to be solved.
Disclosure of Invention
The application provides a method, a device, equipment and a storage medium for managing a connection pool, which realize the dynamic adjustment of the connection pool parameters of a target connection pool, improve the correctness of the connection pool parameters and further improve the management effect of the connection pool.
In a first aspect, the present application provides a connection pool management method, applied to configuration equipment, the method comprising:
Receiving operation data which is sent by a client and aims at a target connection pool, wherein the target connection pool is a connection pool related to a target application, the operation data comprises the times of the target connection pool accessing a server in a preset time interval, and the server is used for providing background service for the target application;
Adjusting connection pool parameters corresponding to the target connection pool based on the operation data to obtain adjusted connection pool parameters, wherein 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.
Optionally, the connection pool parameters include core thread numbers, and the adjusting the connection pool parameters corresponding to the target connection pool based on the operation data to obtain adjusted connection pool parameters includes:
determining the ratio between the running 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 represents the frequency of the target connection pool accessing the server side;
and adjusting the core thread number corresponding to the target connection pool based on the access frequency to obtain an adjusted core thread number, wherein the access frequency is positively correlated with the core thread number.
Optionally, before the 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, which is sent by the client;
Acquiring stored initial connection pool parameters corresponding to the client;
and sending the initial connection pool parameters to the client so that the client initializes the target connection pool according to the initial connection pool parameters.
Optionally, the process of determining the initial connection pool parameter 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 into a registration information group corresponding to the server;
And determining an initial connection pool parameter corresponding to the target connection pool based on preset configuration information corresponding to the client, the maximum connection number corresponding to the server and the calculation core number corresponding to the client, and storing the initial connection pool parameter.
Optionally, the connection pool information includes an internet protocol IP address of the server, and the storing the connection pool information in a registration information group corresponding to the server includes:
if the registration information group corresponding to the IP address exists, the connection pool information is stored in the registration information group corresponding to the IP address;
if the registration information group corresponding to the IP address does not exist, creating the registration information group corresponding to the IP address, and storing the connection pool information into the registration information group.
Optionally, the preset configuration information includes 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 determining the initial connection pool parameter corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum connection number corresponding to the server and the calculation core number corresponding to the client includes:
Adopting a preset formula, and determining an initial core thread number and an initial maximum thread number based on the maximum connection number corresponding to the server side and the calculation core number corresponding to the client side;
And forming the initial connection pool parameters by the initial core thread number, the initial maximum thread number, the preset idle thread survival time, a preset time unit corresponding to the preset idle thread survival time, the preset thread factory and the preset rejection strategy.
Optionally, after determining the initial connection pool parameter corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum connection number corresponding to the server, and the calculation core number corresponding to the client, the method further includes:
If the difference between the maximum connection number corresponding to the server side and the user fixed connection number is determined to be smaller than the sum of the number of the remaining connection pools, placing the target connection pool into a waiting queue until the difference between the maximum connection number corresponding to the server side and the user fixed connection number is determined to be larger than or equal to the sum of the number of the remaining connection pools, and determining initial connection pool parameters corresponding to the target connection pool again based on preset configuration information corresponding to the client side, the maximum connection number corresponding to the server side and the calculation core number corresponding to the client side;
And if the difference value between the maximum connection number corresponding to the server and the user fixed connection number is determined to be greater than or equal to the sum of the number of the residual connection pools, executing the step of storing the initial connection pool parameters.
Optionally, the method further comprises:
Adopting a correction formula to respectively determine correction trend information and a connection number correction value corresponding to the target connection pool, wherein the correction trend information represents that the connection number is increased or decreased;
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, wherein the waiting queue comprises a plurality of connection pools which are arranged in sequence and are used for determining the connection pool parameters;
And if the waiting queue is not empty, placing the target connection pool into the waiting queue, and sequentially determining corresponding connection pool parameters for the connection pools in the waiting queue.
In a second aspect, the present application provides a connection pool management apparatus, provided in a configuration device, including:
The system comprises a receiving module, a receiving module and a processing module, wherein the receiving module is used for receiving operation data which is sent by a client and aims at a target connection pool, the target connection pool is a connection pool related to a target application, the operation data comprises the times that the target connection pool accesses a server in a preset time interval, and the server is used for providing background service for the target application;
The adjusting module is used for adjusting the connection pool parameters corresponding to the target connection pool based on the operation data to obtain adjusted connection pool parameters, wherein the connection pool parameters are used for describing the target connection pool;
And the sending module is used for 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.
In a third aspect, the application provides an electronic device comprising a processor, and a memory and a transceiver communicatively coupled to the processor, respectively;
The transceiver is used for receiving and transmitting data with the client or the server;
The processor executes computer-executable instructions stored in the memory to implement the connection pool management method according to any one of the first aspects.
In a fourth aspect, the present application provides a computer-readable storage medium having stored therein computer-executable instructions for implementing the connection pool management method of any one of the first aspects when executed by a processor.
In a fifth aspect, the present application provides a computer program product comprising computer-executable instructions which, when executed by a processor, implement the connection pool management method of any of the first aspects.
The method, the device, the equipment and the storage medium for managing the connection pool, provided by the application, acquire the operation data of the target connection pool through the client in the operation process of the target connection pool, send the operation data to the configuration equipment, so that the configuration equipment adjusts the target connection pool based on the operation data, and because the operation data comprises the times of the target connection pool accessing the server in a preset time interval, the operation data can embody the service condition of the target connection pool, so that the adjusted connection pool parameters are more attached to the actual service condition of the target connection pool, the dynamic adjustment of the connection pool parameters of the target connection pool is realized, the correctness of the connection pool parameters is improved, and the management effect of the connection pool is further improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description, serve to explain the principles of the application.
FIG. 1 is a schematic diagram of an application scenario shown in accordance with an exemplary embodiment;
FIG. 2 is a flow diagram illustrating a method of connection pool management, according to an example embodiment;
FIG. 3 is a flow diagram illustrating a method of connection pool management according to another exemplary embodiment;
FIG. 4 is a diagram illustrating a relationship between a server and a connection pool according to an example embodiment;
FIG. 5 is a schematic diagram illustrating an initial connection pool parameter determination procedure, according to an example embodiment;
FIG. 6 is a schematic diagram illustrating a connection pool parameter dynamic adjustment process, according to an example embodiment;
FIG. 7 is a schematic diagram illustrating a connection object usage flow in accordance with an exemplary embodiment;
FIG. 8 is a schematic diagram of a connection pool management device, according to an example embodiment;
Fig. 9 is a schematic diagram of an electronic device according to an exemplary embodiment.
Specific embodiments of the present application have been shown by way of the above drawings and will be described in more detail below. The drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but rather to illustrate the inventive concepts to those skilled in the art by reference to the specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the application. Rather, they are merely examples of apparatus and methods consistent with aspects of the application as detailed in the accompanying claims.
The terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the following description of the embodiments, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
First, the terms involved in the present application will be explained:
core thread number refers to the number of threads that survive, i.e., reside, for a long period of time in the connection pool.
The maximum number of threads refers to the maximum number of threads in the connection pool that can be created.
The idle thread survival time refers to the survival time corresponding to the idle thread, and when no task exists in the task queue of the connection pool and the idle time corresponding to the idle thread reaches the survival time, the idle thread can be destroyed. The number of threads destroyed = maximum number of threads-core number of threads.
The time unit refers to a description unit of the survival time of the idle thread.
The task queue refers to a queue for storing tasks in the connection pool and is used for storing tasks to be executed in the connection pool.
Thread factory refers to the method called when a connection pool creates a new thread.
Rejecting policy refers to a policy how to reject a request to execute when the task queue is full and the worker thread is greater than or equal to the maximum number of threads of the connection pool.
Principle of operation of the connection pool:
Step S1, judging whether the current thread number in a connection pool reaches the core thread number or not for a task to be executed, if not, creating a new thread to execute the task, and after the task is ended, reserving the thread in the connection pool without destruction processing;
Step S2, judging whether the task queue is full, if not, submitting the task to the task queue, and if so, entering step S3;
And S3, judging whether the current thread number in the connection pool reaches the maximum thread number, if not, newly creating threads to execute the task, and if so, processing the task by using a rejection strategy.
When the current thread number in the connection pool reaches the maximum thread number, each time the idle time corresponding to a certain thread reaches the idle thread survival time, destroying the thread until the current thread number in the connection pool is equal to the core thread number.
For a clear understanding of the technical solutions of the present application, the prior art solutions will be described in detail first.
With the rapid development of computer technology, most of internet applications currently adopt a structure that a client is connected with a server to realize that the client obtains data expected by the client from the server. When the client establishes a bottom layer TCP connection with the server, the client needs to undergo three-way handshake with the server, and the three-way handshake comprises a series of system calls with high cost on machine resources, such as I/O (Input/Output) operation, network monitoring and the like.
In the related art, the connection pool is an important middleware. By placing connection resources in advance in a management container, referred to as a connection pool, a client, when accessing a server, first obtains available connections from the connection pool and then uses the connections to communicate with the server. Taking a database connection pool for accessing a database as an example, when a client accesses a database server, the client accesses the connection pool to obtain available connection, and then uses the connection to communicate with the server. By using the connection pool, the client side is not required to newly establish a database connection when being connected with the database server side, thereby improving the system performance.
The connection pool is configured by the connection pool parameters, however, in the related art, the connection pool parameters are generally set by a technician according to experience in advance, but there is dynamic variation in communication between the client and the server, and how to dynamically adjust the connection pool parameters to better manage the connection pool becomes a problem to be solved.
Aiming at the technical problem of poor dynamic scheduling effect caused by large resource use gap between working nodes in the related technology, the inventor finds out in the research that in order to solve the problem, the parameters of the connection pool can be dynamically adjusted in the operation process of the connection pool, and further, the parameters can be adjusted according to the operation condition of the connection pool. In particular, the client obtains the operation data of the target connection pool in the operation process of the target connection pool, and sends the operation data to the configuration equipment, so that the configuration equipment adjusts the target connection pool based on the operation data, and because the operation data comprises the times of the target connection pool accessing the server in a preset time interval, the operation data can embody the service condition of the target connection pool, so that the adjusted connection pool parameters are more attached to the actual service condition of the target connection pool, the dynamic adjustment of the connection pool parameters of the target connection pool is realized, the correctness of the connection pool parameters is improved, and the management effect of the connection pool is further improved.
The application scenario of the connection pool management method provided by the embodiment of the application is described below.
Fig. 1 is a schematic diagram of an application scenario shown according to an example embodiment. As shown in fig. 1, the application scenario includes a configuration device 1, a client 2 and a server 3. The devices are connected through a network.
The configuration device 1 is used for managing a connection pool, the client 2 refers to client devices, the server 3 refers to server devices, and the client 2 and the server 3 communicate through connection objects 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 parameter corresponding to the target connection pool based on the operation data to obtain an adjusted connection pool parameter, and then sends the adjusted connection pool parameter to the client 2, so that the client 2 configures the target connection pool based on the adjusted connection pool parameter.
The following describes the technical scheme of the present application and how the technical scheme of the present application solves the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 2 is a flow diagram illustrating a method of connection pool management, according to an example embodiment. The execution main body of the connection pool management method provided by the application is a connection pool management device which is integrated in configuration equipment, and the configuration equipment is used for managing the connection pool. As shown in fig. 2, the connection pool management method provided in this embodiment includes the following steps:
step S101, receiving operation data sent by a client and aiming at a target connection pool, wherein the target connection pool is a connection pool related to a target application, the operation data comprises the times of the target connection pool accessing a server in a preset time interval, and the server is used for providing background service for the target application.
The target connection pool is a connection pool provided by the server and is used for the client to realize communication with the server through connection in the target connection pool. The client side is provided with a target application, the target application can be any type of application, and a background server of the target application is a server side. And the client acquires the operation data of the target connection pool in real time and sends the operation data to the configuration equipment. Optionally, the client transmits the acquired operation data to the configuration device at regular intervals. The fixed interval is the interval length corresponding to the preset time interval, namely the time interval between the starting time and the ending time in the preset time interval. The preset time interval may be set according to needs, and the embodiment is not limited thereto, for example, the preset time interval may be any time interval with an interval length of 5 minutes, such as 1 point to 1 point for 5 minutes, and further, the preset time interval may be any time interval with an interval length of 10 minutes, such as 2 points to 2 points for 10 minutes.
Step S102, 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 for describing the target connection pool.
The operation data can show the real operation condition of the target connection pool in a preset time interval, so that the connection pool parameters of the target connection pool can be adjusted according to the operation data, and the adjusted connection pool parameters are more close to the real operation condition of the target connection pool. The connection pool parameters comprise any one of core thread number, maximum thread number, idle thread survival time, a time unit corresponding to the idle thread survival time, a task queue, a thread factory and a rejection strategy.
Step S103, the adjusted connection pool parameters are sent to the client side, so that the client side configures the target connection pool based on the adjusted connection pool parameters.
In this embodiment, after the adjusted connection pool parameter is obtained, the adjusted connection pool parameter is sent to the client, so that the client configures the target connection pool.
In this embodiment, in the operation process of the target connection pool by the client, operation data of the target connection pool is obtained, and the operation data is sent to the configuration device, so that the configuration device adjusts the target connection pool based on the operation data, and because the operation data includes the number of times the target connection pool accesses the server in a preset time interval, the operation data can embody the service condition of the target connection pool, so that the adjusted connection pool parameters are more attached to the actual service condition of the target connection pool, the dynamic adjustment of the connection pool parameters of the target connection pool is realized, the correctness of the connection pool parameters is improved, and the management effect of the connection pool is further improved.
Fig. 3 is a flow diagram illustrating a method of connection pool management according to another exemplary embodiment. The execution main body of the connection pool management method provided by the application is a connection pool management device which is integrated in configuration equipment. As shown in fig. 3, the connection pool management method provided in this embodiment includes the following steps:
Step S201, receiving operation data sent by a client and directed against a target connection pool, where the target connection pool is a connection pool related to a target application, and the operation data includes the number of times that the target connection pool accesses a server in a preset time interval, where the server is used to provide background services for the target application.
In some embodiments, the implementation of step S201 is the same as that of step S101, and will not be described here again.
Illustratively, fig. 4 is a schematic diagram illustrating a relationship between a server and a connection pool, where the server is provided with a plurality of connection pools, as shown in fig. 4, including a connection pool a, a connection pool B, and the like, and the configuration center listens to operation data of the connection pools, where each connection pool has a user corresponding to it, such as user 1, user 2, user 3, user 4, and the like, where the user is a database connection user or a ssh connection user, and ssh refers to Secure Shell protocol (Secure Shell).
In this embodiment, after step S201, the configuration device adjusts, based on the operation data, the connection pool parameters corresponding to the target connection pool to obtain adjusted connection pool parameters, where the connection pool parameters are used to describe the target connection pool. Optionally, the connection pool parameters include core thread numbers. Correspondingly, based on the operation data, the implementation manner of adjusting the connection pool parameters corresponding to the target connection pool to obtain the adjusted connection pool parameters includes the following steps S202-S203.
Step S202, determining the ratio between the running 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 represents the frequency of the target connection pool accessing the server side.
The operation data comprises the times of accessing the server side by the target connection pool in a preset time interval, the times are more frequent, the times are less frequent, and accordingly, the frequency of accessing the server side by the target connection pool in the preset time interval can be represented between the operation data and the interval length corresponding to the preset time interval, so that the wallpaper can be determined to be the access frequency corresponding to the target connection pool.
Step S203, 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 related to the number of core threads.
The larger the access frequency is, the more the target connection pool needs the resident threads, the larger the number of required core threads is, and the smaller the access frequency is, the smaller the target connection pool needs the resident threads, the smaller the number of required core threads is, and accordingly, the access frequency is positively related to the number of core threads. Therefore, 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 implementation manner of step S203 may be flexibly set by a technician as required, which is not limited in this embodiment. In an alternative implementation manner, the configuration device stores a corresponding relation between the access frequency and the core thread number in advance, the corresponding relation satisfies a condition that the access frequency and the core thread number are positively correlated, so that after the access frequency is determined, the core thread number corresponding to the determined access frequency is queried from the stored corresponding relation between the access frequency and the core thread number, and the core thread number is used as the adjusted core thread number.
In this embodiment, the greater the access frequency, the greater the demand of the target connection pool for resident threads, the greater the number of required core threads, and the smaller the access frequency, the smaller the demand of the target connection pool for resident threads, and the smaller the number of required core threads, so that the adjusted number of core threads can more satisfy the current running condition of the target connection pool by adjusting the number of core threads corresponding to the target connection pool based on the access frequency.
Step S204, the adjusted connection pool parameters are sent to the client side, so that the client side configures the target connection pool based on the adjusted connection pool parameters.
In some embodiments, the implementation of step S204 is the same as the implementation of step S103, and will not be described here again.
In the present application, the above-described embodiment describes a process in which the configuration device dynamically adjusts the connection pool parameters corresponding to the target connection pool during the operation of the target connection pool. Before running the target connection pool, the client needs to initialize the target connection pool, and accordingly, on the basis of the above embodiment, an initialization process of the target connection pool is described below.
In an alternative embodiment, before receiving the operation data for the target connection pool sent by the client, the connection pool management method further comprises the steps that the client sends an initialization request for the target connection pool to the configuration device when the connection requirement exists, correspondingly, the configuration device receives the initialization request for the target connection pool sent by the client, obtains initial connection pool parameters corresponding to the stored 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.
When the client needs to execute tasks, the client can be considered to have connection requirements, and an initialization request for the target connection pool is sent to the configuration equipment. The task is a task realized by communicating with a server, for example, the task is to acquire data from a database, and the server is a server corresponding to the database. The related art loads and initializes the connection pool into the memory when the project is started, however, no task is usually submitted to the connection pool at this time, so that the connection in the connection pool is in an idle state, and unnecessary threads and memory overhead are caused. In this embodiment, the client connected to the server by using the connection pool method does not load and initialize the connection pool until the task needs to be executed when the project is started in a lazy loading manner, so as to reduce the phenomena of occupying threads and consuming memory and CPU (Central Processing Unit ) resources of the client when the service is idle.
In this embodiment, the configuration device stores the initial connection pool parameters corresponding to the client in advance, acquires the stored initial connection pool parameters after receiving the initialization request sent by the client, and sends the initial connection pool parameters to the client, so that the client can initialize the target connection pool according to the initial connection pool parameters, and resources of the client are saved in a lazy loading manner.
In the above optional embodiment, the configuration device stores the initial connection pool parameters corresponding to the target connection pool in advance, and in an optional embodiment, the process of determining the initial connection pool parameters includes the steps of receiving a registration request for the target connection pool sent by the client, the registration request carrying connection pool information corresponding to the target connection pool, storing the connection pool information in a registration information group corresponding to the server, determining the initial connection pool parameters corresponding to the target connection pool based on preset configuration information corresponding to the client, the maximum connection number corresponding to the server, and the calculation core number corresponding to the client, and storing the initial connection pool parameters.
The configuration device stores registration information groups corresponding to the service terminals respectively, and the registration information groups store connection pool information corresponding to at least one connection pool provided by the corresponding service terminal respectively. The configuration device stores preset configuration information in advance, and the preset configuration information includes 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 may be set as needed, which is not limited in this embodiment. The maximum connection number corresponding to the server side refers to the maximum value of the connection number that the server side can establish.
In this embodiment, in the process of registering the target connection pool, the initial connection pool parameter corresponding to the target connection pool is determined, so as to provide data support for the initialization of the subsequent target connection pool.
In an alternative implementation of the above alternative embodiment, the connection pool information includes an identification of the server, which is illustratively an IP address. Correspondingly, the implementation mode of storing the connection pool information in the registration information group corresponding to the server side comprises the following two cases:
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 an IP address, which indicates that a registration information group corresponding to a server to which the IP address belongs has been stored, connection pool information corresponding to a target connection pool may be stored in the registration information group. The group name of the registration information group may be an IP address of the server.
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, which means that the registration information group corresponding to the server to which the IP address belongs is not stored, the registration information group corresponding to the IP address is created first, and then the connection pool information is stored in the created registration information group. Specifically, an IP address is used as a group name, a group is created, and ssh parameters are obtained from a server through a user name and a password corresponding to the server and stored in the group.
In the above optional implementation manner, the registration information set corresponding to the server uses the IP address corresponding to the server as the set name to store, when the connection pool information is stored, by first judging whether the registration information set corresponding to the IP address exists, the connection pool information is stored according to the corresponding situation, so that the occurrence of failure in storing the connection pool information is reduced.
In an optional implementation manner of the above optional embodiment, the preset configuration information includes 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, and the determining an implementation manner of the initial connection pool parameter corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum connection number corresponding to the server and the calculation core number corresponding to the client correspondingly includes determining the initial core thread number and the initial maximum thread number by adopting a preset formula based on the maximum connection number corresponding to the server and the calculation core number corresponding to the client, and forming the initial connection pool parameter by 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.
In the above optional implementation manner, the number of computing cores corresponding to the client can embody the performance of the client, the larger the number of computing cores is, the stronger the performance is, the smaller the number of computing cores is, the weaker the performance is, by adopting a preset formula, the initial core thread number and the initial maximum thread number can be accurately determined based on the maximum connection number corresponding to the server and the number of computing cores corresponding to the client, and on the basis, the initial connection pool parameter can be determined by combining the preset configuration information, so that the determination efficiency is higher.
Illustratively, the preset formulas include a formula for determining an initial core thread number and a formula for determining an initial maximum thread number. Wherein, the formula for determining the initial core thread number is shown in the following formula I:
Wherein Mn represents the initial core thread number corresponding to the nth client, cn represents the calculation core number corresponding to the nth client, n E (1, D), D represents the total number of clients, D is a positive integer greater than 1, and S represents the maximum connection number corresponding to the server.
In one possible case, if the number of calculation cores corresponding to a certain client is too large, the initial core number determined according to the formula one is too large, so that the client occupies more connection resources of the server, and other clients may not be separated from the connection resources.
Wherein Mn' represents the updated initial core thread number corresponding to the nth client, mn represents the initial core thread number corresponding to the nth client calculated by the formula I.
For example, the maximum connection number corresponding to the server is 1000, the calculation core number corresponding to the client a is 996, the calculation core number corresponding to the client B is 2, the initial core number corresponding to the client a is 995, the initial core number corresponding to the client B is 0 according to the first calculation of the formula, it can be seen that when the difference between the calculation core numbers corresponding to the client a and the client B is large, the client B may not be able to divide the connection resource, and on this basis, further calculation is performed according to the second calculation of the formula, the updated initial core number corresponding to the client a is 18, and the updated initial core number corresponding to the client B is 1.
On the basis of the formula I, the initial core thread number is further calculated through the formula II, so that each connection pool can be divided into at least one connection under the condition that the number of connections provided by a server is insufficient and distributed according to the performance of a client, and the reasonable core thread number can be obtained by each connection pool under the condition that the number of connections provided by the server is sufficient, and therefore the phenomenon that a large number of invalid threads are obtained by individual clients can be reduced.
Accordingly, the formula for determining the initial maximum thread number is referred to as formula three below:
Wherein Wn represents the initial maximum thread number corresponding to the nth client, and beta represents a random factor with a value of 0, -1 or 1.
And for the determination of the initial maximum thread number, adding the ratio of the thread number already obtained on the basis of the initial core thread number and taking the logarithm, acquiring the corresponding maximum thread number through the performance of the client under the condition of redundant connection number, adding a random factor, and carrying out pre-estimation judgment on the actual running condition after the connection pool, thereby reducing the capacity expansion requirement.
Wherein, the constraint conditions of the formula I and the formula II are thatThe constraint of equation three isThat is, the maximum connection number corresponding to the server is smaller than the total number of initial core thread numbers corresponding to the clients and smaller than the total number of maximum thread numbers, each client takes the form of a queue, preemptively acquires the connection number, and if the connection number is not acquired, the client needs to wait in a waiting queue and alarm. In this embodiment, the preset formula, the constraint formula, the related parameters of the preset formula and the related parameters of the constraint formula, the waiting queue and the alarm prompt interface are exposed for the user to modify according to the requirement, for example, to be exposed in a config (configuration file) form.
The above alternative implementation is illustrated by taking the example that the number of clients is greater than 1. When the number of clients is 1, after the initial core thread number and the initial maximum thread number are respectively determined by a formula for determining the initial core thread number and a formula for determining the initial maximum thread number, further calculation is needed, specifically, a half value of the determined initial core thread number is determined as a final initial core thread number, and a half value of the determined initial maximum thread number is determined as a final initial maximum thread number.
On the basis of the above optional implementation manner, optionally, if the user fixed connection number exists, before determining the initial core thread number and the initial maximum thread number based on the maximum connection number corresponding to the server and the calculation core number corresponding to the client by adopting a preset formula, determining a difference value between the maximum connection number corresponding to the server and the user fixed connection number as an updated maximum connection number, and then determining the initial core thread number and the initial maximum thread number based on the updated maximum connection number and the calculation core number corresponding to the client by adopting the preset formula. The user fixed connection number is the connection number which is set by the user according to the requirement in advance.
On the basis of the above optional implementation manner, optionally, after determining the initial connection pool parameter corresponding to the target connection pool based on the preset configuration information corresponding to the client, the maximum connection number corresponding to the server and the calculation core number corresponding to the client, the connection pool management method provided by the present application further includes the following two cases:
In the first case, if it is determined that the difference between the maximum connection number corresponding to the server and the fixed connection number of the user is smaller than the sum of the remaining connection pools, the target connection pool is placed into the waiting queue until it is determined that the difference between the maximum connection number corresponding to the server and the fixed connection number of the user is greater than or equal to the sum of the remaining connection pools, and the initial connection pool parameters corresponding to the target connection pool are determined again based on preset configuration information corresponding to the client, the maximum connection number corresponding to the server and the calculation core number corresponding to the client. The difference between the maximum connection number and the fixed connection number of the user is regarded as the available connection number provided by the server, if the difference is smaller than the sum of the number of the remaining connection pools, the available connection number is insufficient, connection cannot be allocated to the target connection pool at present, and the determined initial connection pool parameter is unavailable.
And in the second case, if the difference between the maximum connection number corresponding to the server and the fixed connection number of the user is determined to be greater than or equal to the sum of the number of the residual connection pools, executing the step of storing the initial connection pool parameters. Wherein, in case the number of available connections is sufficient, the determined initial connection pool parameters are available, the determined initial connection pool parameters are directly stored.
Fig. 5 is a schematic diagram of an initial connection pool parameter determining process according to an exemplary embodiment, where, as shown in fig. 5, a connection pool is initially registered, server information, that is, a maximum connection number is obtained, whether there is a user fixed connection number is first determined, if not, a preset formula is adopted, an initial connection pool parameter is determined based on the maximum connection number and a calculation core number corresponding to a client, then whether there is a sufficient connection number is determined, if there is a difference between the maximum connection number corresponding to the server and the user fixed connection number is determined as an updated maximum connection number, then a preset formula is adopted, an initial connection pool parameter is determined based on the updated maximum connection number and the calculation core number corresponding to the client, then whether there is a sufficient connection number is determined, if there is a sufficient connection number, the determined initial connection pool parameter is stored, and the connection pool configuration is refreshed, and if there is a insufficient connection number, the target connection pool is placed into a waiting queue, on the one hand, and on the other hand, the cluster is dynamically adjusted.
In the above alternative implementation manner, through the example and weight analysis, the connection resources are allocated to the target connection pool according to the performance of the client, when the connection resources are fewer, it can be ensured that the client can be allocated to a certain connection resource as much as possible, and the user can self-define the allocation through the user fixed connection number, so that the limited connection resources are more efficiently and fully utilized.
On the basis of the embodiment, the configuration equipment can also dynamically adjust the core thread number and the maximum thread number corresponding to the target connection pool at fixed time intervals. The time interval may be set as desired, for example, 5 seconds, 10 seconds, etc. In an alternative embodiment, the method for managing the connection pool provided by the application further comprises the steps of adopting a correction formula to respectively determine correction trend information and connection number correction values corresponding to the target connection pool, wherein the correction trend information indicates that the connection number is increased or decreased, adjusting the connection pool parameters corresponding to the target connection pool according to the correction trend information and the connection number correction values if a waiting queue is empty, wherein the waiting queue comprises a plurality of connection pools which are sequentially arranged and are to be determined, and placing the target connection pool into the waiting queue if the waiting queue is not empty, and sequentially determining the corresponding connection pool parameters for the connection pools in the waiting queue.
If the correction trend information indicates that the number of connections increases, the number of connections corresponding to the target connection pool needs to be expanded, and if the correction trend information indicates that the number of connections decreases, the number of connections corresponding to the target connection pool needs to be contracted. The connection number is contracted or expanded by adjusting parameters of the connection pool, specifically, the core thread number and the maximum thread number. The connection number correction value is a value which is specifically required to be adjusted, and the connection number correction value comprises a core thread number correction value and a maximum thread number correction value. Alternatively, the correction formula is referred to as formula four below:
Equation four:
Where P represents the difference between the current calculated weight and the sum of the last calculated weights, t represents the length of the last time period, ct represents the number of task submissions to the target connection pool in the last time period, S represents a set of recent time periods, S e {10,30,60,600....degree, P0 represents the sum of the weights calculated last time, c1 represents the core thread number correction value, and c2 represents the maximum thread number correction value. Constraint of equation four is In this embodiment, the correction formula and various parameters in the formula may be exposed for the user to modify as required.
The implementation mode of adjusting the connection pool parameters corresponding to the target connection pool according to the correction trend information and the connection number correction value comprises the steps of determining the sum value of the core thread number in the connection pool parameters and the core thread number correction value as updated core thread numbers and determining the sum value of the maximum thread number in the connection pool parameters and the maximum thread number correction value as updated maximum thread numbers if the correction trend information indicates that the connection number is increased, determining the difference value of the core thread number in the connection pool parameters and the core thread number correction value as updated core thread numbers if the correction trend information indicates that the connection number is decreased, and determining the difference value of the maximum thread number in the connection pool parameters and the maximum thread number correction value as updated maximum thread numbers.
For example, fig. 6 is a schematic diagram of a dynamic adjustment flow of parameters of a connection pool, as shown in fig. 6, where ssh related parameters of a server are refreshed and saved every 10 seconds, and then a correction formula is used to determine P, and determine whether P is greater than 0. When P is larger than 0, the target connection pool needs to be expanded, and when P is smaller than 0, the target connection pool needs to be contracted. And determining a connection number correction value corresponding to the target connection pool by using a correction formula, comparing the ssh related parameter with the ssh related parameter acquired last time, wherein the ssh related parameter comprises a maximum connection number, namely, the maximum connection number and the maximum connection number acquired last time are compared, determining a change value of the maximum connection number, namely, a difference value between the maximum connection number and the maximum connection number, and judging whether a waiting queue is empty, namely, whether the waiting queue has a connection pool waiting to be allocated. When the waiting queue is empty, the parameters of the connection pools are dynamically adjusted according to a strategy, the configuration of the connection pools is refreshed, specifically, if at least one connection pool needs to be expanded and the number of the left connection of the service end is larger than 0, the connection pool with higher c is preferentially allocated to the connection pool with higher c according to the proportion of c, wherein the maximum number of the connection corresponding to the service end minus the number of the used connection is the number of the left connection, if at least one connection pool needs to be expanded and the number of the left connection of the service end is 0, when the highest c value is higher than the lowest c value by 3 times of a threshold value, the connection number of the lowest c value is recovered and allocated to the connection pool with the highest c value, and if at least one connection pool needs to be contracted, the connection pool is contracted according to correction trend information and connection number correction value. When the connection pool exists in the waiting queue, judging whether the number of the left connection of the server is larger than the number of the connection pools waiting in the waiting queue. When the number of the remained connection is smaller than the number of the connection pools waiting in the waiting queue, the connection pools are sequentially allocated with one connection number according to the first-come first-served principle, and the remained connection pools which are not allocated with the connection number are continuously reserved in the waiting queue for waiting and alarm processing.
In the above alternative embodiment, a dynamic adjustment scheme is provided, where when P is greater than 0, it indicates that expansion is required, when P is less than 0, it indicates that contraction is required, and when the target connection pool continuously requires expansion or contraction twice, the connection pool parameters of the target connection pool are dynamically adjusted, where the dynamic adjustment of the core thread number and the maximum thread number considers the concurrency of the client, the concurrency of the target connection pool, the performance of itself, and the difference value from the last time, and constraint is performed by constraint conditions, and by combining the concurrency number of the last time period of the connection pool, the weight difference value, and the performance of the client, it calculates whether the connection pool needs to be expanded or contracted, and when the system resources are seriously insufficient, preferentially allocates connection resources for the connection pool with higher concurrency, so that the system resources of the client and the server can be fully utilized, and the connection pool can work normally as much as possible, thereby improving the overall resource utilization of the cluster.
In this embodiment, when a connection object needs to be obtained from a connection pool, whether an idle connection object exists is determined first, when an idle connection object exists, whether the current maximum number of threads and the number of core threads reach a threshold value is determined when no idle connection object exists, and the two parameters are exposed, so that the effect of dynamically adjusting the size of the connection pool can be achieved without shutting down the connection pool, if yes, waiting in a waiting queue is performed, if not, the thread factory is called to create the connection object, and after the connection object is used, the connection object is returned to the connection pool.
Most of currently used connection pool technologies load and initialize a connection pool into a memory when an item is started, and at this time, no task is usually submitted to the connection pool, so that connection is resident in an idle period, and unnecessary thread and memory overhead are caused. According to the scheme, under a distributed scene, a client end connected with a server end in a connection pool mode can not load and initialize the connection pool when a project is started in a lazy loading mode, and the connection pool is loaded and initialized until a task needs to be executed, so that the client end is prevented from occupying resources such as internal memory, CPU and the like when the service is idle. And when the client needs to initialize the connection pool, the client firstly takes ssh parameters corresponding to the server through configuration equipment, then determines the parameters of the connection pool through calculation, and transmits the parameters of the connection pool to the client, thereby completing the initial allocation of the connection pool. In the application, the client using the connection pool can send the operation condition of the connection pool to the configuration equipment, so that the configuration equipment dynamically adjusts the core thread number and the maximum thread number of the connection pool according to the operation condition of the connection pool of the client, thereby realizing the dynamic contraction, recovery and management of the connection pool. The application realizes configuration monitoring, instance and weight analysis, dynamic configuration strategy and dynamic recovery strategy through the container.
Fig. 8 is a schematic structural diagram of a connection pool management apparatus according to an exemplary embodiment, and as shown in fig. 8, in this embodiment, the connection pool management apparatus 300 may be disposed in a configuration device, and the connection pool management apparatus 300 includes:
The receiving module 301 is configured to receive operation data sent by a client and directed against a target connection pool, where the target connection pool is a connection pool related to a target application, and the operation data includes a number of times the target connection pool accesses a server in a preset time interval, where the server is configured to provide background service for the target application;
The adjustment module 302 is configured to adjust, based on the operation data, a connection pool parameter corresponding to the target connection pool, so as to obtain an adjusted connection pool parameter, where the connection pool parameter is used to describe the target connection pool;
And the sending module 303 is configured to send the adjusted connection pool parameter to the client, so that the client configures the target connection pool based on the adjusted connection pool parameter.
Optionally, the connection pool parameters include core thread numbers, an adjustment module 302 for:
Determining the ratio between the running 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 represents the frequency of the target connection pool accessing the server side;
and adjusting the number of core threads corresponding to the target connection pool based on the access frequency to obtain the adjusted number of core threads, wherein the access frequency is positively correlated with the number of core threads.
Optionally, the apparatus 300 further comprises an initialization module, configured to:
Receiving an initialization request for a target connection pool sent by a client;
acquiring stored initial connection pool parameters corresponding to a client;
And sending the initial connection pool parameters to the client so that the client initializes the target connection pool according to the initial connection pool parameters.
Optionally, the apparatus 300 further comprises a determining module, configured to:
Receiving a registration request for a target connection pool sent by a client, wherein the registration request carries connection pool information corresponding to the target connection pool;
storing the connection pool information into a registration information group corresponding to the server;
and determining initial connection pool parameters corresponding to the target connection pool based on preset configuration information corresponding to the client, the maximum connection number corresponding to the server and the calculation core number corresponding to the client, and storing the initial connection pool parameters.
Optionally, the connection pool information comprises an Internet Protocol (IP) address of the server, a determining module, a processing module and a processing module, wherein the determining module is used for:
if the registration information group corresponding to the IP address exists, the connection pool information is stored in the registration information group corresponding to the IP address;
if the registration information group corresponding to the IP address does not exist, the registration information group corresponding to the IP address is created, and the connection pool information is stored in the registration information group.
Optionally, the preset configuration information includes 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;
A determining module for:
Adopting a preset formula, and determining an initial core thread number and an initial maximum thread number based on the maximum connection number corresponding to the server and the calculation core number corresponding to the client;
And forming initial connection pool parameters by the initial core thread number, the initial maximum thread number, the 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.
Optionally, the determining module is configured to:
If the difference between the maximum connection number corresponding to the server side and the user fixed connection number is determined to be smaller than the sum of the number of the remaining connection pools, placing the target connection pool into a waiting queue until the difference between the maximum connection number corresponding to the server side and the user fixed connection number is determined to be larger than or equal to the sum of the number of the remaining connection pools, and determining initial connection pool parameters corresponding to the target connection pool again based on preset configuration information corresponding to the client side, the maximum connection number corresponding to the server side and the calculation core number corresponding to the client side;
and if the difference value between the maximum connection number corresponding to the server and the fixed connection number of the user is larger than or equal to the sum of the number of the residual connection pools, storing the initial connection pool parameters.
Optionally, the adjusting module 302 is further configured to:
Adopting a correction formula to respectively determine correction trend information and a connection number correction value corresponding to the target connection pool, wherein the correction trend information indicates that the connection number is increased or decreased;
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, wherein the waiting queue comprises a plurality of connection pools which are arranged in sequence and are used for determining the connection pool parameters;
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 sequence.
The connection pool management device provided in this embodiment may execute the technical scheme of the corresponding method embodiment, and its implementation principle and technical effects are similar to those of the corresponding method embodiment, and will not be described in detail herein.
The configuration device in the embodiment of the application can be provided as an electronic device. Correspondingly, the embodiment of the application also provides electronic equipment. Electronic devices are intended for various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers.
Fig. 9 is a schematic diagram of an electronic device according to an exemplary embodiment. As shown in fig. 9, the electronic device 400 includes a processor 401 and a memory 402 and a transceiver 403 communicatively connected to the processor 401, respectively.
The memory 402 stores computer-executable instructions, and the transceiver 403 is used to transmit and receive data to and from a client or a server.
The processor 401 executes computer-executable instructions stored in the memory 402 to implement the connection pool management method provided by the present application.
In this embodiment of the present application, the memory 402 and the transceiver 403 are respectively connected to the processor 401 through a bus. The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (PERIPHERAL COMPONENT INTERCONNECT, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the applications described and/or claimed herein. The various components are interconnected using different buses and may be mounted on a common motherboard or in other manners as desired.
In an exemplary embodiment, there is also provided a computer-readable storage medium having stored therein computer-executable instructions for implementing the connection pool management method provided by the present application when executed by a processor.
In an exemplary embodiment, a computer program product is also provided, comprising computer-executable instructions for implementing the connection pool management method provided by the application when the computer-executable instructions in the computer program product are executed by a processor.
It should be noted that, for simplicity of description, the foregoing method embodiments are all described as a series of acts, but it should be understood by those skilled in the art that the present application is not limited by the order of acts described, as some steps may be performed in other orders or concurrently in accordance with the present application. Further, those skilled in the art will also appreciate that the embodiments described in the specification are alternative embodiments, and that the acts and modules referred to are not necessarily required for the present application.
It should be further noted that, although the steps in the flowchart are sequentially shown as indicated by arrows, the steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least a portion of the steps in the flowcharts may include a plurality of sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, the order in which the sub-steps or stages are performed is not necessarily sequential, and may be performed in turn or alternately with at least a portion of the sub-steps or stages of other steps or other steps.
It will be appreciated that the device embodiments described above are merely illustrative and that the device of the application may be implemented in other ways. For example, the division of the units/modules in the above embodiments is merely a logic function division, and there may be another division manner in actual implementation. For example, multiple units, modules, or components may be combined, or may be integrated into another system, or some features may be omitted or not performed.
In addition, each functional unit/module in each embodiment of the present application may be integrated into one unit/module, or each unit/module may exist alone physically, or two or more units/modules may be integrated together, unless otherwise specified. The integrated units/modules described above may be implemented either in hardware or in software program modules.
The integrated units/modules, if implemented in hardware, may be digital circuits, analog circuits, etc. Physical implementations of hardware structures include, but are not limited to, transistors, memristors, and the like. Unless otherwise indicated, the Processor may be any suitable hardware Processor such as a central processing unit (Central Processing Unit, CPU), a graphics Processor (Graphics Processing Unit, GPU), an Application-specific integrated Circuit (ASIC), a digital signal Processor (DIGITAL SIGNAL Processor, DSP), a programmable logic device (Programmable Logic Device, PLD), a field programmable gate array (Field Programmable GATE ARRAY, FPGA), a controller, microcontroller, microprocessor, or other electronic element. Unless specifically stated otherwise, the Memory may be implemented by any type of volatile or non-volatile Memory device or combination thereof, such as a U disk, random-Access Memory (RAM), static Random-Access Memory (SRAM), dynamic Random-Access Memory (DRAM), enhanced Dynamic Random-Access Memory (ENHANCED DYNAMIC Random-Access Memory, EDRAM), electrically erasable programmable Read-Only Memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory, EEPROM), erasable programmable Read-Only Memory (Erasable Programmable Read-Only Memory, EPROM), programmable Read-Only Memory (Programmable Read-Only Memory, PROM), read-Only Memory (ROM), variable Memory (RESISTIVE RANDOM ACCESS MEMORY, RRAM), high Bandwidth Memory HBM (High-Bandwidth Memory hard disk), hybrid Memory cube HMC (Hybrid Memory Cube), magnetic Memory, flash Memory, optical disk, mobile or various other programmable media.
The integrated units/modules may be stored in a computer readable memory if implemented in the form of software program modules and sold or used as a stand-alone product. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in whole or in part in the form of a software product stored in a memory, comprising several instructions for causing a computer device (which may be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method of the various embodiments of the present application.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and for parts of one embodiment that are not described in detail, reference may be made to related descriptions of other embodiments. The technical features of the above embodiments may be combined in any way, and for brevity, all of the possible combinations of the technical features of the above embodiments are not described, but should be considered as the scope of the description
Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the application following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the application pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It is to be understood that the application is not limited to the precise arrangements and instrumentalities shown in the drawings, which have been described above, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (11)

1.一种连接池管理方法,其特征在于,应用于配置设备,所述方法包括:1. A connection pool management method, characterized in that it is applied to a configuration device, the method comprising: 接收客户端发送的针对目标连接池的运行数据,所述目标连接池为目标应用相关的连接池,所述运行数据包括所述目标连接池在预设时间区间内访问服务端的次数,所述服务端用于为所述目标应用提供后台服务;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.根据权利要求1所述的方法,其特征在于,所述连接池参数包括核心线程数;所述基于所述运行数据,对所述目标连接池对应的连接池参数进行调整,以获得调整后的连接池参数,包括:2. The method according to claim 1, wherein 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 running data to obtain the adjusted connection pool parameters comprises: 将所述运行数据与所述预设时间区间对应的区间长度之间的比值,确定为所述目标连接池对应的访问频率,所述访问频率表示所述目标连接池访问所述服务端的频繁程度;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.根据权利要求1所述的方法,其特征在于,所述接收客户端发送的针对目标连接池的运行数据之前,所述方法还包括: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 comprises: 接收所述客户端发送的针对所述目标连接池的初始化请求;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.根据权利要求3所述的方法,其特征在于,确定所述初始连接池参数的过程,包括:4. The method according to claim 3, characterized in that the process of determining the initial connection pool parameters comprises: 接收所述客户端发送的针对所述目标连接池的注册请求,所述注册请求携带所述目标连接池对应的连接池信息;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.根据权利要求4所述的方法,其特征在于,所述连接池信息包括所述服务端的互联网协议IP地址;所述将所述连接池信息存储到所述服务端对应的注册信息组中,包括: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 comprises: 若存在所述IP地址对应的注册信息组,则将所述连接池信息存储到所述IP地址对应的注册信息组中;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; 若不存在所述IP地址对应的注册信息组,则创建与所述IP地址对应的注册信息组,并将所述连接池信息存储到所述注册信息组中。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.根据权利要求4所述的方法,其特征在于,所述预设配置信息包括预设空闲线程存活时间、所述预设空闲线程存活时间对应的预设时间单位、预设线程工厂以及预设拒绝策略;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, 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: 采用预设公式,基于所述服务端对应的最大连接数和所述客户端对应的计算核心数,确定初始核心线程数和初始最大线程数;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.根据权利要求4所述的方法,其特征在于,所述基于所述客户端对应的预设配置信息、所述服务端对应的最大连接数以及所述客户端对应的计算核心数,确定所述目标连接池对应的初始连接池参数之后,所述方法还包括: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 comprises: 若确定所述服务端对应的最大连接数与用户固定连接数之间的差值小于剩余连接池数量的总和,则将所述目标连接池放入等待队列,直至确定所述服务端对应的最大连接数与所述用户固定连接数之间的差值大于或等于剩余连接池数量的总和,重新基于所述客户端对应的预设配置信息、所述服务端对应的最大连接数以及所述客户端对应的计算核心数,确定所述目标连接池对应的初始连接池参数;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.根据权利要求1所述的方法,其特征在于,所述方法还包括: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.一种连接池管理装置,其特征在于,设置在配置设备中,包括:9. A connection pool management device, characterized in that it is set in a configuration device and includes: 接收模块,用于接收客户端发送的针对目标连接池的运行数据,所述目标连接池为目标应用相关的连接池,所述运行数据包括所述目标连接池在预设时间区间内访问服务端的次数,所述服务端用于为所述目标应用提供后台服务;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.一种电子设备,其特征在于,包括:处理器以及分别与所述处理器通信连接的存储器和收发器;10. An electronic device, comprising: a processor, and a memory and a transceiver respectively connected to the processor for communication; 所述存储器存储计算机执行指令;所述收发器用于与客户端或服务端之间收发数据;The memory stores computer-executable instructions; the transceiver is used to send and receive data with a client or a server; 所述处理器执行所述存储器存储的计算机执行指令,以实现如权利要求1至8任一项所述的连接池管理方法。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.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机执行指令,所述计算机执行指令被处理器执行时用于实现如权利要求1至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.
CN202311311017.4A 2023-10-10 2023-10-10 Connection pool management method, device, equipment and storage medium Active CN119814554B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311311017.4A CN119814554B (en) 2023-10-10 2023-10-10 Connection pool management method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311311017.4A CN119814554B (en) 2023-10-10 2023-10-10 Connection pool management method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN119814554A true CN119814554A (en) 2025-04-11
CN119814554B CN119814554B (en) 2025-11-18

Family

ID=95271122

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311311017.4A Active CN119814554B (en) 2023-10-10 2023-10-10 Connection pool management method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN119814554B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120066747A (en) * 2025-04-28 2025-05-30 航天智控(北京)监测技术有限公司 Method for switching data sources based on xxl-job timing task calling springboot service interface

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120311138A1 (en) * 2011-06-03 2012-12-06 Oracle International Corporation System and method for using quality of service with workload management in an application server environment
CN112069237A (en) * 2020-07-22 2020-12-11 北京思特奇信息技术股份有限公司 Management system of cluster database connection pool
CN112181652A (en) * 2020-09-25 2021-01-05 北京天融信网络安全技术有限公司 Method and device for adjusting capacity of connection pool, storage medium and electronic equipment
CN113157410A (en) * 2021-03-30 2021-07-23 北京大米科技有限公司 Thread pool adjusting method and device, storage medium and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120311138A1 (en) * 2011-06-03 2012-12-06 Oracle International Corporation System and method for using quality of service with workload management in an application server environment
CN112069237A (en) * 2020-07-22 2020-12-11 北京思特奇信息技术股份有限公司 Management system of cluster database connection pool
CN112181652A (en) * 2020-09-25 2021-01-05 北京天融信网络安全技术有限公司 Method and device for adjusting capacity of connection pool, storage medium and electronic equipment
CN113157410A (en) * 2021-03-30 2021-07-23 北京大米科技有限公司 Thread pool adjusting method and device, storage medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
安红心;徐玉生;: "动态多连接池实现高效地数据库访问", 微计算机应用, no. 12, 15 December 2010 (2010-12-15) *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120066747A (en) * 2025-04-28 2025-05-30 航天智控(北京)监测技术有限公司 Method for switching data sources based on xxl-job timing task calling springboot service interface
CN120066747B (en) * 2025-04-28 2025-07-04 航天智控(北京)监测技术有限公司 Method for switching data sources when calling springboot service interface based on xxl-job scheduled task

Also Published As

Publication number Publication date
CN119814554B (en) 2025-11-18

Similar Documents

Publication Publication Date Title
CN107800768B (en) Open platform control method and system
CN109995842B (en) A grouping method and device for distributed server cluster
CN108881512B (en) Virtual IP balanced allocation method, device, equipment and medium of CTDB
US11853807B1 (en) Cluster scaling based on task state information
CN108667882B (en) Load balancing method and device based on dynamic weight adjustment and electronic equipment
CN106302640A (en) Data request processing method and device
CN114924888A (en) Resource allocation method, data processing method, apparatus, device and storage medium
CN119814554B (en) Connection pool management method, device, equipment and storage medium
CN114168312A (en) Distributed cluster load balancing method, device and storage medium
CN117971491A (en) In-process resource control method, device, equipment and storage medium
WO2024113847A1 (en) Shared resource allocation method and apparatus, and computing device cluster
CN115190177A (en) Request processing method, apparatus, computer device, storage medium, and program product
CN112506647B (en) Stateful server load balancing method, system, device and storage medium
CN111182011B (en) Service set distribution method and device
CN113157415A (en) Farm rendering method and device, electronic equipment and storage medium
CN115328978B (en) Connection method of connection pool and server
CN119201454A (en) Method, device, equipment and storage medium for selecting computing nodes in resource scheduling
CN111782364A (en) Service invocation method, device, electronic device and storage medium
CN116643874A (en) Middleware optimization method, device, equipment and medium under NUMA architecture
CN112825046A (en) Method and device for adjusting management resources in resource pool
CN115794396A (en) Resource allocation method, system and electronic equipment
CN114390058A (en) Service management system, method, device and storage medium
CN116932182A (en) Resource scheduling method, device, system, server and storage medium
CN116910066B (en) Database-based data warehousing method and system
CN113835875A (en) Load balancing method, apparatus, electronic device and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant