Database Connection Pool Reuse for Throughput Optimization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for controlling database connections are costly and reduce database throughput due to the need for maintaining bundled connections, making it challenging to support a large number of database access requests effectively.
Innovation Solution
A method and apparatus that manage database connections by reusing idle connections from a connection pool and establishing new connections as needed, with control rules to dynamically adjust the number of connections based on access requests, and utilizing slave databases for load balancing and fault management.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If the database connection is bundled with a working thread of a server, then the connection stability is improved, but the maintenance cost increases and throughput decreases
Solution Approach 1:
The patent divides the connection management into separate components: a connection pool that maintains database connections independently from working threads. The connection pool is segmented from the thread pool, allowing connections to be reused across multiple threads without being bundled, thus improving throughput while maintaining stability through the pooled connection management.
Solution Approach 2:
The patent introduces a connection pool as an intermediary between the thread pool and the database. This intermediary layer manages connections centrally, allowing multiple threads to access and reuse connections without direct bundling, thereby resolving the contradiction between connection stability and system throughput.
2Device complexity
If the database connection is bundled with a working thread of a server, then the connection management is simplified, but the number of connections required increases
Solution Approach 1:
The connection pool serves multiple functions: it maintains connections, manages connection lifecycle, handles connection allocation to multiple threads, and provides connection reuse. This universal connection management mechanism eliminates the need for each thread to maintain its own bundled connection, reducing the total number of connections required while managing complexity centrally.
3Loss of energy
If idle database connections are reused, then the maintenance cost is reduced, but the connection attribute compatibility must be ensured
Solution Approach 1:
The patent modifies connection attributes dynamically to ensure compatibility when reusing idle connections. The system adjusts connection parameters such as timeout values, buffer sizes, and other attributes to match the requirements of the new task, allowing idle connections to be reused safely while maintaining compatibility and reducing maintenance costs.
Data Source
AI summary
The present application discloses a method and apparatus for controlling a database connection. A specific embodiment of the method comprises: receiving an access request for a database sent by a terminal; determining whether a database connection pool comprises an idle database connection for the database; reusing the idle database connection to connect the terminal with the database if the database connection pool comprises the idle database connection for the database; and establishing a new database connection, in order to connect the terminal with the database by utilizing the new database connection if the database connection pool comprises no idle database connections. This embodiment effectively utilizes fewer database connections to support database access requests.


