Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
SYSTEM AND METHOD FOR EFFICIENT REPURPOSING OF CONNECTIONS IN A MULTI-TENANT DATABASE ENVIRONMENT
Document Type and Number:
WIPO Patent Application WO/2018/027028
Kind Code:
A1
Abstract:
Described herein are systems and methods for providing access to a database in a multi-tenant environment, including the use of a connection pool, with support for efficient repurposing of connections. In accordance with an embodiment, a software application can request that a connection be provided, to enable access to the database. In response to receiving the request, the connection pool can first determine if a particular connection with the exact desired attributes already exists within the pool, but is borrowed at the time of the request. If such a connection exists, then the connection pool can wait a period of time for that particular connection to become available, referred to herein as a double-wait. Subsequently, if the particular connection is not made available within the double-wait time period, the connection pool resumes its usual operation, for example by repurposing other connections.

Inventors:
DE LAVARENE JEAN (FR)
DOLGOV YURI (US)
HEGDE VIDYA (IN)
VERMA SAURABH (IN)
MAHIDHARA CHANDRA SEKHAR KRISHNA (IN)
NAMACHIVAYAM ARAMVALARTHANATHAN (IN)
Application Number:
PCT/US2017/045288
Publication Date:
February 08, 2018
Filing Date:
August 03, 2017
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
ORACLE INT CORP (US)
International Classes:
G06F9/50
Foreign References:
US8145759B22012-03-27
Other References:
ORACLE: "Oracle Fusion Middleware - Configuring and Managing JDBC Data Sources for Oracle WebLogic Server 11g Release 1 (10.3.5)", 1 April 2011 (2011-04-01), pages 1 - 148, XP055075185, Retrieved from the Internet [retrieved on 20130814]
ORACLE: "Oracle Universal Connection Pool for JDBC - Developer's Guide 11g Release 2 (11.2)", 1 September 2009 (2009-09-01), pages 1 - 74, XP055075255, Retrieved from the Internet [retrieved on 20130814]
"Network and Parallel Computing", vol. 8904, 1 January 2015, SPRINGER INTERNATIONAL PUBLISHING, Cham, ISBN: 978-3-642-27168-7, ISSN: 0302-9743, article NICOLAS MICHAEL ET AL: "Downtime-Free Live Migration in a Multitenant Database", pages: 130 - 155, XP055417846, 032548, DOI: 10.1007/978-3-319-15350-6_9
None
Attorney, Agent or Firm:
MEYER, Sheldon, R. et al. (US)
Download PDF:
Claims:
Claims:

What is claimed is: 1. A system for providing access to a database, including support for efficient repurposing of connections, comprising:

a computer including a processor, and at least one of an application server or database environment executing thereon;

a connection pool that enables software applications to request a connection from the connection pool, and use a provided connection to access a database; and

wherein the system enables repurposing of connections in the connection pool, including, in response to receiving a request,

determining if the connection pool includes a particular connection having desired attributes that is borrowed at the time of the request; and

If such a connection exists, waiting a time period for the particular connection to become available, prior to repurposing another connection.

2. The system of Claim 1 , wherein if the particular connection is not made available within the time period, the connection pool resumes usual operation, including determining whether to repurpose other connections.

3. The system according to Claim 1 or 2, wherein the connection pool can be polled using different modes, including a single-wait mode, and a double-wait mode. 4. The system according to any preceding Claim, wherein the connection pool supports an auto-tuning process that determines a value for the time period.

5. The system according to any preceding Claim, wherein software applications are enabled to associate particular labels with particular connection states.

6. The system according to any preceding Claim, wherein each software application is associated with one or more tenants.

7. A method for providing access to a database, including support for efficient repurposing of connections, comprising:

providing, at a computer including a processor, at least one of an application server or database environment executing thereon, a connection pool that includes connection objects and that enables software applications to request a connection from the connection pool, and use a provided connection to access a database; and

enabling repurposing of connections in the connection pool, including, in response to receiving a request,

determining if the connection pool includes a particular connection having desired attributes that is borrowed at the time of the request; and

If such a connection exists, waiting a time period for the particular connection to become available, prior to repurposing another connection. 8. The method of Claim 7, wherein if the particular connection is not made available within the time period, the connection pool resumes usual operation, including determining whether to repurpose other connections.

9. The method according to Claim 7 or 8, wherein the connection pool can be polled using different modes, including a single-wait mode, and a double-wait mode.

10. The method according to any of Claims 7 to 9, wherein the connection pool supports an auto-tuning process that determines a value for the time period. 11. The method according to any of Claims 7 to 10, wherein software applications are enabled to associate particular labels with particular connection states.

