2012-10-26 30 views
3

服務器1:SQL Server 2008標準版 服務器2:Windows 2008 Server的R2,IIS 7.0在重負載下IIS SQL連接失敗;重置IIS解決暫時

一個網站服務器2上要求服務器1.

一切都在SQL Server數據有一段時間(周有時)工作良好。然後,在負載很重的情況下,服務器2報告無法連接服務器1上的SQL Server。一旦服務器2上的IIS報告無法連接到服務器1上的SQL,直到服務器2上的IIS重新啓動後纔會好轉。也許重新啓動應用程序池可能會發生完全IIS重置。我不確定。

我試着改變連接字符串來增加連接池大小到不合理的大值(1,000)。失敗仍然發生。

該網站是用C#編寫的。數據訪問層是NHibernate。

這裏是例外的開始:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)] 
    System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +428 
    System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65 
    System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117 
    System.Data.SqlClient.SqlConnection.Open() +122 
    NHibernate.Connection.DriverConnectionProvider.GetConnection() +60 
    NHibernate.Impl.SessionFactoryImpl.OpenConnection() +39 

任何想法,爲什麼發生這種情況?如何診斷/修復它?我很沮喪,考慮剝離NHibernate,這將需要數月的時間,並可能導致許多其他類型的問題。

+0

您正在重複使用SessionFactory,並且正在處理會話嗎?使用sql server profiler來查看審計登錄和審計註銷,以查看新連接的打開和舊連接的關閉頻率。當然,池化應該是這樣,所以你不應該看到太多的開放,但如果你看到很多開放,很少關閉,那麼你可能會耗盡連接池。 –

回答

0

我認爲你必須增加連接超時值和連接池。這樣它就不會在重負載下釋放與SQL Server的連接。