2011年10月28日 星期五

改善WCF效能

最近用到WCF Host in IIS,出現了效能瓶頸,原本以為是IIS所導致的,後來看了相關的文章後,才發現,其實透過WCF設定,就可以解決

在WCF中,可以設定連線數的部分,
在WCF的Behavior裡設定,主要有三個參數:
(1)MaxConcurrentSessions (WCF 3.0中,預設值10)
(2)MaxConcurrentCalls (WCF 3.0中,預設值16)
(3)MaxConcurrentInstances (WCF 3.0中,預設值26)

在WCF 3.0中,預設值並沒有針對這三個值做最佳化的計算,
而在WCF 4.0的設計中,改善了這個部份,預設值分別為:
(1)MaxConcurrentSessions: 100 * ProcessorCount
(2)MaxConcurrentCalls: 16 * ProcessorCount
(3)MaxConcurrentInstances: 前兩項的總和 (100*ProcessorCount + 16*ProcessorCount)