12. The method according to any of Claims 7 to 11 , wherein each software application is associated with one or more tenants.

13. A non-transitory computer readable storage medium, including instructions stored thereon which when read and executed by one or more computers cause the one or more computers to perform the method comprising:

providing, at a computer including a processor, at least one of an application server or database environment executing thereon, a connection pool that includes connection objects and that enables software applications to request a connection from the connection pool, and use a provided connection to access a database; and

enabling repurposing of connections in the connection pool, including, in response to receiving a request,

determining if the connection pool includes a particular connection having desired attributes that is borrowed at the time of the request; and

If such a connection exists, waiting a time period for the particular connection to become available, prior to repurposing another connection.

14. The non-transitory computer readable storage medium of Claim 13, wherein if the particular connection is not made available within the time period, the connection pool resumes usual operation, including determining whether to repurpose other connections.

15. The non-transitory computer readable storage medium according to Claim 13 or 14, wherein the connection pool can be polled using different modes, including a single-wait mode, and a double-wait mode.

16. The non-transitory computer readable storage medium according to any of Claims 13 to 15, wherein the connection pool supports an auto-tuning process that determines a value for the time period. 17. The non-transitory computer readable storage medium according to any of Claims 13 to 16, wherein software applications are enabled to associate particular labels with particular connection states.

18. The non-transitory computer readable storage medium according to any of Claims 13 to 17, wherein each software application is associated with one or more tenants.

19. A computer program comprising program instructions in machine-readable format that when executed by a computer system cause the computer system to perform the method of any of Claims 7 to 12.

20. A computer program product comprising the computer program of Claim 19 stored in a non-transitory machine readable data storage medium.

21. An apparatus comprising means for performing the method of any of Claims 7 to 12.

Description:
SYSTEM AND METHOD FOR EFFICIENT REPURPOSING OF CONNECTIONS

IN A MULTI-TENANT DATABASE ENVIRONMENT

COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever.

Claim of Priority:

[0001] This application claims the benefit of priority to U.S. Patent Application titled

"SYSTEM AND METHOD FOR EFFICIENT REPURPOSING OF CONNECTIONS IN A MULTI-TENANT DATABASE ENVIRONMENT", Application No. 15/227,899 filed August 3, 2016, which application is herein incorporated by reference.

Field of Invention:

[0002] Embodiments of the invention are generally related to software application servers and databases, and are particularly related to systems and methods for providing access to a database in a multi-tenant environment, including the use of a connection pool, with support for efficient repurposing of connections.

Background:

[0003] Generally described, in a database environment, a connection pool operates as a cache of connection objects, each of which represents a connection that can be used by a software application to connect to a database. At runtime, an application can request a connection from the connection pool. If the connection pool includes a connection that can satisfy the particular request, it can return that connection to the application for its use. In some instances, if no suitable connection is found, then a new connection can be created and returned to the application. The application can borrow the connection to access the database and perform some work, and then return the connection to the pool, where it can then be made available for subsequent connection requests from the same, or from other, applications. Summary:

[0004] Described herein are systems and methods for providing access to a database in a multi-tenant environment, including the use of a connection pool, with support for efficient repurposing of connections. In accordance with an embodiment, a software application can request that a connection be provided, to enable access to the database. In response to receiving the request, the connection pool can first determine if a particular connection with the exact desired attributes already exists within the pool, but is borrowed at the time of the request. If such a connection exists, then the connection pool can wait a period of time for that particular connection to become available, referred to herein as a double-wait. Subsequently, if the particular connection is not made available within the double-wait time period, the connection pool resumes its usual operation, for example by repurposing other connections. Brief Description of the Figures:

[0005] Figure 1 illustrates a system that includes a connection pool, in accordance with an embodiment.

[0006] Figure 2 further illustrates a system that includes a connection pool, including support for use of a sharded database, in accordance with an embodiment.

[0007] Figure 3 further illustrates a system that includes a connection pool, including support for use in a multi-tenant environment, in accordance with an embodiment.

[0008] Figure 4 illustrates support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[0009] Figure 5 further illustrates support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[0010] Figure 6 further illustrates support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[0011] Figure 7 further illustrates support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[0012] Figure 8 further illustrates support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[0013] Figure 9 further illustrates support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[0014] Figure 10 illustrates a method of providing support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

Detailed Description:

[0015] As described above, a connection pool operates as a cache of connection objects, each of which represents a connection that can be used by a software application to connect to a database. At runtime, an application can request a connection from the connection pool. If the connection pool includes a connection that can satisfy the particular request, it can return that connection to the application for its use. In some instances, if no suitable connection is found, then a new connection can be created and returned to the application. The application can borrow the connection to access the database and perform some work, and then return the connection to the pool, where it can then be made available for subsequent connection requests from the same, or from other, applications.

