You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This topic describes how to configure the **max worker threads** server configuration option in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE[tsql](../../includes/tsql-md.md)]. The **max worker threads** option configures the number of worker threads that are available to [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] processes. [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] uses the native thread services of the operating systems so that one or more threads support each network that [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] supports simultaneously, another thread handles database checkpoints, and a pool of threads handles all users. The default value for **max worker threads** is 0. This enables [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] to automatically configure the number of worker threads at startup. The default setting is best for most systems. However, depending on your system configuration, setting **max worker threads** to a specific value sometimes improves performance.
21
-
22
-
**In This Topic**
23
-
24
-
-**Before you begin:**
25
-
26
-
[Limitations and Restrictions](#Restrictions)
27
-
28
-
[Recommendations](#Recommendations)
29
-
30
-
[Security](#Security)
31
-
32
-
-**To configure the max worker threads option, using:**
33
-
34
-
[SQL Server Management Studio](#SSMSProcedure)
35
-
36
-
[Transact-SQL](#TsqlProcedure)
37
-
38
-
-**Follow Up:**[After you configure the max worker threads option](#FollowUp)
20
+
This topic describes how to configure the **max worker threads** server configuration option in [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] by using [!INCLUDE[ssManStudioFull](../../includes/ssmanstudiofull-md.md)] or [!INCLUDE[tsql](../../includes/tsql-md.md)]. The **max worker threads** option configures the number of worker threads that are available to [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] processes.
21
+
22
+
23
+
[!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] uses the native thread services of the operating systems to ensure the following conditions:
24
+
25
+
- One or more threads simultaneously support each network that [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] supports.
26
+
27
+
- One thread handles database checkpoints.
28
+
29
+
- A pool of threads handles all users.
30
+
31
+
The default value for **max worker threads** is 0. This enables [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] to automatically configure the number of worker threads at startup. The default setting is best for most systems. However, depending on your system configuration, setting **max worker threads** to a specific value sometimes improves performance.
39
32
40
33
## <aname="BeforeYouBegin"></a> Before You Begin
41
34
42
35
### <aname="Restrictions"></a> Limitations and Restrictions
43
36
44
-
- When the actual number of query requests is less than the amount set in **max worker threads**, one thread handles each query request. However, if the actual number of query requests exceeds the amount set in **max worker threads**, [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] pools the worker threads so that the next available worker thread can handle the request.
37
+
- When the actual number of query requests is less than the amount set in **max worker threads**, one thread handles each query request. However, if the actual number of query requests exceeds the amount set in **max worker threads**, [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] pools the worker threads so that the next available worker thread can handle the request.
38
+
39
+
- The **max worker threads** server configuration option does not limit all threads that may be spawned in the system. Threads required for tasks such as Availability Groups, Service Broker, Lock Manager, or others are spawned outside this limit. If the number of threads configured is being exceeded, the following query will provide information about the system tasks that have spawned the additional threads.
40
+
41
+
```sql
42
+
SELECTs.session_id, r.command, r.status,
43
+
r.wait_type, r.scheduler_id, w.worker_address,
44
+
w.is_preemptive, w.state, t.task_state,
45
+
t.session_id, t.exec_context_id, t.request_id
46
+
FROMsys.dm_exec_sessionsAS s
47
+
INNER JOINsys.dm_exec_requestsAS r
48
+
ONs.session_id=r.session_id
49
+
INNER JOINsys.dm_os_tasksAS t
50
+
ONr.task_address=t.task_address
51
+
INNER JOINsys.dm_os_workersAS w
52
+
ONt.worker_address=w.worker_address
53
+
WHEREs.is_user_process=0;
54
+
```
55
+
45
56
46
57
### <aname="Recommendations"></a> Recommendations
47
58
48
-
- This option is an advanced option and should be changed only by an experienced database administrator or certified [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] professional. If you suspect that there is a performance problem, it is probably not the availability of worker threads. The cause is more likely something like I/O that is causing the worker threads to wait. It is best to find the root cause of a performance issue before you change the max worker threads setting.
59
+
- This option is an advanced option and should be changed only by an experienced database administrator or certified [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] professional. If you suspect that there is a performance problem, it is probably not the availability of worker threads. The cause is more likely something like I/O that is causing the worker threads to wait. It is best to find the root cause of a performance issue before you change the max worker threads setting. For more information on assessing performance, see [Monitor and tune for performance](../../relational-databases/performance/monitor-and-tune-for-performance.md).
49
60
50
-
- Thread pooling helps optimize performance when large numbers of clients are connected to the server. Usually, a separate operating system thread is created for each query request. However, with hundreds of connections to the server, using one thread per query request can consume large amounts of system resources. The **max worker threads** option enables [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] to create a pool of worker threads to service a larger number of query requests, which improves performance.
61
+
- Thread pooling helps optimize performance when a large number of clients connect to the server. Usually, a separate operating system thread is created for each query request. However, with hundreds of connections to the server, using one thread per query request can consume large amounts of system resources. The **max worker threads** option enables [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] to create a pool of worker threads to service a larger number of query requests, which improves performance.
51
62
52
63
- The following table shows the automatically configured number of max worker threads for various combinations of CPUs, computer architecture, and versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], using the formula: ***Default Max Workers* + ((*logical CPUs* - 4) * *Workers per CPU*)**.
53
64
@@ -85,23 +96,6 @@ ms.author: maghan
85
96
86
97
- When all worker threads are active with long running queries, [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] might appear unresponsive until a worker thread completes and becomes available. Although this is not a defect, it can sometimes be undesirable. If a process appears to be unresponsive and no new queries can be processed, then connect to [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] using the dedicated administrator connection (DAC), and kill the process. To prevent this, increase the number of max worker threads.
87
98
88
-
The **max worker threads** server configuration option does not limit all threads that may be spawned in the system. Threads required for tasks such as Availability Groups, Service Broker, Lock Manager, or others are spawned outside this limit. If the number of threads configured is being exceeded, the following query will provide information about the system tasks that have spawned the additional threads.
0 commit comments