The connection pool is a leasing company that stores products across the country in your community.
You don't have to go to your own manufacturer to use things. You just need to rent it from the leasing company. If you have used it, remember to go back. The tenant's warehouse is limited!
If there are too many people to rent, you have to add a warehouse.
If there are too many idle products in the warehouse for a long time, you have to narrow down the warehouse.
Advantages,
1. You can quickly get what you need.
2. All items can be reused.
3 manufacturers can reduce transportation costs
Corresponding connection pool
You need to connect to the database without having to get it from the database. You can rent it from the connection pool. After you have used it, remember to go back. Because the connection pool has the maximum allowed connection limit!
If you have too many users and need more database connections at the same time, you have to increase the maximum number of connections.
If there are too many connections to the idle database for a long time, you need to reduce the maximum number of connections or the allowed number of idle and initial connections.
Advantages,
1. You can quickly get the connection you need.
2. All database connections can be reused.
3 can reduce the burden on the database. Creating a new database connection consumes a lot of system resources.
Tip:
What else will happen if you forget to lease something? Because there is no available connection in the connection pool, you can only apply for more connections,
If the maximum number of connections is exceeded, or the maximum number of connections allowed by the database, the system waits and the system fails to run.
Source: Old zizhu quotations» image metaphor for database connection pools