0

Our .NET web app uses ODP.NET for connections and its Oracle User for connecting to database is "webuserOracle". That web app always close connections and dispose connections.

However, on our Oracle 10g database, we see that sessions and processes values of Oracle User "webuserOracle" is always high, as they woudn't close or die.

We have decided to set up on Oracle profile for "webuserOracle" in order to limit the connect time up to 5 minutes.

CREATE PROFILE profile_webuserOracle LIMIT CONNECT_TIME 5;

ALTER USER webuserOracle PROFILE profile_webuserOracle;

Question:

For a web app, limiting connection to 5 minutes, means that the user could interact, say, 2 hours with the web app. The limit of 5 minutes is only for events triggered (like clicking a button) to connect to database. 5 minutes for everything that happened between Con.Open and Con.Dispose:

Dim con As OracleConnection = oraConexion()
con.Open()
''' There'll be a limit of 5 minutes to run the code here
con.Close()
con.Dispose()
4

1 回答 1

1

在 Web 应用程序的配置文件中设置 aCONNECT_TIME可能是一个非常糟糕的主意。

首先,一般来说,三层应用程序将使用中间层的连接池。这意味着中间层服务器会打开一个连接到数据库的连接池,这些连接会在很长一段时间内保持打开状态,并根据需要分发给 Web 会话。这意味着在网站上单击的单个 Web 用户可能会在每次单击时获得不同的数据库会话,并且单个数据库会话将被大量 Web 用户使用。

如果你CONNECT_TIME为你的连接池连接设置一个,

  • 中间层可能会不断收到错误,即它从连接池中获得的特定连接已超过其允许的连接时间。您可以通过让中间层在从池中获取的每个连接上执行一个虚拟查询(即select 1 from dual)来缓解其中的一些问题,以验证在交互开始之前 5 分钟没有过去,但不能保证超时获胜'在页面上运行第一个查询时无法到达。
  • 中间层将不断地打开到数据库的新物理连接(一个相当昂贵的过程),以替换因为打开 5 分钟而关闭的连接。这些连接风暴可能会给数据库带来巨大的负载。这也会给应用程序带来性能问题,因为用户一直在等待新的物理连接打开,而不是能够重用池中的连接。
  • 如果您进行此更改,会话和进程的数量可能会更高。中间层将维护它需要为用户提供服务的许多实际物理连接,以及一些必须保留的过期连接,以便通知下一个调用者它们已过期。

您要解决的真正问题是什么?中间层将维护一个不会关闭的数据库连接池是完全正常的。这是完全正常和健康的。如果您想减少任何时候打开的连接数,您可以调整中间层服务器上的连接池设置。

于 2012-08-13T18:08:09.190 回答