数据库服务器一次可以有多少个打开的连接?
我试图了解 Oracle 11g 的数据库驻留连接池。现在我想到的一个问题是:如果我在后端有 1 个数据库服务器。我的数据库服务器在给定时刻可以处理多少个并发请求,是一个还是多个?
解释一下我的问题:如果 Client1 请求一个包含前 100 个结果的选择查询,而 Client2 请求选择其他内容,那么服务器是否会同时处理这两个请求,或者服务器会在处理第一个请求之前完成第一个请求吗?下一个请求?
I am trying to understand database resident connection pooling with Oracle 11g. Now one question I have on my mind is: If I have 1 database server in the backend. How many concurrent requests can my database server handle at a given moment, would it be one or would it be more than one at the same time?
To para-phrase my question: If Client1 requests a select query of say top 100 results, and Client2 requests a select of something else, does the server handle both requests at the same moment, or will the server finish the first request before handling the next request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据此处的文档:http://download.oracle。 com/docs/cd/E11882_01/network.112/e10836/listenercfg.htm
这是特定于平台的。 (这也会因数据库系统而异,但您提到了 Oracle 11g,所以这就是我具体回答的。)
对于其他数据库,您始终可以谷歌“最大并发连接数(此处插入数据库类型)”,
而实际上从技术上讲,单个处理器一次只能处理单个计算,因此实际上,当您询问“在同一时刻”技术上答案是否定的。
线程可能会让它们看起来像是同时发生的,但实际上它们很可能是同时发生的不是。线程与功能强大、能够非常快速地完成任务的计算机相结合,通过处理各个任务,使事情看起来就像是同时发生的,但实际上并非如此。但这是一个比这里所能涵盖的更大的话题。
Per the docs here: http://download.oracle.com/docs/cd/E11882_01/network.112/e10836/listenercfg.htm
this is specific to the platform. (This would also vary by database system, but you mentioned Oracle 11g, so that's what I answered specifically.)
For other databases, you can always google "Maximum Concurrent Connections (insert DB type here)"
And in reality technically, a single processor can only handle a single calculation at a time, so in reality, when you ask "At the same moment" technically the answer is no.
Threading may make it LOOK like they are happening at the same moment, but likely they are not. Threading, in conjunction with computers powerful enough to do things very quicly makes things appear like they are happening at the same time by handling the individiual tasks, but in reality, it's not. But that's a bigger topic than can be covered here.
DBMS 可以同时处理多个连接,通常为数百个。然而,通常每个核心会同时进行一些查询(可能是 2-3 个)。
@David,确实,单个处理器一次只能处理单个计算,但是当负载受磁盘限制时,它有大量空闲时间来处理其他查询,同时等待数据加载。
A DBMS can handle many connection simultaneously, typically in the hundreds. However normally a few queries (could be 2-3) per core will proceed at the same time.
@David it's true that a single processor can handle only a single calculation at a time, but when the load is disk bound, it has a lot of spare time to process other queries, while waiting for the data to be loaded.
正如@David 所说,处理器在给定时刻只能做一件事。
也就是说,你的问题不容易给出简单的答案。服务器将以最简单的情况以排队方式处理查询(忽略资源限制等)。然而,一旦第一个查询由于磁盘 I/O 或任何其他资源请求而必须放弃控制,第二个查询就会有机会。它很可能在第一个查询之前完成,具体取决于每个查询正在执行的操作。
As @David states, a processor can do only one thing at a given instant.
That said, your question is not easy to give a simple answer for. The server is going to handle the queries in a queued fashion in it's simplest case (ignoring such things as resource limits). However, as soon as the first query has to give up control due to disk I/O or any other resource request, the second query gets a chance. It very well may complete before the first one, depending on what each query is doing.
通常,查询将同时执行。可以处理的连接数量取决于服务器、侦听器配置以及进程和会话初始化参数。如果您尝试打开过多的连接,您将收到错误消息。
如果您使用连接池,那么每个池连接都会耗尽数据库实例的会话之一及其进程之一。 (有人可能会纠正我关于专用听众和共享听众之间的区别,但这大致是正确的)。通过池连接的每个请求(查询)都使用已经设置的连接,因此它不需要新的 TCP/IP 套接字,并且没有与套接字/会话创建相关的开销 - 这是您的原因之一首先使用池化。
无论您使用的是池连接还是独立连接,执行查询的进程都独立于任何其他查询,并且不会等待任何其他查询完成。如果您正在进行更新,那么这不一定是真的 - 您可能会等待另一个进程完成自己的更新 - 但如果您只是查询,那么这不是一个因素。
您可能会出现资源争用,因此同时运行的两个查询可能比其中任何一个查询单独运行所需的时间稍长,但它们仍然同时运行。
The queries will be executed concurrently, usually. The number of connections that can be handled depends on the server, the listener configuration, and the processes and sessions initialisation parameters. If you try to open too may connections you'll get an error.
If you're using connection pooling then each of those pooled connections is using up one of the database instance's sessions and one of its processes. (Someone may correct me on the difference between dedicated and shared listeners, but that's roughly right). Each request (query) over a pooled connection uses the already set-up connection, so it doesn't need a new TCP/IP socket and doesn't have the overhead associated with socket/session creation - which is one of the reasons you use pooling in the first place.
Whether you're using a pooled or standalone connection, the process that executes your query is independent of any others and doesn't wait for any other queries to finish. If you're doing updates then that's not necessarily true - you may wait for another process to finish its own update - but if you're just querying then that isn't a factor.
You may get contention for resources, so two queries running at the same time might take slightly longer than either of them takes to run on their own, but they're still both running at the same time.