views:

26

answers:

2

Hi, Is the singleton requirement of a provider is a performance hit ? Because all the database read/write opertions must be taking place through that singleton. Wouldnt it be an issue with multiple users doing read/write operation in a site like Blogger.

A: 

Instead of using a Singleton to access your database directly, have your Singleton manage a pool of connections. Use the Singleton as a global access point. That way, you can then avoid the bottleneck of a single connection, while still being able to manage the connections.

calico-cat
+1  A: 

You should definitly use a connection pool, and limit the max number of connections to say 200 depending on hardware and traffic.

http://ondotnet.com/pub/a/dotnet/2004/02/09/connpool.html

const string connString = "server=localhost;" +
                             "uid=user;" +
                             "pwd=secret;" +
                             "database=Northwind;" + 
                             "Min Pool Size=50;" +
                             "Max Pool Size=200";   

Further tips regarding performance:

http://msdn.microsoft.com/en-us/magazine/cc163854.aspx

stacker