我有几个ASP.NET应用程序部署在一个农场的4 Windows 2003机器。每个应用程序在IIS中使用单独的应用程序池和虚拟目录。它们严重依赖于在单个sql Server 2000(< sessionstate mode =“sqlserver”... />)上持久化的会话。应用程序是针对.NET 3.0编译的,但是.NET 3.5 SP1安装在服务器上。
每个Web服务器接收大约10个请求/秒。每隔一段时间我在日志中得到一些例外:
System.Data.sqlClient.sqlException: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider,error: 0 - The semaphore timeout period has expired.) at System.Data.sqlClient.sqlConnection.OnError(sqlException exception,Boolean breakConnection) at System.Data.sqlClient.sqlInternalConnection.OnError(sqlException exception,Boolean breakConnection) at System.Data.sqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.sqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj,UInt32 error) at System.Data.sqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult,TdsParserStateObject stateObj) at System.Data.sqlClient.TdsParserStateObject.ReadNetworkPacket() at System.Data.sqlClient.TdsParserStateObject.ReadBuffer() at System.Data.sqlClient.TdsParserStateObject.ReadByte() at System.Data.sqlClient.TdsParser.Run(RunBehavior runBehavior,sqlCommand cmdHandler,sqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) at System.Data.sqlClient.sqlCommand.FinishExecuteReader(sqlDataReader ds,RunBehavior runBehavior,String resetOptionsString) at System.Data.sqlClient.sqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,Boolean returnStream,Boolean async) at System.Data.sqlClient.sqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method,DbAsyncResult result) at System.Data.sqlClient.sqlCommand.InternalExecuteNonQuery(DbAsyncResult result,String methodName,Boolean sendToPipe) at System.Data.sqlClient.sqlCommand.ExecuteNonQuery() at System.Web.SessionState.sqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context,String id,SessionStateStoreData item,Object lockId,Boolean newItem)
或其他:
System.Data.sqlClient.sqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider,error: 0 - An existing connection was forcibly closed by the remote host.) at System.Data.sqlClient.sqlConnection.OnError(sqlException exception,Boolean breakConnection) at System.Data.sqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.sqlClient.TdsParserStateObject.WriteSni() at System.Data.sqlClient.TdsParserStateObject.WritePacket(Byte flushMode) at System.Data.sqlClient.TdsParserStateObject.ExecuteFlush() at System.Data.sqlClient.TdsParser.TdsExecuteRPC(_sqlRPC[] rpcArray,Int32 timeout,Boolean inSchema,sqlNotificationRequest notificationRequest,TdsParserStateObject stateObj,Boolean isCommandProc) at System.Data.sqlClient.sqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,Boolean newItem)
或另一个:
System.Data.sqlClient.sqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.sqlClient.sqlInternalConnection.OnError(sqlException exception,TdsParserStateObject stateObj) at System.Data.sqlClient.sqlDataReader.ConsumeMetaData() at System.Data.sqlClient.sqlDataReader.get_MetaData() at System.Data.sqlClient.sqlCommand.FinishExecuteReader(sqlDataReader ds,DbAsyncResult result) at System.Data.sqlClient.sqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method) at System.Data.sqlClient.sqlCommand.ExecuteReader(CommandBehavior behavior,String method) at System.Data.sqlClient.sqlCommand.ExecuteReader() at System.Web.SessionState.sqlSessionStateStore.DoGet(HttpContext context,Boolean getExclusive,Boolean& locked,TimeSpan& lockAge,Object& lockId,SessionStateActions& actionFlags)
这些错误每天发生几次,持续约1-2分钟,然后消失。有没有人遇到这样的问题?你可以建议我做什么,以进一步跟踪问题?对我来说,它看起来更像是网络问题,而不是应用程序。是否可以在sql Server上的一些设置,无法处理这么多并发连接?任何建议将不胜感激。
更新: