WCF 웹 서비스 성능 최적화
WCF 서비스는 성능에 영향을 주는 수많은 구성 매개 변수를 노출합니다. 이 항목에서는 WCF 서비스의 성능을 향상시키기 위해 이러한 구성 매개 변수에 대한 최적 값을 설정하기 위한 일반적인 지침을 제공합니다.
백 엔드 WCF 서비스에 대한 serviceThrottling 동작 구현
백 엔드 WCF 서비스에 대한 serviceThrottling 동작을 구현합니다. 서비스 제한을 사용하면 백 엔드 WCF 서버의 부하를 균등화하고 리소스 할당을 적용할 수 있습니다. serviceThrottling 동작은 WCF 서비스의 구성 파일에서 maxConcurrentCalls, maxConcurrentSessions 및 maxConcurrentInstances 매개 변수 값을 수정하여 구성됩니다. maxConcurrentCalls, maxConcurrentSessions 및 maxConcurrentInstances를 16 * CPU 또는 CPU 코어 수보다 큰 값으로 설정합니다. 예를 들어 CPU 코어가 8개인 컴퓨터에서 maxConcurrentCalls, maxConcurrentSessions 및 maxConcurrentInstances 를 다음과 같이 128(16 * 8 = 128)보다 큰 값으로 설정합니다.
<serviceThrottling
maxConcurrentCalls="200"
maxConcurrentSessions="200"
maxConcurrentInstances="200" />
백 엔드 WCF 서비스 web.config 파일에서 NetTcpBinding.ListenBacklog 및 NetTcpBinding.MaxConnections 속성의 기본값을 늘입니다.
NetTcpBinding.ListenBacklog 속성은 웹 서비스에 대해 보류 중일 수 있는 대기 중인 연결 요청의 최대 수를 제어합니다. NetTcpBinding.MaxConnections 속성은 클라이언트에서 후속 재사용을 위해 풀링할 최대 연결 수와 서버에서 디스패치 보류 중인 최대 연결 수를 제어합니다. 이러한 각 속성은 특히 높은 처리량이 필요한 문서 처리 시나리오의 경우 최적이 아닐 수 있는 기본값 10을 사용합니다.
netTcpBinding 바인딩 클래스를 구현하는 WCF 서비스를 사용하는 처리량이 많은 문서 처리 시나리오에 대해 이러한 속성의 기본값을 늘리는 것이 좋습니다.
다음 예제에서는 listenBacklog 및 maxConnections 매개 변수가 모두 "200" 값으로 설정됩니다.
<netTcpBinding>
<binding name="netTcpBinding"
closeTimeout="00:10:00"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="200"
maxBufferPoolSize="1048576"
maxBufferSize="10485760"
maxConnections="200"
maxReceivedMessageSize="10485760">
<readerQuotas
maxDepth="32"
maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession
ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
NetTcpBinding.ListenBacklog 속성에 대한 자세한 내용은 NetTcpBinding.ListenBacklog 속성을 참조하세요.
NetTcpBinding.MaxConnections 속성에 대한 자세한 내용은 NetTcpBinding.MaxConnections 속성을 참조하세요.
WCF 웹 서비스를 실행할 필요가 없는 ASP.NET httpModules 제거
기본적으로 여러 ASP.NET httpModules는 IIS 6.0의 요청 파이프라인 및 IIS 7.5/7.0의 클래식 또는 통합 파이프라인에 정의됩니다. 이러한 구성 요소는 들어오는 모든 요청을 가로채고 처리합니다. 기본 모듈은 32비트 ASP.NET 애플리케이션의 %windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG 폴더에 포함된 web.config 파일과 64비트 ASP.NET 애플리케이션에 대한 %windir%\Microsoft.NET\Framework64\v2.0.50727\CONFIG 폴더에 정의됩니다. 다음 코드 조각에 표시된 대로 입니다.
<httpModules>
<add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
<add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/>
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/>
<add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/>
<add name="RoleManager" type="System.Web.Security.RoleManagerModule"/>
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/>
<add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/>
<add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule"/>
<add name="Profile" type="System.Web.Profile.ProfileModule"/>
<add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</httpModules>
대부분의 시나리오에서는 이러한 모듈을 모두 로드할 필요가 없습니다. 따라서 WCF 웹 서비스를 실행할 때 다음 httpModules를 제거하여 성능을 향상시킬 수 있습니다.
세션
WindowsAuthentication
FormsAuthentication
PassportAuthentication
RoleManager
AnonymousIdentification
프로필
비동기 WCF HTTP 모듈/처리기를 사용하여 IIS 7.5/7.0 호스팅 WCF 서비스의 확장성을 개선하는 방법에 대한 자세한 내용은 Wenlong Dong의 블로그 Orcas SP1 개선: IIS7용 비동기 WCF HTTP 모듈/처리기를 참조하세요.