[0016] Creating connection objects can be costly in terms of time and resources. For example, tasks such as network communication, authentication, transaction enlistment, and memory allocation, all contribute to the amount of time and resources it takes to create a particular connection object. Since connection pools allow the reuse of such connection objects, they help reduce the number of times that the various objects must be created.

[0017] One example of a connection pool is Oracle Universal Connection Pool (UCP), which provides a connection pool for caching Java Database Connectivity (JDBC) connections. For example, the connection pool can operate with a JDBC driver to create connections to a database, which are then maintained by the pool; and can be configured with properties that are used to further optimize pool behavior, based on the performance and availability requirements of a requesting software application.

Connection Labeling

[0018] Figure 1 illustrates a system that includes a connection pool, in accordance with an embodiment.

[0019] As illustrated in Figure 1 , in accordance with an embodiment, an application server or database environment 100, which includes physical computer resources 101 (e.g., a processor/CPU, memory, and network components), for example an Oracle WebLogic Server, Oracle Fusion Middleware, or other application server or database environment, can include or provide access to a database 102, for example an Oracle database, or other type of database.

[0020] As further illustrated in Figure 1 , in accordance with an embodiment, the system also includes a connection pool logic 104 or program code, which when executed by a computer controls 105 the creation and use of connection objects in a connection pool 106, including, for example, connections that are currently in use 108 by a software application, and connections that are idle 1 10, or are not currently being used.

[0021] Software applications can initialize connections retrieved from a connection pool, before using the connection to access, or perform work at the database. Examples of initialization can include simple state re-initializations that require method calls within the application code, or more complex initializations including database operations that require round trips over a network. The computational cost of these latter types of initialization may be significant.

[0022] Some connection pools (for example, UCP) allow their connection pools to be configured using connection pool properties, that have get and set methods, and that are available through a pool-enabled data source instance. These get and set methods provide a convenient way to programmatically configure a pool. If no pool properties are set, then a connection pool uses default property values.

[0023] In accordance with an embodiment, labeling connections allows a client software application to attach arbitrary name/value pairs to a connection. The application can then request a connection with a desired label from the connection pool. By associating particular labels with particular connection states, an application can potentially retrieve an already-initialized connection from the pool, and avoid the time and cost of re-initialization. Connection labeling does not impose any meaning on user-defined keys or values; the meaning of any user-defined keys and values is defined solely by the application.

[0024] For example, as illustrated in Figure 1 , in accordance with an embodiment, the connection pool can include a plurality of connections that are currently in use by software applications, here indicated as connections A 1 12 and B 114. Each of the connections can be labeled, for example connection A is labeled (Blue) and connection B is labeled (Green). These labels/colors are provided for purposes of illustration, and as described above can be arbitrary name/value pairs attached to a connection by a client application. In accordance with various embodiments, different types of labels can be used, to distinguish between different connection types; and different applications can attach different labels/colors to a particular connection type.

[0025] As further illustrated in Figure 1 , in accordance with an embodiment, the connection pool can also include a plurality of connections that are idle, or are not currently being used by software applications, here indicated as connections C 1 16, D 118, E 120, F 122, G 124 and N 126. Each of the idle connections can be similarly labeled, in this illustration as (Blue) or (Green), and again these labels/colors are provided for purposes of illustration.

[0026] As further illustrated in Figure 1 , in accordance with an embodiment, if a software application 130 wishes to make a request on the database, using a particular type of connection, for example a (Red) connection, then the application can make a "getConnection(Red)" request 132. In response, the connection pool logic will either create a new (Red) connection, here indicated as X 134 (Red); or repurpose an existing idle connection from (Blue or Green) to (Red), here indicated as E 135 (Red).

Sharded Databases

[0027] In accordance with an embodiment, sharding is a database-scaling technique which uses a horizontal partitioning of data across multiple independent physical databases. The part of the data which is stored in each physical database is referred to as a shard. From the perspective of a software client application, the collection of all of the physical databases appears as a single logical database.

[0028] In accordance with an embodiment, the system can include support for use of a connection pool with sharded databases. A shard director or listener provides access by software client applications to database shards. A connection pool (e.g., UCP) and database driver (e.g., a JDBC driver) can be configured to allow a client application to provide a shard key, either during connection checkout or at a later time; recognize shard keys specified by the client application; and enable connection by the client application to a particular shard or chunk. The approach enables efficient re-use of connection resources, and faster access to appropriate shards.

[0029] Figure 2 further illustrates a system that includes a connection pool, including support for use of a sharded database, in accordance with an embodiment.

