Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Connection Pooling nightmare - Timeout Expired

Connection Pooling nightmare - Timeout Expired

Scheduled Pinned Locked Moved Database
helpcssdatabasedesignsysadmin
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Guy Harwood
    wrote on last edited by
    #1

    In the 12 years ive been developing software ive never been so stumped on one issue for so long... I took over the design of the companies web application from my boss. I tidied up 75% of the code and now have a pretty tidy way of doing things as follows... each page inherits a page called 'basePage', this has all the necessary functions in it for data manipulation, such as... GetConnection() as SqlConnection (returns it unopened but populated with the connection string) GetDataTable(sql as string) as DataTable ExecuteQuery(sql as string) as integer etc... Recently we started getting "Timeout Expired" errors "while obtaining a connection from the pool". Ive tried various extremities of parameters in the connection string such as "min pool size=5;max pool size=1000;connect timeout=90;". and have read numerous articles on the subject. I have also turned off connection pooling entirely and still receive the same error (differing only by not mentioning "the pool"). Before you ask - yes, i am using try catch blocks in my basepage functions and always closing and disposing my objects in the finally block. Today i received no less than 840 timeout error reports on the server in one hour - there was only 46 people using the application at the most within that hour. The timeouts seem to happen all at once for a few minutes, like a big bottleneck. The server itself was running fine - not even brushing 50% cpu usage. But the web application itself would slow down quite badly, taking up to a minute to serve the page. I set up some tracing and noticed that some pages made no less than 60 calls per page load to the GetConnection() method :wtf: This is due to various business objects being called and checking data etc... Before i even suggest that any of the business model be redesigned, id like to ask.. has anyone ever come across this type of situation before? are most of you spitting coffee on your monitor over the 60 page calls like i nearly did? :sigh: or have you seen this before in big applications with many components? Any help, comments or suggestions are welcomed. Regards, Guy

    ---Guy H (;-)---

    C 1 Reply Last reply
    0
    • G Guy Harwood

      In the 12 years ive been developing software ive never been so stumped on one issue for so long... I took over the design of the companies web application from my boss. I tidied up 75% of the code and now have a pretty tidy way of doing things as follows... each page inherits a page called 'basePage', this has all the necessary functions in it for data manipulation, such as... GetConnection() as SqlConnection (returns it unopened but populated with the connection string) GetDataTable(sql as string) as DataTable ExecuteQuery(sql as string) as integer etc... Recently we started getting "Timeout Expired" errors "while obtaining a connection from the pool". Ive tried various extremities of parameters in the connection string such as "min pool size=5;max pool size=1000;connect timeout=90;". and have read numerous articles on the subject. I have also turned off connection pooling entirely and still receive the same error (differing only by not mentioning "the pool"). Before you ask - yes, i am using try catch blocks in my basepage functions and always closing and disposing my objects in the finally block. Today i received no less than 840 timeout error reports on the server in one hour - there was only 46 people using the application at the most within that hour. The timeouts seem to happen all at once for a few minutes, like a big bottleneck. The server itself was running fine - not even brushing 50% cpu usage. But the web application itself would slow down quite badly, taking up to a minute to serve the page. I set up some tracing and noticed that some pages made no less than 60 calls per page load to the GetConnection() method :wtf: This is due to various business objects being called and checking data etc... Before i even suggest that any of the business model be redesigned, id like to ask.. has anyone ever come across this type of situation before? are most of you spitting coffee on your monitor over the 60 page calls like i nearly did? :sigh: or have you seen this before in big applications with many components? Any help, comments or suggestions are welcomed. Regards, Guy

      ---Guy H (;-)---

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Guy Harwood wrote:

      I set up some tracing and noticed that some pages made no less than 60 calls per page load to the GetConnection() method

      Is the code closing the connection before getting another?

      Guy Harwood wrote:

      are most of you spitting coffee on your monitor over the 60 page calls like i nearly did?

      You might want to see if you can rationalise some of these calls. For example, if you alwasy call the same three stored procedures in sucession then you might be able to create a wrapper stored procedure that calls the other three so you can only doing one call to the database. You can then iterate over the result sets and pull out multiple sets of data from one database call. (If you are using DataReaders the NextResult() method is the one that moves to the next result set) The thing that causes the most slow down in an application is roundtrips to the database. If you can reduce the number of roundtrips it would improve performance, and reduce the number of connections you are making. I'll also admit that I've never had to alter the timeout of the connection from the 15 second default. By the way, what edition of SQL Server are you using?


      Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

      G 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Guy Harwood wrote:

        I set up some tracing and noticed that some pages made no less than 60 calls per page load to the GetConnection() method

        Is the code closing the connection before getting another?

        Guy Harwood wrote:

        are most of you spitting coffee on your monitor over the 60 page calls like i nearly did?

        You might want to see if you can rationalise some of these calls. For example, if you alwasy call the same three stored procedures in sucession then you might be able to create a wrapper stored procedure that calls the other three so you can only doing one call to the database. You can then iterate over the result sets and pull out multiple sets of data from one database call. (If you are using DataReaders the NextResult() method is the one that moves to the next result set) The thing that causes the most slow down in an application is roundtrips to the database. If you can reduce the number of roundtrips it would improve performance, and reduce the number of connections you are making. I'll also admit that I've never had to alter the timeout of the connection from the 15 second default. By the way, what edition of SQL Server are you using?


        Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

        G Offline
        G Offline
        Guy Harwood
        wrote on last edited by
        #3

        Hi Colin, Yes the code always closes the connection before getting another. Ive used the nextresult() stuff before, very handy and will come in useful when i end up knocking down those 60 calls per page load! We are using SQL Server 2000 with SP4 on 2003 server. The server has 3GB ram and 2 Xeon 2.4GHZ processors (effectively 4 cpus according to sql server). I did notice something odd in the event viewer application log earlier that was entered right about the time the errors started pouring in... Error: 15457, Severity: 0, State: 1 Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install. :confused: wasnt doing any maintenance and never seen it before.

        ---Guy H (;-)---

        S 1 Reply Last reply
        0
        • G Guy Harwood

          Hi Colin, Yes the code always closes the connection before getting another. Ive used the nextresult() stuff before, very handy and will come in useful when i end up knocking down those 60 calls per page load! We are using SQL Server 2000 with SP4 on 2003 server. The server has 3GB ram and 2 Xeon 2.4GHZ processors (effectively 4 cpus according to sql server). I did notice something odd in the event viewer application log earlier that was entered right about the time the errors started pouring in... Error: 15457, Severity: 0, State: 1 Configuration option 'show advanced options' changed from 1 to 1. Run the RECONFIGURE statement to install. :confused: wasnt doing any maintenance and never seen it before.

          ---Guy H (;-)---

          S Offline
          S Offline
          S Douglas
          wrote on last edited by
          #4

          Guy Harwood wrote:

          Error: 15457,

          If you Google “SQL Server 15457” there are quite a number of hits, would seem error code 15457 is an informational error code, but most of the people posing questions about this error code have the same issues you’re experiencing. Most of the issues seem to be related to the db getting locked or query time out values changed. Might want to take a look. http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20684322.html[^]


          I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

          G 1 Reply Last reply
          0
          • S S Douglas

            Guy Harwood wrote:

            Error: 15457,

            If you Google “SQL Server 15457” there are quite a number of hits, would seem error code 15457 is an informational error code, but most of the people posing questions about this error code have the same issues you’re experiencing. Most of the issues seem to be related to the db getting locked or query time out values changed. Might want to take a look. http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20684322.html[^]


            I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

            G Offline
            G Offline
            Guy Harwood
            wrote on last edited by
            #5

            For some stupid reason i never looked this up :doh: seems a restart solved the problem. gonna look into it more and see what i find. thanks everyone :)

            ---Guy H (;-)---

            S 1 Reply Last reply
            0
            • G Guy Harwood

              For some stupid reason i never looked this up :doh: seems a restart solved the problem. gonna look into it more and see what i find. thanks everyone :)

              ---Guy H (;-)---

              S Offline
              S Offline
              S Douglas
              wrote on last edited by
              #6

              Guy Harwood wrote:

              seems a restart solved the problem.

              :cool: Hope it works out for yea.


              I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups