스레드 수

Microsoft.SQLServer.2012.DBEngine.ThreadCountMonitor (UnitMonitor)

2012 DB 엔진의 스레드 수

Knowledge Base article:

요약

일반적으로 SQL Server는 각 쿼리 요청에 대해 시스템 스레드를 열지만, 스레드 양이 지정된 최대 작업자 스레드 값을 초과할 경우 SQL Server가 해당 작업자 스레드를 풀링합니다. 장기 실행 쿼리의 모든 작업자 스레드가 활성 상태이면 작업자 스레드가 완료되어 사용 가능 상태가 되기 전에는 SQL Server가 응답하지 않을 수 있습니다. 이는 오류는 아니지만 바람직한 상태는 아닙니다. 모니터가 비어 있는 스레드 양을 분석하고 양이 적으면 알림을 표시합니다.

원인

스레드 사용량을 증가시키는 작업량 증가는 SQL Server가 높은 부하에서 작동하고 있거나 병렬로 실행 중인 쿼리 수가 너무 많음을 의미할 수 있습니다.

해결 방법

max worker threads 조정은 고급 옵션으로, 숙련된 데이터베이스 관리자나 공인된 SQL Server 기술 지원 담당자만 변경해야 합니다.

스레드 풀링을 사용하면 많은 클라이언트가 서버에 연결되어 있을 때 성능이 최적화됩니다. 보통 각 쿼리 요청마다 별도의 운영 체제 스레드가 생성됩니다. 그러나 서버에 대한 연결 수가 수백 개인 경우 쿼리 요청별로 스레드를 하나씩 사용하면 시스템 리소스를 상당히 많이 소비하게 될 수 있습니다. max worker threads 옵션을 사용하면 SQL Server에서 작업자 스레드 풀을 만들어 많은 쿼리 요청을 처리할 수 있으므로 성능이 향상됩니다.

max worker threads 서버 구성 옵션 구성

http://msdn.microsoft.com/ko-kr/library/ms190219.aspx

Element properties:

TargetMicrosoft.SQLServer.2012.DBEngine
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityError
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SQLServer.2012.DBEngine.ThreadCount.MonitorType
RemotableTrue
AccessibilityPublic
Alert Message
SQL DB 2012 엔진 스레드 수가 너무 높음
"{1}" 컴퓨터에서 SQL 인스턴스 "{0}"의 스레드 수가 너무 높습니다. 자세한 내용은 "경고 컨텍스트" 탭을 참조하십시오.
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2012.DBEngine.ThreadCountMonitor" Accessibility="Public" Enabled="true" Target="SQL2012Core!Microsoft.SQLServer.2012.DBEngine" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2012.DBEngine.ThreadCount.MonitorType" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2012.DBEngine.ThreadCountMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL!Microsoft.SQLServer.ServerRole"]/InstanceName$</AlertParameter1>
<AlertParameter2>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Normal" MonitorTypeStateID="Normal" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ServiceName>$Target/Property[Type="SQL!Microsoft.SQLServer.DBEngine"]/ServiceName$</ServiceName>
<IntervalSeconds>300</IntervalSeconds>
<TimeoutSeconds>200</TimeoutSeconds>
<MinFreeThreadsCount>10</MinFreeThreadsCount>
<NumSamples>6</NumSamples>
</Configuration>
</UnitMonitor>