[0030] In accordance with an embodiment, a database table can be partitioned using a shard key (SHARD_KEY), for example as one or more columns that determine, within a particular shard, where each row is stored. A shard key can be provided in a connect string or description as an attribute of connect data (CONNECT_DATA). Examples of shard keys can include a VARCHAR2, CHAR, DATE, NUMBER, or TIMESTAMP in the database. In accordance with an embodiment, a sharded database can also accept connections without a shard key or shard group key.

[0031] In accordance with an embodiment, to reduce the impact of resharding on system performance and data availability, each shard can be subdivided into smaller pieces or chunks. Each chunk acts as a unit of resharding that can be moved from one shard to another. Chunks also simplify routing, by adding a level of indirection to the shard key mapping.

[0032] For example, each chunk can be automatically associated with a range of shard key values. A user-provided shard key can be mapped to a particular chunk, and that chunk mapped to a particular shard. If a database operation attempts to operate on a chunk that is not existent on a particular shard, then an error will be raised. When shard groups are used, each shard group is a collection of those chunks that have a specific value of shard group identifier.

[0033] A shard-aware client application can work with sharded database configurations, including the ability to connect to one or multiple database shards in which the data is partitioned based on one or more sharding methods. Each time a database operation is required, the client application can determine the shard to which it needs to connect.

[0034] In accordance with an embodiment, a sharding method can be used to map shard key values to individual shards. Different sharding methods can be supported, for example: hash-based sharding, in which a range of hash values is assigned to each chunk, so that upon establishing a database connection the system applies a hash function to a given value of the sharding key, and calculates a corresponding hash value which is then mapped to a chunk based on the range to which that value belongs; range-based sharding, in which a range of shard key values is assigned directly to individual shards; and list-based sharding, in which each shard is associated with a list of shard key values.

[0035] As illustrated in Figure 2, in accordance with an embodiment a sharded database 140 can comprise a first database region A (here indicated as "DB East", DBE) 141 , including sharded database instances "DBE-1" 142, with a shard A stored as chunks A1 , A2, ... An; and "DBE-2" 143, with a shard B stored as chunks B1 , B2, ... Bn.

[0036] As further illustrated in Figure 2, in accordance with an embodiment, a second database region B (here indicated as "DB West", DBW) 144, includes sharded database instances "DBW-1" 145, with a shard C stored as chunks C1 , C2, ... Cn; and "DBW-2" 146, with a shard D stored as chunks D1 , D2, ... Dn.

[0037] In accordance with an embodiment, each database region or group of sharded database instances can be associated with a shard director or listener (e.g., an Oracle Global Service Managers (GSM) listener, or another type of listener). For example, as illustrated in Figure 2, a shard director or listener 147 can be associated with the first database region A; and another shard director or listener 148 can be associated with the second database region B. The system can include a database driver (e.g., a JDBC driver) 152 that maintains a shard topology layer 154, which over a period of time learns and caches shard key ranges to the location of each shard in a sharded database.

[0038] In accordance with an embodiment, a client application can provide one or more shard keys to the connection pool during a connection request 162; and, based on the one or more shard keys, and information provided by the shard topology layer, the connection pool can route the connection request to a correct or appropriate shard.

[0039] In accordance with an embodiment, the connection pool can also identify a connection to a particular shard or chunk by its shard keys, and allow re-use of a connection when a request for a same shard key is received from a particular client application.

[0040] For example, as illustrated in Figure 2, in accordance with an embodiment, a connection to a particular chunk (e.g., chunk A1) can be used to connect 174, to that chunk. If there are no available connections in the pool to the particular shard or chunk, the system can attempt to repurpose an existing available connection to another shard or chunk, and reuse that connection. The data distribution across the shards and chunks in the database can be made transparent to the client application, which also minimizes the impact of re-sharding of chunks on the client.

[0041] When a shard-aware client application provides one or more shard keys to the connection pool, in association with a connection request; then, if the connection pool or database driver already has a mapping for the shard keys, the connection request can be directly forwarded to the appropriate shard and chunk, in this example, to chunk C2.

[0042] When a shard-aware client application does not provide a shard key in association with the connection request; or if the connection pool or database driver does not have a mapping for a provided shard key; then the connection request can be forwarded to an appropriate shard director or listener.

Multi-Tenant Environments

[0043] In accordance with an embodiment, the system can include support for cloud- based or multi-tenant environments using connection labeling. For example, a multi-tenant cloud environment can include an application server or database environment that includes or provides access to a database for use by multiple tenants or tenant applications, in a cloud- based environment.

[0044] Figure 3 further illustrates a system that includes a connection pool, including support for use in a multi-tenant environment, in accordance with an embodiment.

