D
David Browne
Bernardo Heynemann said:I have multiple users accessing my database at all times.
As i am using today, i have one connection that serves all users (ASP 3.0
Application object).
This works fine since i´m using an oracle database server.
The problem is when there are too many concurrent data requests (selects)
some users get timeouts, since oracle uses a queue for each connection.
Then the first 10 users get their request, but the 11th one gets a timeout
(example).
I want to do a Threaded Data Access Layer in .NET that works at ASP 3.0, VB
6.0 or .NET.
It should work this way:
-When the first user requests data, it creates a thread with a connection.
-The N (parameter) following users go to this thread also.
-When the (n+1) user requests data he should be redirected to the second
thread with another connection.
-If there´s an open spot at any of the previous threads the user should be
redirected to that spot in spite of creating a new thread.
Any hints, sugestions, code would be a LOT useful.
Ok. This problem has been solved. The solution is not perfect, but 99.99%
of the people out there are using it. So you shouldn't write something from
scratch.
The solution is Connection Pooling. Both MTS (COM+) and ADO.NET implement
connection pooling, and it happens 100% transparently to you. You will have
slightly more open connections with Connection Pooling than with your
proposed scheme, but on the other hand you user sessions will never have to
wait for another session to finish its databse activity.
Plus you shouldn't interleave unrelated activity on a single session. It's
impossible to tell whos doing what, database locking doesn't work, and you
can't use package variables or global temporary tables.
To start using connection pooling in ADO or ADO.NET just create a new
connection, open it, use it and close it each time you need to talk to the
databse. Behind the scenes, each thread will check out an open connection,
use it, and return it to the pool.
David