Make sure your connection string uses pooling. This way you would pool from
a collection of connections so when you call a connection.Open() method, it
first sees if there's a connection in the pool and then will use an
available connection. A lot of this is already handled for you behind the
scenes by ADO.Net so you don't have to worry about it so much. The general
rule though, only have your connection open for the length of time you need
it then close it right away. This frees it up to be used by some other page.
Instead of caching the connections, you should be looking at where you can
use the built-in output caching for a web page or control. If you are
creating news for a site, then make sure the page caches itself so that
you're only calling for a fresh set of data every 20 minutes or so, no need
to cache the connection here, just the resultant page since it's not
changing that often.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression
<la*****@gmail.comwrote in message
news:5d**********************************@e6g2000p rf.googlegroups.com...
Hi there
Anybody knows what is the best way to manage creation 2000 of the
database connections at the same time?
Now Im doing it somethink like this:
using ( Connection conn = Connection.Create )
{
conn.Open();
//...
}
...but I thinks that isn't a good solution because every (of 2000)
visitor who enters to the site always gets a new connection. Every
refresing page creates a new connection.
In my opinion this solve isn't good. So, what is the best way to do it
right? Am I always must create a new connection for every page
refresing? Could I cache it...? or .. what?