[0045] Software applications, which can be accessed by tenants via a cloud or other network, may, similarly to the environments described above, initialize connections retrieved from a connection pool before using the connection.

[0046] As described above, examples of initialization can include simple state reinitializations that require method calls within the application code, or more complex initializations including database operations that require round trips over a network.

[0047] As also described above, labeling connections allows an application to attach arbitrary name/value pairs to a connection, so that the application can then request a connection with a desired label from the connection pool, including the ability to retrieve an already-initialized connection from the pool and avoid the time and cost of re-initialization.

[0048] As illustrated in Figure 3, in accordance with an embodiment, a multi-tenant database environment 180 can include, for example, a container database (CDB) 181 , and one or more pluggable database (PDB), here illustrated as "PDB-1" 182, "PDB-2" 183, and "PDB-3" 184.

[0049] In accordance with an embodiment, each PDB can be associated with a tenant, here illustrated as "Tenant-1", "Tenant-2", and "Tenant-3", of a multi-tenant application that is either hosted by the application server or database environment 185, or provided as an external client application 186, and which provides access to the database environment through the use of one or more Oracle Real Application Cluster (RAC) instances 186, 188, including in this example "RAC-lnstance-1", and "RAC-lnstance-2"; one or more services, including in this example Service- 1", "Service-2", and "Service-3", and a mapping of tenants to services 190.

[0050] In the example illustrated in Figure 3, an application being used by a tenant to access the database environment, can make connection requests associated with that tenant's data source 192, 194, 196, and the system can switch services 198 if necessary, to utilize connections to existing RAC instances or PDBs. Server-Side Connection Pools

[0051] In accordance with an embodiment, the system can utilize a server-side connection pool tagging feature, such as that provided, for example, by Oracle Database Resident Connection Pool (DRCP). A server-side connection pool tagging feature allows user applications or clients to selectively obtain a connection to a database environment, based on use of a single tag that is understood by that database environment.

[0052] In accordance with an embodiment, only one tag is associated per connection.

The database server does not communicate the tag value to the user applications or clients, but rather communicates a tag-match (for example, as a Boolean value). Efficient Repurposing of Connections in the Pool

[0053] In accordance with an embodiment, the system can include support for efficient repurposing of connections. A software application can request that a connection be provided, to enable access to the database. In response to receiving the request, the connection pool can first determine if a particular connection with the exact desired attributes already exists within the pool, but is borrowed at the time of the request. If such a connection exists, then the connection pool can wait a period of time for that particular connection to become available, referred to herein as a double-wait. Subsequently, if the particular connection is not made available within the double-wait time period, the connection pool resumes its usual operation, for example by repurposing other connections.

[0054] With a traditional connection pool, whenever a request is made by a software application for a connection with specific desired attributes (e.g., having a particular connection label or a particular session state), the usual procedure is for the connection pool to: (1) determine if there is an available connection which has the desired attributes; or if not, then (2) determine if there is an available connection having different attributes, but which can be repurposed to satisfy the request, by modifying its attributes; or (3) attempt to create an entirely new connection with the desired attributes.

[0055] If the maximum number of allowed connections has been reached, then the connection pool will generally wait for an existing, albeit busy, connection to be released, and then repurpose the released connection.

[0056] In such an environment, the connection pool supports a single-wait functionality, i.e., to wait for a suitable connection to become available, and then to act accordingly. [0057] However, in accordance with an embodiment, the system can include a double- wait functionality, which enables the connection pool, instead of or in addition to its single-wait functionality described above, to first determine if a particular connection with the exact desired attributes already exists, but is borrowed at the time of the request; and if so, to wait for a period of time for that connection to become available (referred to herein as a connection double-wait timeout (Atcdw)) , before resuming its usual procedure as described above.

[0058] With double-wait functionality, the possibility of reusing connections, without repurposing or otherwise having to modify the attributes of those connections, is increased. Since change-connection attributes are computationally-expensive operations, in terms of roundtrip/latency and server-side CPU usage, the use of a double-wait provides an efficient means of providing and/or repurposing connections in response to requests.

[0059] For example, in accordance with an embodiment, the system can include support for cloud-based or multi-tenant environments, including an application server or database that includes or provides access to a database, for use by multiple tenants or tenant applications.

