1
votes

After moving a .NET based website (Dotnetnuke / DNN based) to a new server, I'm starting to see multiple errors when the app pool is recycled while the website becomes unavailable for a couple of minutes:

System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached

The error is at: System.Data.ProviderBase.DbConnectionFactory.TryGetConnection

On peak hours the error can occur hundreds of times in the eventlog and the website returns a generic "503 not available" error to the user (instead of the custom, user friendly version of the error page).

The web app is unchanged and has been working fine prior to moving, so I'm quite sure this is not due to bad coding leaving DB connections open. On the old server (and in local dev environment) the site will become unresponsive while recycling, i.e. the user waits 20-30 seconds until the site is up and running. No exceptions is thrown and definitely no end user errors.

The main difference between the new and old server environment is:

New:

  • One Hyper-V host with multiple virtual servers:
  • Windows Server 2019 with IIS 10 (virtual server)
  • SQL Server 2014 (virtual server)

Old:

  • A single Windows Server 2008 R2 with IIS 7.5
  • Local install of SQL Server 2014 directly on webserver

I suspect that it related to either a difference in how connections are handled to a remote SQL Server located on a separate server. Or perhaps it is related to the way IIS recycles the app pool causing an issue when spinning up a new instance of the web app while closing down the existing version.

Any ideas?

Edit:

I have tried increasing the max pool size by adding "Max Pool Size=500" to the connection string. No effect. Using perfmon to monitor the active number of connections when restarting the web app: It increases to around 80 connections (from around 25-30) during recycle. I.e. no where near the max pool size.

1

1 Answers

1
votes

An update: I didn't find the root cause of this issue, however it was solved by going back to a single-server setup instead of separating web and DB into two different servers.

SQL Server was installed directly on the webserver and the DB was moved. There has been no connection related errors since.