Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit d74c5c6

Browse files
authored
Merge pull request #15213 from PeterCLu/plu-update-max-worker
Content performance
2 parents 34dd280 + ae5abd4 commit d74c5c6

1 file changed

Lines changed: 35 additions & 43 deletions

File tree

docs/database-engine/configure-windows/configure-the-max-worker-threads-server-configuration-option.md

Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Configure the max worker threads Server Configuration Option | Microsoft Docs"
3-
ms.custom: ""
3+
ms.custom: "contperfq4"
44
ms.date: "04/14/2020"
55
ms.prod: sql
66
ms.prod_service: high-availability
@@ -17,37 +17,48 @@ ms.author: maghan
1717
# Configure the max worker threads Server Configuration Option
1818
[!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md](../../includes/appliesto-ss-xxxx-xxxx-xxx-md.md)]
1919

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. [!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.
3932

4033
## <a name="BeforeYouBegin"></a> Before You Begin
4134

4235
### <a name="Restrictions"></a> Limitations and Restrictions
4336

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+
SELECT s.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+
FROM sys.dm_exec_sessions AS s
47+
INNER JOIN sys.dm_exec_requests AS r
48+
ON s.session_id = r.session_id
49+
INNER JOIN sys.dm_os_tasks AS t
50+
ON r.task_address = t.task_address
51+
INNER JOIN sys.dm_os_workers AS w
52+
ON t.worker_address = w.worker_address
53+
WHERE s.is_user_process = 0;
54+
```
55+
4556

4657
### <a name="Recommendations"></a> Recommendations
4758

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).
4960

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.
5162

5263
- 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*)**.
5364

@@ -85,23 +96,6 @@ ms.author: maghan
8596
8697
- 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.
8798

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.
89-
90-
```sql
91-
SELECT s.session_id, r.command, r.status,
92-
r.wait_type, r.scheduler_id, w.worker_address,
93-
w.is_preemptive, w.state, t.task_state,
94-
t.session_id, t.exec_context_id, t.request_id
95-
FROM sys.dm_exec_sessions AS s
96-
INNER JOIN sys.dm_exec_requests AS r
97-
ON s.session_id = r.session_id
98-
INNER JOIN sys.dm_os_tasks AS t
99-
ON r.task_address = t.task_address
100-
INNER JOIN sys.dm_os_workers AS w
101-
ON t.worker_address = w.worker_address
102-
WHERE s.is_user_process = 0;
103-
```
104-
10599
### <a name="Security"></a> Security
106100

107101
#### <a name="Permissions"></a> Permissions
@@ -152,6 +146,4 @@ GO
152146
[Server Configuration Options &#40;SQL Server&#41;](../../database-engine/configure-windows/server-configuration-options-sql-server.md)
153147
[RECONFIGURE &#40;Transact-SQL&#41;](../../t-sql/language-elements/reconfigure-transact-sql.md)
154148
[sp_configure &#40;Transact-SQL&#41;](../../relational-databases/system-stored-procedures/sp-configure-transact-sql.md)
155-
[Diagnostic Connection for Database Administrators](../../database-engine/configure-windows/diagnostic-connection-for-database-administrators.md)
156-
157-
149+
[Diagnostic Connection for Database Administrators](../../database-engine/configure-windows/diagnostic-connection-for-database-administrators.md)

0 commit comments

Comments
 (0)