[0060] In such an environment, when there is no connection available in the pool for a given tenant, then instead of repurposing an available connection that is associated with another tenant (which would be a computationally-expensive operation), the connection pool can double-wait, including first determining if the pool already includes a connection for the given tenant, even though that particular connection is currently borrowed (i.e., a particular connection with the exact desired attributes). If so, then the connection pool can wait for a period of time for that particular (i.e., that given tenant's) connection to become available, so that it can be provided without requiring a change in attributes. The connection pool will only repurpose another tenant's connection if no connection with the exact desired attributes is made available.

[0061] Figures 4-8 illustrate support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[0062] As described above, labeling connections allows a client software application to attach arbitrary name/value pairs to a connection. The application can then request a connection with a desired label, to be provided by the connection pool. By associating particular labels with particular connection states, an application can potentially retrieve an already-initialized connection from the pool, and avoid the time and cost of re-initialization. For example, if a software application wishes to make a request on the database, using a particular type of connection, e.g., a (Red) connection, then the connection pool logic can either create a new (Red) connection; or repurpose an existing idle connection from e.g., (Blue or Green) to (Red).

[0063] However, a connection pool's borrow operation is typically complex, comprising several orchestrated connection selection mechanisms - for example, RAC load balancing, high availability, affinity, connection validation, labels processing, harvesting, or processing of various timeouts. While the above example uses different colors to illustrate that a repurposing could include a transformation of, for example, a (Blue) connection to a (Red) connection; in actual practice this transformation might require closing a connection on one RAC instance, and creating a replacement on another RAC instance, together with the various procedures required to implement such an operation.

[0064] For attributes that are computationally-inexpensive, this may be a relatively straightforward process. However, computationally-expensive attribute changes, for example, changing a pluggable database within a container database, as might be implemented in a multi-tenant environment, require a more considered approach.

[0065] As illustrated in Figure 4, in accordance with an embodiment, a double-wait functionality 250 can be used by the connection pool, to perform a wait 252, followed, if appropriate, by a repurpose connection after wait 254, the process of which is described in further detail below.

[0066] In accordance with an embodiment, the described approach recognizes that, even if there may be a matching connection for a borrow request, and a borrowing thread is double-waiting for this connection, there is no guarantee that the connection is returned within the connection double-wait timeout (Atcdw).

[0067] To address this, in accordance with an embodiment, the connection double- wait timeout can be set smaller than the connection wait timeout (Atcw), so that the system can revert back to its usual procedure, i.e., to a single-wait borrowing mode, if the double-wait was unsuccessful.

[0068] For example, in accordance with an embodiment, the connection double-wait timeout (AU) can be set as 50 milliseconds, with the (total) connection wait timeout or time period (Atcw) set as 500 milliseconds.

[0069] Additionally, in accordance with an embodiment, the described approach recognizes that the system generally may not be able to predict when a borrowed connection will be returned to the pool. However, relying on signal events for such information would be expensive performance-wise. For example, if the system were to wait for a signal API, for every returned connection, this would slow down the performance of the connection borrow/return mechanism.

[0070] To address this, in accordance with an embodiment, the connection pool supports a borrow operation that combines a small number of waiting-for-a-signal API calls, with busy-waiting polls of a pool, for obtaining a required connection. Generally, the only situation in which the borrow operation waits to be signaled, is when there is nothing to borrow at the moment. An appearance of a valid available connection triggers all of the currently- borrowing threads to start polling.

[0071] Generally, threads should poll the pool with small (e.g., nanoseconds, or zero- time) intervals, to attempt to obtain an appropriate connection as soon as possible. However, in practice, zero-time polling intervals can result in extensive CPU usage. To address this, in accordance with an embodiment, the connection pool supports an auto-tuning process, as further described below, to provide a balance between CPU load and endurance of these intervals.

[0072] For example, in accordance with an embodiment, an inter-poll sleeping interval can be computed with: t s iee — to (\ CPU eX p ec t ec i — PU curren(: l )

[0073] Where Ato is an empirical constant time interval, CPUexpected is the percentage

CPU utilization expected, and CPU current is the percentage current CPU utilization. In accordance with an embodiment, the value for CPU utilization is an integral value of CPU utilization for all participating threads.

Single-Wait and Double-Wait Modes

[0074] In accordance with an embodiment, the system is configured to poll the connection pool using two different modes: generally referred to herein as a connection single- wait mode, and a connection double-wait mode.

[0075] In a connection single-wait mode, the connection pool logic assumes that a borrow request expects any connection to show up available to be reserved (for example, any of (Red), (Blue), or (Green) connections, the particular connection type does not matter), repurposed if needed (e.g., a (Red) connection is transformed to (Green)), and then borrowed. This single-wait mode lasts for the duration of the connection wait timeout (At cw ), which can be defined as a configurable connection pool property.

[0076] In a connection double-wait mode, the connection pool assumes that a borrow request expects only a connection of required quality or type, i.e., having the exact desired attributes (e.g. only (Red) connections), such that a repurpose is not needed. This double- wait mode lasts for the duration of the connection double-wait timeout (Atcdw), which can be defined as a configurable connection pool property, or automatically/dynamically calculated by the system.

[0077] By definition, the connection wait timeout (Atcw) is the longest interval of time for a borrowing thread to poll a pool for a connection.

[0078] In accordance with an embodiment, the system can be configured to poll in double-wait mode first, and then poll in single-wait mode. Once the double-wait determination does not guarantee a connection to be released within the AW time period, it = is less useful to set (Atcdw = Atcw), since in many situations this would necessitate time spent, with nothing achieved, before an inevitable repurpose. Conversely, setting the value for At CdW = 0 would mean that the double-wait mode is turned off.

[0079] The above indicates that, in accordance with an embodiment, the value for double-wait timeout AU should generally float between some bounds, for example:

0 ≤ At cdw ≤ At,

[0080] Once the value for AU≤ At cw , there is some non-zero time interval to spend for single-waiting for any connection, and repurpose that connection if double-wait was unsuccessful.

[0081] In accordance with an embodiment, the value for double-wait timeout AU can be defined as a configurable property. As described above, another approach is to use an auto-tuning process. For example, the double-wait interval can be made proportional to the statistical average borrow ("ab") time interval At a b , which can be computed with:

1=7 0 1 At-

Atab = n

[0082] Where n is some amount of most recent At, - individual (i) borrow time intervals

(i.e., the time passed between a connection borrow, and a return back to a pool) for all connections of a required type in a pool. The value for At a b is inversely proportional to the number of borrowed connections fitting a pending borrow request (N c ), and is proportional to the number of similar pending borrow requests, i.e., those request looking for connection of

[0083] In accordance with an embodiment, the value for double-wait timeout (AW) can be automatically/dynamically calculated by the system according to the auto-tuning process as: lNb r- AL a b

At cdw = min(FAt cw ,— )

"c

[0084] Where F is maximal allowed value of Atcdw Atcw within the range of [0..1].

[0085] Although it would be possible to tune the value of Atcdw prior to each single poll, in practice this approach would require some analysis to determine the number of borrowed connections of required type and would require some resources. Instead, the system can compute A once per each particular borrow operation, and then use it as a constant for that particular borrow operation.

[0086] For example, as illustrated in Figure 5, in accordance with an embodiment, the connection pool can receive a request for a particular type (e.g., a (Blue)-labeled) connection 260.

[0087] As illustrated in Figure 6, in accordance with an embodiment, the system can include a double-wait functionality, which enables the connection pool, instead of or in addition to its single-wait functionality described above, to first determine if a particular connection with the exact desired attributes already exists, but is borrowed at the time of the request; and if so, to wait for a period of time for that connection to become available If a desired connection is made available within the double-wait timeout (Atcdw), then it is returned 262 to the client application for its use.

[0088] As illustrated in Figure 7, in accordance with an embodiment, if a suitable connection does not become available within the double-wait timeout (A ), the connection pool can resume its usual procedure, during a single-wait mode.

[0089] As illustrated in Figure 8, in accordance with an embodiment during the

(remaining, or single-wait) connection timeout (Atcw), the connection pool can determine whether to repurpose 264 an existing idle connection, in this example to a (Blue) Connection 266, and then return it 268, to the client application.

[0090] The following additional examples illustrate the above:

[0091] Example 1 : Consider a pool of 100 connections, in which At cw is 10 seconds, there are two types of connections, 50 (Green) and 50 (Blue) ones. Currently there are all 50 (Green) and 25 (Blue) ones borrowed, 25 (Blue) ones are available and there are 150 (Green) borrow requests pending. At a b is 1 second for now. Consider an example in which F is 0.5. So, A = min ((0.5 *10), ((150+1) / 50)) i.e., equal to 3 seconds. The borrow request would double-wait for 3 seconds, expecting connection of an exact required type, then it would wait for another 7 seconds to obtain any connection and repurpose it.

[0092] Example 2: Consider the example described above with the same inputs, in which there are 300 borrowing requests instead of 150. Then the AU = min ((0.5 *10), ((300+1) / 50)), i.e., equal to 5 seconds. This means that to borrow (Green) connection, a borrow thread would double-wait for 5 seconds, then, if not borrowed, will single-wait for another 5 seconds, repurposing if needed.

[0093] Example 3: Consider the example described above with the same inputs, and 5000 borrowing requests instead of 300. A = 5 seconds. This results in the same behavior as Example 2. Connection Borrow Process

[0094] Figure 9 further illustrates support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[0095] As illustrated in Figure 9, in accordance with an embodiment, the connection borrow operation can be viewed as proceeding from a double-wait poll preparation step 280, to a double-wait polling cycle 282, to a single-wait poll preparation step 290, to a single-wait polling cycle 292, to one or more post-borrow action steps 300, each of which are further described below. Double-Wait Poll Preparations:

[0096] In accordance with an embodiment, the double-wait poll preparations can include:

[0097] a. Compute A .

[0098] b. Save a current timestamp, and start double-wait polling.

Double-Wait Polling Cycle:

[0099] In accordance with an embodiment, the double-wait polling cycle can include:

[00100] a. Determine Atcdw as the time interval for double-wait polls. Check if it is already passed. If passed, exit the double-wait cycle and start single-wait poll preparations.

[00101] b. Poll for an available valid connection of a proper type. If an available valid connection of a proper type is found, then jump to post-borrow actions; the borrow request is over. If not, then go to next step.

[00102] c. Compute At s/eep .

[00103] d. Sleep, and go to (a).

Single-Wait Poll Preparations:

[00104] In accordance with an embodiment, the single-wait poll preparations can include:

[00105] a. Compute At cw - AU .

[00106] b. Save current timestamp, and start single-wait polling.

Single-Wait Polling Cycle:

[00107] In accordance with an embodiment, the single-wait polling cycle can include:

[00108] a. Atcw - Atcdw is the time interval for single-wait polls. Check if it is already passed. If passed, exit the single-wait cycle and start performing post-borrow actions. [00109] b. Poll for an available valid connection of any type. If an available valid connection of any type is found, then jump to post-borrow actions; the borrow request is over. If not, then go to next step.

[00110] c. If there is a room to grow the connection pool, then grow it with a connection of the required type. If a new connection has been grown, then get it, and jump to post-borrow actions; the borrow request is over. If not, then go to next step.

[00111] d. Compute At s , eep .

[00112] e. Sleep, and go to (a).

Post-Borrow Actions:

[00113] In accordance with an embodiment, the post-borrow actions can include:

[00114] a. Perform some post-borrow actions on a connection.

[00115] b. Return a connection, or null. [00116] In accordance with an embodiment, for the connection return operation for a double-wait mechanism, a regular connection return logic works as needed, returning a connection from an application because it is not needed anymore. The return increments the number of available connections, marks a connection available in the pool, and sends a signal to a pool if it is waiting for at least one available connection.

[00117] Figure 10 illustrates a method of providing support for efficient repurposing of connections, in a connection pool environment, in accordance with an embodiment.

[00118] As illustrated in Figure 10, in accordance with an embodiment, at step 310, at an application server or database environment, a connection pool logic or program code is provided that controls the creation and use of connection objects in a connection pool, wherein software applications can request a connection from the connection pool, and use a provided connection to access a database.

[00119] At step 312, a double-wait functionality is provided for use with the connection pool, wherein in response to a request for a particular connection having desired attributes, the connection pool first determines if a connection with those exact desired attributes already exists within the connection pool, but is borrowed at the time of the request; and if so, the connection pool waits for a double-wait timeout or time period for that connection to become available.

[00120] At step 314, when the double-wait timeout or time period expires, the connection pool reverts to a single-wait mode, to determine if there is an available connection having different attributes, but which can be repurposed to satisfy the request, by modifying its attributes; or attempt to create an entirely new connection with the desired attributes.

[00121] At step 316, the connection pool provides one of the connection having the exact desired attributes, the repurposed connection, the new connection, or returns a null or other value.

[00122] Embodiments of the present invention may be conveniently implemented using one or more conventional general purpose or specialized digital computer, computing device, machine, or microprocessor, including one or more processors, memory and/or computer readable storage media programmed according to the teachings of the present disclosure. Appropriate software coding can readily be prepared by skilled programmers based on the teachings of the present disclosure, as will be apparent to those skilled in the software art.

[00123] In some embodiments, the present invention includes a computer program product which is a non-transitory storage medium or computer readable medium (media) having instructions stored thereon/in which can be used to program a computer to perform any of the processes of the present invention. Examples of the storage medium can include, but is not limited to, any type of disk including floppy disks, optical discs, DVD, CD-ROMs, microdrive, and magneto-optical disks, ROMs, RAMs, EPROMs, EEPROMs, DRAMs, VRAMs, flash memory devices, magnetic or optical cards, nanosystems (including molecular memory ICs), or any type of media or device suitable for storing instructions and/or data.

[00124] The foregoing description of embodiments of the present invention has been provided for the purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise forms disclosed. Many modifications and variations will be apparent to the practitioner skilled in the art. The modifications and variations include any relevant combination of the disclosed features. The embodiments were chosen and described in order to best explain the principles of the invention and its practical application, thereby enabling others skilled in the art to understand the invention for various embodiments and with various modifications that are suited to the particular use contemplated.