[英]A SelfHosted WCF Service over Basic HTTP Binding doesn't support more than 1000 concurrent requests
我自己托管了ASMX Client
使用的BasicHttpBinding
的WCF服務。 我正在模擬1200個用戶的並發用戶負載。 service方法接受一個字符串參數並返回一個字符串。 交換的數據少於10KB。 通過Thread.Sleep(2000)語句將請求的處理時間固定為2秒。 沒什么別的。 我刪除了所有數據庫命中/業務邏輯。
同一條代碼可以運行1000個並發用戶。 當我將數字提升到1200個用戶時,我收到以下錯誤。
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at WCF.Throttling.Client.Service.Function2(String param)
此異常通常報告在DataContract不匹配和大數據交換上。 但從來沒有進行負載測試。 我已經瀏覽了很多,並嘗試了大多數選項,包括,
過去兩天我一直未能確定這個問題。
任何幫助,將不勝感激。
謝謝。
如果服務端WCF日志中沒有錯誤,我懷疑您在HTTP.SYS驅動程序層中遇到某種限制,導致請求在服務應用程序看到之前被拒絕。 我認為特定應用程序的請求隊列中的默認限制可能是1000。
我不是HTTP.SYS的專家,但你可以通過運行獲得一些見解:
netsh http show servicestate
我在不同的服務器上看到了類似的問題,具體取決於它們的CPU和RAM。 您沒有提到服務器類型,它是如何升級的(XP Pro或Server 2003升級到Server 2008)等。我解決問題的方法是通過檢查x:\\ Windows \\ Microsoft.NET \\ Framework [版本] \\ CONFIG \\ machine.config中。 顯然通過IIS選擇“無限制”連接並不意味着“無限制”連接。 我遇到的連接數在完全相同的毫秒之后的11個請求之后出錯了。
該問題與來自同一來源的連接數有關。 性能基准測試工具位於具有相同IP的同一台PC上。 machine.config包含對來自同一源的連接數的約束。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.