Connection pool management method and related product
By using Bloom filters and hash algorithm-based indexes in the connection pool, the problem of invalid retrieval in the stateful connection pool is solved, and the effect of reducing resource overhead and improving performance is achieved.
Patent Information
- Application Number
- CN202411823359.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-21
AI Technical Summary
With the increase in the number of connection resources in the stateful connection pool, how to quickly retrieve the required connection resources and accurately store the connection tags of user tags has become an urgent problem, resulting in high resource overhead and low performance in the system when the system is invalid for retrieval.
Set up a Bloom filter in the connection pool, map the state-labeled connection tags to the Bloom filter and the hash algorithm-based index, and put them back into the stateful connection area, so that when the client obtains the target connection, it can quickly filter through the Bloom filter to avoid invalid retrieval.
The rapid filtering of the Bloom filter avoids invalid retrieval, reduces system resource overhead, improves system performance, and reduces data migration when the hash ring is expanded, and improves capacity expansion efficiency.
Smart Images

Figure CN119669230A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a connection pool management method, a computer-readable storage medium and a computer program product. Background Art
[0002] Stateful connection pool technology is a resource management solution for databases. Usually, when a user puts a connection resource back into the connection pool, the connection is first marked using multiple key-value pairs with matching priority characteristics, and then put back into the stateful connection pool. When the user uses the connection again, it can be directly obtained from the stateful connection pool. Stateful connection pool technology can efficiently manage and reuse network connection resources to reduce system resource overhead and improve system performance.
[0003] However, as the number of connection resources in the stateful connection pool increases, how to quickly retrieve the required connection resources and accurately store the connection tags marked by the user has become an urgent problem to be solved. In particular, when a user requests to use a stateful connection, but the stateful connection is not stored in the stateful connection pool, the system will consume a lot of performance for invalid retrieval, which greatly increases the system's resource overhead and reduces system performance. Summary of the invention
[0004] An object of the present invention is to provide a connection pool management method, a computer-readable storage medium and a computer program product, so as to avoid or reduce invalid retrieval by a database system, thereby reducing the resource overhead of the system and improving the performance of the system.
[0005] A further object of the present invention is to reduce the amount of data migrated by the hash algorithm-based index of the connection pool when the capacity is expanded, thereby reducing the resource overhead of the system and improving the performance of the system.
[0006] Specifically, according to one aspect of the present invention, the present invention provides a method for managing a connection pool.
[0007] It includes:
[0008] In response to a client request, the out-of-pool connection is put back into the connection pool, and it is determined whether the connection tag of the out-of-pool connection has a stateful mark; the stateful mark is used to mark the connection characteristics of the out-of-pool connection and attach a connection priority;
[0009] If so, mapping the connection tag of the out-of-pool connection to a Bloom filter, and mapping the connection tag of the out-of-pool connection to an index based on a hash algorithm; and
[0010] Put the out-of-pool connection back into the stateful connection area of the connection pool.
[0011] Optionally, after putting the out-of-pool connection back into the stateful connection area of the connection pool, the management method further includes:
[0012] In response to a client request, obtaining a target connection from the connection pool, and determining whether a connection tag of the target connection carries the stateful mark;
[0013] If the stateful mark is present, the connection label of the target connection is analyzed through the Bloom filter;
[0014] In response to the connection tag of the target connection not being hit by the Bloom filter, acquiring the target connection from the stateless connection area of the connection pool.
[0015] Optionally, after inputting the connection tag of the target connection into the Bloom filter for analysis, the management method further includes:
[0016] In response to the connection tag of the target connection being hit by the Bloom filter, obtaining a unique identifier of the storage unit where the target connection is located through the index based on the hash algorithm;
[0017] The target connection is acquired from the connection pool according to the connection tag of the target connection and the unique identifier.
[0018] Optionally, acquiring the target connection from the connection pool according to the connection tag of the target connection and the unique identifier includes:
[0019] Determining whether the unique identifier is legal;
[0020] If legal, acquiring the target connection from the stateful connection area of the connection pool according to the connection tag of the target connection and the unique identifier;
[0021] If it is illegal, the target connection is obtained from the stateless connection area of the connection pool.
[0022] Optionally, mapping the connection label of the out-of-pool connection to an index based on a hash algorithm includes:
[0023] Generate a hash ring according to the consistent hashing algorithm;
[0024] The connection labels of the out-of-pool connections are mapped onto the hash ring.
[0025] Optionally, mapping the connection label of the out-of-pool connection to the hash ring includes:
[0026] Determine whether the hash ring has sufficient space;
[0027] If there is enough space, the connection label of the out-of-pool connection is directly mapped to the hash ring;
[0028] If there is not enough space, the hash ring is expanded and data is migrated first, and then the process returns to execute the step of determining whether the hash ring has enough space.
[0029] Optionally, if there is enough space, directly mapping the connection label of the out-of-pool connection to the hash ring includes:
[0030] Obtaining a preset node threshold of the hash ring;
[0031] In response to the hash ring having reached the preset node threshold, mapping the connection label of the out-of-pool connection to the start node of the hash ring.
[0032] Optionally, after returning the out-of-pool connection to the connection pool in response to the client request and determining whether the connection tag of the out-of-pool connection carries a stateful mark, the management method further comprises:
[0033] If the out-of-pool connection does not have the stateful mark, the out-of-pool connection is placed back into the stateless connection area of the connection pool; and
[0034] Responding to a client request, obtaining a target connection from the connection pool, and determining whether the target connection carries the stateful mark;
[0035] If the target connection does not carry the stateful mark, the target connection is obtained from the stateless connection area of the connection pool.
[0036] According to another aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of any of the above connection pool management methods are implemented.
[0037] According to yet another aspect of the present invention, a computer program product is provided, which includes a computer program, and when the computer program is executed by a processor, the steps of any one of the above connection pool management methods are implemented.
[0038] The connection pool management method of the present invention sets a Bloom filter in the connection pool, maps the connection tag with a state mark of the out-of-pool connection to be put back to the Bloom filter, and then puts it back into the stateful connection area of the connection pool, so that the connection tag with the state mark corresponds to the connection in the stateful connection pool. In this way, when the client obtains a certain target connection, if the Bloom filter does not hit the connection tag of the target connection, it indicates that the target connection is not stored in the stateful connection pool, thereby avoiding or reducing the database system from performing invalid searches in the stateful connection pool, achieving the effect of reducing the resource overhead of the system and improving the performance of the system.
[0039] Furthermore, the management method of the present invention reduces the amount of migrated data and improves expansion efficiency by mapping the connection label to the hash ring when the hash ring is expanded and data is migrated, thereby achieving the effect of reducing system resource overhead and improving system performance.
[0040] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:
[0042] Figure 1 is a flow chart of a management method according to an embodiment of the present invention;
[0043] Figure 2 is a schematic diagram of a process of obtaining a target connection according to a management method of an embodiment of the present invention;
[0044] Figure 3 is a schematic diagram of a process of obtaining a target connection according to a management method of an embodiment of the present invention;
[0045] Figure 4 is a schematic diagram of a process of obtaining a target connection according to a management method of an embodiment of the present invention;
[0046] Figure 5 It is a schematic diagram of a process of mapping an out-of-pool connection to a hash ring according to a management method of an embodiment of the present invention;
[0047] Figure 6 It is a schematic diagram of a process of mapping an out-of-pool connection to a hash ring according to a management method of an embodiment of the present invention;
[0048] Figure 7is a schematic diagram of a process of placing and acquiring a stateless connection according to a management method according to an embodiment of the present invention;
[0049] Figure 8 is a schematic diagram of a flow chart of obtaining a connection according to a management method of an embodiment of the present invention;
[0050] Fig. 9 is a schematic diagram of a process of placing back a connection according to a management method according to an embodiment of the present invention;
[0051] Fig.10 is a schematic block diagram of a connection pool of a management method according to an embodiment of the present invention;
[0052] Fig.11 is a schematic block diagram of a hash ring of a management method according to an embodiment of the present invention;
[0053] Fig.12 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; and
[0054] Fig.13 is a schematic diagram of a computer program product according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] The purpose of the connection pool management method of this embodiment is to avoid or reduce invalid searches performed by the database system, thereby reducing the resource overhead of the system and improving the performance of the system.
[0056] Figure 1 FIG. 1 is a flow chart of a management method according to an embodiment of the present invention. The method may generally include:
[0057] S100, in response to a client request, putting the out-of-pool connection back into the connection pool, and determining whether the connection tag of the out-of-pool connection carries a stateful mark; the stateful mark is used to identify the connection characteristics of the out-of-pool connection and attach a connection priority;
[0058] S200, if yes, map the connection label of the out-of-pool connection into the Bloom filter;
[0059] S300, mapping the connection label of the connection outside the pool to an index based on a hash algorithm; and
[0060] S400: Put the out-of-pool connection back into the stateful connection area of the connection pool.
[0061] Stateful connection pool is a technology for creating and managing a buffer pool of stateful connections. Each stateful connection may contain state information, priority information, etc. related to a specific user or session. These stateful connections are ready to be used by any thread that needs them. In high-concurrency scenarios, the client can obtain an available stateful connection from the connection pool (for example, getConnection), and return the stateful connection to the connection pool (for example, releaseConnection) after use. This eliminates the need to repeatedly execute the connection building process with the server, improving overall performance. Compared with stateless connections, stateful connections need to maintain connection status information, so they have higher requirements for system performance. When retrieving stateful connections through an index based on a hash algorithm, more performance resources will also be occupied. In particular, when a user requests to use a stateful connection, but the connection is not stored in the stateful connection pool, the system will traverse the entire stateful connection pool, consuming a lot of performance, greatly increasing the system's resource overhead and reducing system performance.
[0062] In this embodiment, when a connection is outside the connection pool, it can be called an out-of-pool connection. The stateful tag is used to mark the connection characteristics of the out-of-pool connection and attach the priority of the connection. Exemplarily, the stateful tag is a plurality of key-value pairs with matching priority characteristics, which can mark user identity, context information and other information, so that the connection becomes a stateful connection. The priority is used to mark the importance of the connection. For connections with higher priorities, they will be processed preferentially according to preset rules when they are put back into the connection pool or obtained from the connection pool.
[0063] In this embodiment, a Bloom filter is set on the connection pool, so as to improve the efficiency of retrieval. Specifically, when the client requests to put the out-of-pool connection back into the connection pool, the connection tag of the out-of-pool connection is mapped to the bitmap of the Bloom filter, so that the stateful marked connection tag corresponds to the connection in the stateful connection pool. In this way, when the client requests to obtain a stateful target connection, the system does not immediately search the connection tag through the index based on the hash algorithm, but first runs the Bloom filter to analyze the connection tag. The Bloom filter can quickly determine whether the corresponding connection tag is hit with an efficiency of time complexity of O(1). When the Bloom filter does not hit the corresponding connection tag, it indicates that the stateful target connection corresponding to the connection tag is not stored in the stateful connection area of the connection pool, and there is no need to perform the next step of retrieval.
[0064] The hash algorithm-based index is an index based on a hash function, which can be a hash index, a consistent hash algorithm, etc. It is used to establish an index between the connection tag of the connection and the storage location of the connection in the connection pool, so as to quickly find the connection according to the connection tag. For example, Fig.10 As shown, the connection pool has at least one stateful connection area, and multiple storage units are set in each stateful connection area to store stateful connections. Each storage unit has a unique identifier (id0, id1...idn shown in the figure). The index based on the hash algorithm can establish an index between the connection and the id.
[0065] In this embodiment, the Bloom filter does not miss any requests, and can accurately avoid or reduce invalid searches, and filter out invalid stateful connection requests in advance, thereby avoiding or reducing the database system's invalid searches in the stateful connection pool, thereby reducing the system's resource overhead and improving the system's performance.
[0066] In some embodiments of the management methods of the present invention, Figure 2 As shown, after putting the out-of-pool connection back into the stateful connection area of the connection pool, the management method further includes:
[0067] S511, in response to a client request, obtaining a target connection from a connection pool, and determining whether a connection tag of the target connection carries a stateful mark;
[0068] S513, if there is a stateful mark, the connection label of the target connection is analyzed through a Bloom filter;
[0069] S515 : In response to the connection tag of the target connection not being hit by the Bloom filter, acquiring the target connection from the stateless connection area of the connection pool.
[0070] In this embodiment, when the client requests to obtain the target connection from the connection pool, it is first determined whether the target connection requested is a stateful connection or a stateless connection. If the connection tag of the target connection carries a stateful mark, indicating that a stateful connection is to be obtained, it is necessary to retrieve the corresponding connection from the stateful connection area of the connection pool through an index based on a hash algorithm. The target connection requested to be obtained is not necessarily stored in the stateful connection area of the connection pool (for example, it has been cleared, etc.). At this time, if an index search based on a hash algorithm is performed directly, the stateful connection area of the connection pool will be traversed but no results will be obtained. On the one hand, invalid retrieval time is long, affecting the user experience. On the other hand, invalid retrieval will generate a large system resource overhead and occupy a large amount of system performance.
[0071] In this embodiment, since the stateful connections in the stateful connection area of the connection pool correspond to the connection labels mapped to the Bloom filter, invalid stateful connection requests can be filtered out in advance by running the Bloom filter. The Bloom filter does not miss any judgments, and can accurately avoid or reduce invalid searches, thereby avoiding or reducing invalid searches performed by the database system in the stateful connection pool, thereby reducing the resource overhead of the system and improving the performance of the system.
[0072] In some embodiments of the management methods of the present invention, Figure 3 As shown, after the connection tag of the target connection is input into the Bloom filter for analysis, the management method further includes:
[0073] S531, in response to the connection tag of the target connection being hit by the Bloom filter, obtaining a unique identifier of the storage unit where the target connection is located through an index based on a hash algorithm;
[0074] S533: Acquire the target connection from the connection pool according to the connection tag and the unique identifier of the target connection.
[0075] The unique identifier can be the ID of the storage unit of the connection pool. The unique identifiers corresponding to each stateful connection of the connection pool can be mapped to an index based on a hash algorithm. The unique identifier of the target connection can be retrieved through the connection tag. When the connection tag of the target connection requested by the client is hit by the Bloom filter, it is highly likely that the target connection is stored in the stateful connection area of the connection pool. At this time, the unique identifier of the storage unit of the connection pool where the target connection is located can be accurately obtained through the index based on the hash algorithm, and then the target connection can be obtained from the storage unit.
[0076] It should be noted that there is no missed judgment in the Bloom filter, but there may be misjudgment. Under a small probability, the target connection that is not stored in the stateful connection area of the connection pool will be analyzed as a hit. In the case of misjudgment, invalid retrieval may still occur. However, on the one hand, misjudgment is a low-probability event. On the other hand, the hit accuracy can be further improved and the misjudgment rate can be reduced by setting relevant parameters. Specifically, the parameters related to the Bloom filter can be designed according to the following Bloom filter misjudgment rate formula to achieve a more ideal and stable state.
[0077]
[0078] In the above formula, ε represents the false positive rate, k represents the number of hash functions, n represents the number of elements inserted, and m represents the total number of bits of the Bloom filter. By adjusting parameters such as k, n, and m, the false positive rate can be set to the required threshold, thereby reducing the probability of invalid retrieval caused by false positives of the Bloom filter to an acceptable level.
[0079] In some embodiments of the management methods of the present invention, Figure 4 As shown, the step of obtaining the target connection from the connection pool according to the connection tag and the unique identifier of the target connection includes:
[0080] S551, determining whether the unique identifier is legal;
[0081] S553, if legal, obtain the target connection from the stateful connection area of the connection pool according to the connection tag and unique identifier of the target connection;
[0082] S555: If it is illegal, obtain the target connection from the stateless connection area of the connection pool.
[0083] After obtaining the unique identifier corresponding to the connection through the hash algorithm-based index, it is usually necessary to determine whether the unique identifier is legal. If it is legal, it means that it is stored in the stateful connection area of the connection pool and can be directly obtained from the corresponding storage location. If it is illegal, it does not mean that it is not stored in the stateful connection area of the connection pool and can be obtained from the stateless connection area of the connection pool.
[0084] In some embodiments of the management methods of the present invention, Figure 5 As shown, the mapping of the connection label of the out-of-pool connection to the index based on the hash algorithm includes:
[0085] S311, generating a hash ring according to a consistent hashing algorithm;
[0086] S313, mapping the connection label of the out-of-pool connection to the hash ring.
[0087] In the related art, hash index is usually used for retrieval. For example, the connection tag and unique identifier of the connection resource are mapped into the hash table through the hash function to achieve fast search. However, when the hash index faces a large number of connection resources, the retrieval efficiency may decrease due to hash conflicts, and the amount of data migration caused by resolving hash conflicts is also huge, often more than half of the migration amount.
[0088] In this embodiment, retrieval is performed through a consistent hashing algorithm. The consistent hashing algorithm organizes the entire hash value space into a virtual ring, maps both nodes and data to this ring, and determines which node the data should be stored on by comparing hash values. Common hash spaces are 0 to 2^32-1. The end of the hash ring is connected to form a closed loop. On the one hand, the hash ring can easily map the connection label to the hash ring, and the node to which the mapping position belongs is the storage unit corresponding to the unique identifier of the connection. In other words, the hash ring can easily support stateful connections. On the other hand, the hash ring can be easily expanded, and the amount of data migrated during expansion is much less than the hash index. Exemplarily, when a new storage node is added to the hash ring, it will only affect the data between the first node to the new node in the clockwise direction on the ring. These data need to be redistributed to the new node, while other data remain unchanged.
[0089] For example, Fig.11As shown in the figure, 0, 1, 2...MAX-1 illustrate the nodes (or hash space values) corresponding to the hash ring, and each node corresponds to a unique identifier (id) of one or more storage units, where MAX-1 can be 2^32-1. The hash ring can establish an index between the connection and the id. Generally speaking, in a clockwise direction, the data between the starting node (excluding the starting node itself, the starting node is also called the 0 node or the 0 value space) and the 1 node corresponds to the storage unit on the 1 node. When a new node is added between the starting node and the 1 node, it will only affect the data on the 1 node, and will not affect the data of other nodes.
[0090] In this embodiment, the inventors have keenly discovered that the consistent hashing algorithm is more suitable for distributed databases, especially in stateful connection pool scenarios that need to handle dynamic node changes. It ensures that data is evenly distributed among nodes, and only a small amount of data needs to be redistributed when nodes are added or reduced, thereby maintaining the stability and efficiency of the system.
[0091] In some embodiments of the management methods of the present invention, Figure 5 As shown, the mapping of the connection label of the out-of-pool connection to the hash ring includes:
[0092] S331, determining whether the hash ring has sufficient space;
[0093] S333, if there is enough space, directly map the connection label of the connection outside the pool to the hash ring;
[0094] S335, if there is not enough space, the hash ring is expanded and data is migrated first, and then the process returns to execute the step of determining whether the hash ring has enough space.
[0095] The hash ring presets a load factor threshold (for example, 75%). When the load factor is less than the threshold, it indicates that the hash ring (corresponding to each storage unit of the connection pool) has enough space and the connection label can be directly mapped to the hash ring. When the load factor exceeds the threshold, it indicates that the hash ring needs to be expanded in time. At this time, the hash ring can be expanded. Specifically, the data between the first node and the new node can be migrated to the new node (clockwise), while the data of other nodes remains unchanged. In actual use, the range of the preset load factor threshold can be set according to business needs.
[0096] In some embodiments of the management methods of the present invention, Figure 6 As shown, if there is enough space, the connection label of the connection outside the pool is directly mapped to the hash ring, including:
[0097] S351, obtaining a preset node threshold of the hash ring;
[0098] S353: In response to the hash ring having reached a preset node threshold, mapping a connection label of the out-of-pool connection to a start node of the hash ring.
[0099] The hash ring can preset a certain value as the preset node threshold, and then the connection label mapping that exceeds the preset node threshold is stored on the starting node. In this way, when the capacity is expanded beyond the preset load factor threshold, only the data on the starting node needs to be migrated, and the data on other nodes remains unchanged, which can efficiently expand the capacity and migrate data.
[0100] It is important to understand that since the connection label mappings that exceed the preset node threshold are stored on the starting node, the data will be tilted to the starting node before expansion, but as the maximum number of nodes is reached, the degree of data tilt gradually converges, and the final limit tends to 0, which means that the system will be a stable system. This is of great significance for long-running stateful connection pools to maintain a long-term stable system. In actual use, the range of the preset node threshold can be set according to business needs.
[0101] In some embodiments of the management methods of the present invention, Figure 7 As shown, after putting the out-of-pool connection back into the connection pool in response to the client request and determining whether the connection tag of the out-of-pool connection has a stateful mark, the management method further includes:
[0102] S611, if the out-of-pool connection does not have a stateful mark, the out-of-pool connection is placed back into the stateless connection area of the connection pool; and
[0103] S613, in response to the client request, obtaining a target connection from the connection pool, and determining whether the target connection has a stateful mark;
[0104] S615: If there is no stateful mark, obtain the target connection from the stateless connection area of the connection pool.
[0105] The target connection without a stateful mark must not be stored in the stateful connection area of the connection pool, or the target connection that is not hit by the Bloom filter must not be stored in the stateful connection area of the connection pool. According to the relevant rules of the current connection pool, for connections without a stateful mark, the stateless connection area of the connection pool will give a stateless connection. For example, Fig.10 As shown, the connection pool has at least one stateless connection area, and a plurality of storage units are arranged in each stateless connection area to store stateless connections.
[0106] In some embodiments of the management methods of the present invention, Figure 8 As shown, management methods include:
[0107] S711, the client requests to obtain a connection;
[0108] S712, determine whether there is a connection in the connection pool; if so, execute S713; if not, execute S751;
[0109] S713, determine whether to obtain a stateful connection; if so, execute S714; if not, execute S731;
[0110] S714, determine whether the Bloom filter hits; if so, execute S715; if not, execute S731;
[0111] S715, retrieving a unique identifier from the hash ring according to the priority of the stateful mark;
[0112] S716, determine whether the unique identifier is legal; if so, execute S717; if not, execute S731;
[0113] S717, obtaining a connection from the stateful connection area of the connection pool;
[0114] S718, determine whether the stateful connection is idle and available; if so, execute S719; if not, execute S731;
[0115] S719, the client obtains a stateful connection;
[0116] S731, obtaining a connection from the stateless connection area of the connection pool;
[0117] S732, determine whether the stateless connection is idle and available; if so, execute S733; if not, execute S751;
[0118] S733, the client obtains a stateless connection;
[0119] S751, creating a new stateless connection in the stateless connection area of the connection pool;
[0120] S752: The client obtains the newly created stateless connection.
[0121] In this embodiment, when the unique identifier of the connection to be obtained is retrieved from the hash ring, it will be processed according to the priority of the connection. Exemplarily, when the client requests to obtain multiple stateful connections, the system will give priority to the connection with a higher priority. Through the above steps, the client can be efficiently provided with the connection it needs to meet the user's needs.
[0122] In some embodiments of the management methods of the present invention, Fig. 9 As shown, management methods include:
[0123] S811, the client requests to release the connection;
[0124] S812, determine whether the connection has a stateful mark; if so, execute S813; if not, execute S851;
[0125] S813, mapping the connection label to the Bloom filter;
[0126] S814, determine whether the hash ring needs to be expanded; if so, execute S831; if not, execute S815;
[0127] S815, mapping the connection label into the hash ring;
[0128] S816, put the connection back into the stateful connection area of the connection pool;
[0129] S831, expand the capacity of the hash ring and migrate data; return to execute S814;
[0130] S851, put the connection back into the stateless connection area of the connection pool.
[0131] Through the above steps, the connection provided by the client can be efficiently put back into the connection pool for next use.
[0132] The flow chart provided by the present embodiment is not intended to indicate that the operation of the method will be performed in any particular order, or that all operations of the method are included in all every case. In addition, the method may include additional operations. Within the scope of the technical thinking provided by the present embodiment method, additional changes may be made to the above method.
[0133] It should be understood that in some embodiments, each part can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.
[0134] This embodiment also provides a computer program product 10 and a computer readable storage medium 20 . Fig.13 is a schematic diagram of a computer program product 10 according to an embodiment of the present invention, Fig.12 is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention. The computer program product 10 includes a computer program 11, which implements the steps of any of the above-mentioned management methods when the computer program 11 is executed by the processor 32. The computer-readable storage medium 20 stores the above-mentioned computer program 11 thereon, and the computer program 11 implements the steps of the management method of any of the above-mentioned embodiments when the computer program 11 is executed by the processor 32.
[0135] The computer program 11 for performing the operation of the present invention may be an assembly instruction, an instruction set architecture (ISA) instruction, a machine instruction, a machine-related instruction, a microcode, a firmware instruction, a state setting data, a configuration data of an integrated circuit, or a source code or an object code written in any combination of one or more programming languages and process programming languages. The computer program 11 may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider via the Internet). In some embodiments, in order to perform various aspects of the present invention, an electronic circuit including, for example, a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA) may execute computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit.
[0136] In the description of this embodiment, the computer program product 10 is a related product including the computer program 11 .
[0137] For the purpose of the description of the present embodiment, the computer readable storage medium 20 is a tangible device capable of retaining and storing the computer program 11, which can be any device that can contain, store, communicate, propagate or transmit the computer program 11 for use with an instruction execution system, device or apparatus or in conjunction with these instruction execution systems, devices or apparatuses. More specific examples (a non-exhaustive list) of the computer readable storage medium 20 include the following: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, and any suitable combination of the above.
[0138] The computer program product 10 can be run on a computer device. The computer device may include a memory, a processor 32, and a computer program 11 stored in the memory and running on the processor 32. The computer device may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, the computer device may be a cloud computing node. The computer device may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module may include routines, programs, target programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device may be implemented in a distributed cloud computing environment where remote processing devices linked through a communication network perform tasks. In a distributed cloud computing environment, program modules may be located on a local or remote computing system storage medium including a storage device.
[0139] The computer device may include a processor 32 adapted to execute stored instructions, and a memory that provides temporary storage space for the operation of the instructions during operation. The processor 32 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.
[0140] The computer device may also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows input and output of data with external devices that may be connected to the computer device. The network adapter / interface may provide communication between the computer device and a network, which is usually shown as a communication network.
[0141] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.
Claims
1. A method for managing a connection pool, characterized in that: include: In response to a client request, the out-of-pool connection is put back into the connection pool, and it is determined whether the connection tag of the out-of-pool connection has a stateful mark; the stateful mark is used to mark the connection characteristics of the out-of-pool connection and attach a connection priority; If yes, mapping the connection label of the out-of-pool connection to a Bloom filter, and mapping the connection label of the out-of-pool connection to an index based on a hash algorithm; as well as Put the out-of-pool connection back into the stateful connection area of the connection pool.
2. The management method according to claim 1, characterized in that: After putting the out-of-pool connection back into the stateful connection area of the connection pool, the management method further includes: In response to a client request, obtaining a target connection from the connection pool, and determining whether a connection tag of the target connection carries the stateful mark; If the stateful mark is present, the connection label of the target connection is analyzed through the Bloom filter; In response to the connection tag of the target connection not being hit by the Bloom filter, acquiring the target connection from the stateless connection area of the connection pool.
3. The management method according to claim 2, characterized in that: After inputting the connection tag of the target connection into the Bloom filter for analysis, the management method further includes: In response to the connection tag of the target connection being hit by the Bloom filter, obtaining a unique identifier of the storage unit where the target connection is located through the index based on the hash algorithm; The target connection is acquired from the connection pool according to the connection tag of the target connection and the unique identifier.
4. The management method according to claim 3, characterized in that: The step of acquiring the target connection from the connection pool according to the connection tag of the target connection and the unique identifier includes: Determining whether the unique identifier is legal; If legal, acquiring the target connection from the stateful connection area of the connection pool according to the connection tag of the target connection and the unique identifier; If it is illegal, the target connection is obtained from the stateless connection area of the connection pool.
5. The management method according to claim 1, characterized in that: The mapping of the connection label of the out-of-pool connection to an index based on a hash algorithm includes: Generate a hash ring according to the consistent hashing algorithm; The connection label of the out-of-pool connection is mapped to the hash ring.
6. The management method according to claim 5, characterized in that: The mapping of the connection label of the out-of-pool connection to the hash ring includes: Determine whether the hash ring has sufficient space; If there is enough space, the connection label of the out-of-pool connection is directly mapped to the hash ring; If there is not enough space, the hash ring is expanded and data is migrated first, and then the process returns to execute the step of determining whether the hash ring has enough space.
7. The management method according to claim 6, characterized in that: If there is enough space, directly mapping the connection label of the out-of-pool connection to the hash ring includes: Obtaining a preset node threshold of the hash ring; In response to the hash ring having reached the preset node threshold, mapping the connection label of the out-of-pool connection to the start node of the hash ring.
8. The management method according to claim 1, characterized in that: After placing the out-of-pool connection back into the connection pool in response to the client request and determining whether the connection tag of the out-of-pool connection carries a stateful mark, the management method further comprises: If the out-of-pool connection does not have the stateful mark, the out-of-pool connection is placed back into the stateless connection area of the connection pool; and Responding to a client request, obtaining a target connection from the connection pool, and determining whether the target connection carries the stateful mark; If the target connection does not carry the stateful mark, the target connection is obtained from the stateless connection area of the connection pool.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the connection pool management method according to any one of claims 1 to 8 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the connection pool management method according to any one of claims 1 to 8 are implemented.