Oracle会话与连接池的关系
我先解释一下设置。
我们有一个在 2GB RAM 机器上运行的 oracle 服务器。 Db 实例的初始化参数“sessions”设置为 160。
我们将应用程序部署在 Websphere 6.1 上。 连接池设置为最小 50 和最大 150。
当我们对 40 个用户运行负载测试(并发,使用 jMeter)时,一切正常。 但是当我们将并发用户数增加到超过 60 时,Oracle 会抛出会话不足的异常。
我们检查了应用程序是否存在任何连接泄漏,但没有发现任何连接泄漏。
那么是不是说这个设置可以承受40个并发呢? 增加 Oracle 会话/进程是获得更高并发性的唯一方法吗?
数据库会话和连接池中的连接究竟如何相关? 根据我的理解,连接数不能超过会话数,因此将最大连接池设置为超过会话数可能并不重要。 那是对的吗 ?
Let me explain the set up first.
We have an oracle server running on a 2GB RAM machine. The Db instance has the init parameter "sessions" set to 160.
We have the application deployed on Websphere 6.1. The connection pool settings is Min 50 and Max 150.
When we run Load test on 40 Users (concurrent, using jMeter), everything goes fine.
But when we increase the concurent users to Beyond 60, Oracle throws and exception that it is out of sessions.
We checked the application for any connection leaks but could not find any.
So does it mean that the concurrency of 40 is what this setup can take ? Is increasing the Oracle sessions/process the only way to obtain higher concurrency ?
How exactly are the DB sessions and Connection in the Connection pool related ? In my understanding, the connections cannot exceed the sessions and so setting the Max Connection pool to more than sessions may not really matter. Is that correct ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的所有连接都使用同一个用户帐户吗? 如果是这样,您可能需要检查该用户帐户是否有每用户会话限制。
另外,您是否获得了超过 40 个连接的许可? (检查您的参数文件中是否设置了 LICENSE_MAX_SESSION)
Are all your connections using the same user account? If so, you might want to check to see if you have a per-user session limit for that user account.
Also, are you licensed for more than 40 connections? (Check if you have LICENSE_MAX_SESSION set in your parameter file)
会话池是客户端驱动的。 它不知道(或控制)数据库将允许多少个会话。
您应该查看服务器以确定允许的实际连接数,并根据服务器允许的连接数设置会话池数。
您的连接池不应使用所有允许的连接。 这将使其他 ID 能够连接。 如果您有一个使用 USER_1 的应用程序,则可以将连接池设置为使用一定数量的允许连接,但保留足够的连接...哦,请让 DBA 登录。
-- 编辑 --
在连接池达到最大之前,进程可能会耗尽。
这是允许的进程总数
现在看看有多少已经被使用 - 其中许多是后台进程,你永远不会想到。
The session pool is client-side driven. It doesn't know (or control) how many sessions the database will allow.
You should look on the server to determine the actual number of connections that are allowed and set the session pool number based on what the server will allow.
Your connection pool should not use all of the connections allowed. This will let other IDs connect. If you have an application using USER_1, you'd set the connection pool to use some amount of the allowed connections, but leave enough connections for... Oh, say DBA to log in.
-- Edit --
Processes are probably runing out before your connection pool maxes out.
This is the total # of processes allowed
Now see how many are already used - many of them are background procs, you'd never think of.
Metalink 给出了有关 SESSIONS 参数的以下建议:
因此,根据 websphere 和您的用户进程正在执行的操作,这可以部分解释您所看到的内容。
Metalink gives the following advice about the SESSIONS parameter:
So, depending on what websphere and your user process are doing this could partially explain what you're seeing.
我的 v$session 包含 30 个条目,其中 4 个有用户名(其中一个是后台作业)。
如果您有后台进程(例如批处理作业),它们可能会占用会话。
但也可能是您的内存不足。 对于 50 个会话的连接池来说,2GB 似乎有点低。 假设Oracle 10g,你的RAM分为共享(SGA)和进程(PGA)。 假设您有 1.5GB 用于 SGA,那么剩下 500MB 用于所有会话。 如果每个会话占用 10MB,则大约 50 个会话就会达到限制。
事实上,
1. 您的机器上将运行一些其他“东西”,因此不会有完整的 2GB 可供 Oracle 使用
PS, 。 2GB 是否意味着您使用的是 Windows?
My v$session contains 30 entries, 4 of which have a username (one of which is a background job).
If you've got background processes (eg batch jobs), they could be chewing up sessions.
But it could be that you are simply running out of memory. 2GB seems a bit low for a conneection pool of 50 sessions. Assuming Oracle 10g, you're RAM is divided into shared (SGA) and process (PGA). Say you've got 1.5GB for SGA, that leaves 500MB for all the sessions. If sessions grab 10MB each, you'll hit your limit around 50 sessions.
In reality,
1. You'll have some other 'stuff' running on the box, so won't have a full 2GB available to Oracle
PS. Does the 2GB mean you are on Windows ?