스레드 수

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

2016 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://go.microsoft.com/fwlink/?LinkId=799312

재정의 가능한 매개 변수

이름

설명

기본값

알림 우선 순위

알림 우선 순위를 정의합니다.

보통

알림 심각도

알림 심각도를 정의합니다.

오류

캐시 만료 시간

캐시에서 워크플로가 사용할 수 있는 정보의 최대 보존 기간을 지정합니다. 생략될 수 있습니다.

43200

사용

워크플로를 사용하거나 사용하지 않도록 설정합니다.

알림 생성

워크플로가 알림을 생성하는지를 정의합니다.

간격(초)

워크플로를 실행하는 반복 시간 간격(초)입니다.

300

최소 빈 스레드 수 임계값

워크플로는 각 DB 엔진 프로세스의 최대 스레드 수 및 활성 스레드 수를 결정합니다. 빈 스레드 수가 이 매개 변수 이하인 경우 알림이 생성됩니다.

10

샘플 수

상태가 변경되기 전 측정된 값이 임계값을 위반한 횟수를 나타냅니다.

6

동기화 시간

24시간 형식으로 지정된 동기화 시간입니다. 생략될 수 있습니다.

00:18

제한 시간(초)

워크플로를 닫고 실패로 표시하기 전에 워크플로를 실행할 수 있는 시간을 지정합니다.

200

Element properties:

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

Source Code:

<UnitMonitor ID="Microsoft.SQLServer.2016.DBEngine.ThreadCountMonitor" Accessibility="Public" Enabled="true" Target="SQL2016Core!Microsoft.SQLServer.2016.DBEngine" ParentMonitorID="SystemHealth!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.SQLServer.2016.DBEngine.ThreadCount.MonitorType" ConfirmDelivery="false">
<Category>PerformanceHealth</Category>
<AlertSettings AlertMessage="Microsoft.SQLServer.2016.DBEngine.ThreadCountMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SQL2016Core!Microsoft.SQLServer.2016.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="SQL2016Core!Microsoft.SQLServer.2016.DBEngine"]/ServiceName$</ServiceName>
<IntervalSeconds>300</IntervalSeconds>
<TimeoutSeconds>200</TimeoutSeconds>
<MinFreeThreadsCount>10</MinFreeThreadsCount>
<NumSamples>6</NumSamples>
<SyncTime/>
<CacheExpirationTime>43200</CacheExpirationTime>
</Configuration>
</UnitMonitor>