none
How does connection pooling works in asp.net.. RRS feed

  • Question

  • How does connection pooling works?  i want to know that if i set max. pool size = 20 so are only 20 users able to connect to the web app. at a same time and made a transaction ? What happens to the large websites like Amazon where thousands of users log at same time throughout the world i.e what pool size they keep.? i am not getting the core concept. I know that a connection pool keeps open connections and users reuse the open connections but i want my first question to be answered..thanx..
    Monday, August 19, 2013 9:36 AM

Answers

  • The actual # of simultaneous connections to a DB is not related to the # of users accessing a site at the same time. In most cases the DB query itself is very fast and, using proper scoping, the connection is only open for a fraction of the connection time.  20 is really low for a website but you probably wouldn't notice it unless your connections weren't being managed properly, you were writing queries that took seconds to execute or 100s of users hit it at once. 

    Max pool size controls the max # of underlying connections ADO.NET will create.  When the max is reached subsequent requests will block until a connection is available.  However do not confuse this with a Connection object.  Under the hood the actual connection is managed by ADO.NET.  A Connection object is a wrapper around the real connection which is where conn pool comes in.  As such you can create 100s of Connection objects but never actually use a real conn object and therefore pull from the pool.  The conn pool doesn't get used until you actually open the connection.  Note also that conn pool is based upon the connection string being used.  Each conn string gets its own pool.  Even something as minor as a case string conversion would generate a new conn pool.  As such getting an accurate meaning and count of the conn pool size may be fuzzy.  There are perf counters to track this.  Also MSDN has detailed info about all the ADO.NET parameters that you can read about if you are interested.

    Michael Taylor
    http://msmvps.com/blogs/p3net

    Monday, August 19, 2013 2:27 PM
    Moderator

All replies

  • With huge number of servers that forms database clusters and their dedicated web servers to serve request, and load balancing technologies and a bit DNS settings.

    How the database servers sync. data in the backscene is not something we ordinary programmers needs to worry about.

    Monday, August 19, 2013 10:38 AM
    Answerer
  • The actual # of simultaneous connections to a DB is not related to the # of users accessing a site at the same time. In most cases the DB query itself is very fast and, using proper scoping, the connection is only open for a fraction of the connection time.  20 is really low for a website but you probably wouldn't notice it unless your connections weren't being managed properly, you were writing queries that took seconds to execute or 100s of users hit it at once. 

    Max pool size controls the max # of underlying connections ADO.NET will create.  When the max is reached subsequent requests will block until a connection is available.  However do not confuse this with a Connection object.  Under the hood the actual connection is managed by ADO.NET.  A Connection object is a wrapper around the real connection which is where conn pool comes in.  As such you can create 100s of Connection objects but never actually use a real conn object and therefore pull from the pool.  The conn pool doesn't get used until you actually open the connection.  Note also that conn pool is based upon the connection string being used.  Each conn string gets its own pool.  Even something as minor as a case string conversion would generate a new conn pool.  As such getting an accurate meaning and count of the conn pool size may be fuzzy.  There are perf counters to track this.  Also MSDN has detailed info about all the ADO.NET parameters that you can read about if you are interested.

    Michael Taylor
    http://msmvps.com/blogs/p3net

    Monday, August 19, 2013 2:27 PM
    Moderator
  • Thank you ...after all get a answer that i was expecting..

    R_Sharma1989

    Friday, August 23, 2013 6:42 AM