什么是数据库池? [英] What is database pooling?

查看:283
本文介绍了什么是数据库池?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道数据库池的概念。如何实现。

I just wanted to know the concept of database pooling.How it is achieved.

推荐答案

/ em> pooling是一种用于保持数据库连接打开以便他人可以重用的方法。

Database connection pooling is a method used to keep database connections open so they can be reused by others.

通常,打开数据库连接是一种昂贵的操作,连接处于活动状态,以便在稍后请求连接时,使用活动连接之一优先打开另一个。

Typically, opening a database connection is an expensive operation, so pooling keeps the connections active so that, when a connection is later requested, one of the active ones is used in preference to opening another one.

在其最简单的形式中,它只是一个类似于对实际开放连接API的API调用,其首先检查池以获得合适的连接。如果一个可用,那就是给客户端,否则创建一个新的。

In it's simplest form, it's just a similar API call to the real open-connection API which first checks the pool for a suitable connection. If one is available, that's given to the client, otherwise a new one is created.

同样,有一个关闭的API调用,实际上不调用真实的关闭连接,而是将连接放入池中供以后使用。

Similarly, there's a close API call which doesn't actually call the real close-connection, rather it puts the connection into the pool for later use.

这是一个非常简单的解释。实际的实现可能能够处理到多个服务器的连接,可以预先分配一些连接的基线,使得一些基本连接立即就绪,当使用模式静音时实际上可以关闭旧连接,等等。

That's a pretty simplistic explanation. Real implementations may be able to handle connections to multiple servers, may pre-allocate some baseline of connections so some are ready immediately, may actually close old connections when the usage pattern quietens down, and so on.

所以,像下面这样:

  +---------+
  |         |
  | Clients |
+---------+ |
|         |-+        +------+          +----------+
| Clients | ===#===> | Open | =======> | RealOpen |
|         |    |     +------+          +----------+
+---------+    |         ^
               |         |
               |     /------\
               |     | Pool |
               |     \------/
               |         ^
               |         |
               |     +-------+         +-----------+
               #===> | Close | ======> | RealClose |
                     +-------+         +-----------+

这篇关于什么是数据库池?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