WCF服務在高負載下可能會變慢


KB2538826 解釋了WCF服務在突發的請求下會發生的問題:當您的 WCF 服務接收請求的突發時,默認.Net I/O 完成端口 (IOCP) 線程池可能不擴大需盡快和你 WCF 的響應時間會隨之增加。這篇文章《WCF scales up slowly with bursts of work》解釋了到底發生了什么。

解決方案是通過另一個線程池執行WCF服務,實施這一解決方案可能會產生少量的開銷。 每個WCF服務的性能測試結果會有所不同。

WCF Listener Recommended solution
HTTP Sync Module (Default in 3.x) - used in Integrated Application Pool Switch to the Async handler and then then apply the solution in this article or alternatively use a Private Threadpool (see links following this table)
HTTP Aync Module (Default in 4.x) - used in Integrated Application Pool Apply the code solution in this article
ISAPI - used in Classic Mode Application Pool Apply Private Threadpool (see links following this table)
tcp.Net Apply the code solution in this article

注意:應用此解決方案,當使用WCF偵聽器不會阻止傳入的線程在等待WCF服務的代碼來完成。

如果你按照上面的表在這篇文章中,無法應用的解決方案,使用在MSDN的文章一個專用線程池的例子:
Synchronization Contexts in WCF Juval Lowy將WCF中的同步環境 http://msdn.microsoft.com/zh-cn/magazine/cc163321.aspx

切換同步HTTP處理程序使用異步HTTP處理程序的步驟:

1.WCF調節閾值應高到足以處理預期的突發量在可接受的響應時間。
2. 如果你使用一個.NET CLR默認的線程池,工作人員或IOCP您的WCF服務,你必須確保最低限度的一個數字,你預計並發執行的線程數(價值開始創建線程的限制)。
3. 執行下面的代碼在您的服務將執行你的WCF服務的。NET CLR工作線程池。

 

Reusing Cookies in Different WCF Web Services

Less tweaking of your WCF 4.0 apps for high throughput workloads


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM