Delmonte
Delmonte

Reputation: 411

Oracle sessions and processes generated by a .NET web app

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()

Upvotes: 0

Views: 550

Answers (1)

Justin Cave
Justin Cave

Reputation: 231661

Setting a CONNECT_TIME in a profile for a web application is likely to be a very bad idea.

First off, generally, a three-tier application is going to make use of connection pools in the middle tier. That means that the middle tier servers open a pool of connections to the database that remain open for a long period of time and get handed out to web sessions as needed. That means that a single web user that is clicking around through the site is likely to get different database sessions with each click and that a single database session will be used by a very large number of web users.

If you set a CONNECT_TIME for your connection pool connections,

  • The middle tier is likely to constantly get errors that the particular connection it obtained from the connection pool has exceeded its allowed connection time. You can mitigate some of that by having the middle tier execute a dummy query (i.e. select 1 from dual) on every connection that it gets from the pool to verify that the 5 minutes hasn't elapsed before the interaction starts but there is no guarantee that the timeout won't be reached when you run the first query on the page.
  • The middle tier will constantly be opening new physical connections to the database (a rather expensive process) to replace the connections that have been closed because they've been open for 5 minutes. Those connection storms are likely to put a substantial load on the database. That will also create performance problems for the application as users are constantly waiting for new physical connections to be opened rather than being able to reuse connections from the pool.
  • The number of sessions and processes is likely to be much higher if you make this change. The middle tier is going to maintain however many real physical connections it needs to service the users plus a number of expired connections that have to remain simply to inform the next caller that they are expired.

What is the real problem you are trying to solve? It is perfectly normal that the middle tier will maintain a pool of database connections that do not close. That is perfectly normal and healthy. If you want to reduce the number of connections that are open at any one time, you can adjust the connection pool settings on your middle tier servers.

Upvotes: 1

Related Questions