|
1 | 1 | --- |
2 | 2 | title: "Configure the max worker threads Server Configuration Option | Microsoft Docs" |
3 | 3 | ms.custom: "" |
4 | | -ms.date: "11/23/2017" |
| 4 | +ms.date: "04/14/2020" |
5 | 5 | ms.prod: sql |
6 | 6 | ms.prod_service: high-availability |
7 | 7 | ms.reviewer: "" |
@@ -41,43 +41,51 @@ ms.author: mikeray |
41 | 41 |
|
42 | 42 | ### <a name="Restrictions"></a> Limitations and Restrictions |
43 | 43 |
|
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 request 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. |
| 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. |
45 | 45 |
|
46 | 46 | ### <a name="Recommendations"></a> Recommendations |
47 | 47 |
|
48 | 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. |
49 | 49 |
|
50 | 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. |
51 | 51 |
|
52 | | -- The following table shows the automatically configured number of max worker threads for various combinations of CPUs and versions of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. |
53 | | - |
54 | | - |Number of CPUs|32-bit computer|64-bit computer| |
55 | | - |------------|------------|------------| |
56 | | - |\<= 4 processors|256|512| |
57 | | - |8 processors|288|576| |
58 | | - |16 processors|352|704| |
59 | | - |32 processors|480|960| |
60 | | - |64 processors|736|1472| |
61 | | - |128 processors|4224|4480| |
62 | | - |256 processors|8320|8576| |
| 52 | +- 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 | + |
| 54 | + |Number of CPUs|32-bit computer (up to [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)])|64-bit computer (up to [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] SP1)|64-bit computer (starting with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] SP2 and [!INCLUDE[ssSQL17](../../includes/sssql17-md.md)])| |
| 55 | + |------------|------------|------------|------------| |
| 56 | + |\<= 4|256|512|512| |
| 57 | + |8|288|576|576| |
| 58 | + |16|352|704|704| |
| 59 | + |32|480|960|960| |
| 60 | + |64|736|1472|2432| |
| 61 | + |128|1248|2496|4480| |
| 62 | + |256|2272|4544|8576| |
63 | 63 |
|
64 | | - Using the following formula: |
| 64 | + Up to [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] SP1, the *Workers per CPU* only depend on the architecture (32-bit or 64-bit): |
65 | 65 |
|
66 | | - |Number of CPUs|32-bit computer|64-bit computer| |
67 | | - |------------|------------|------------| |
68 | | - |\<= 4 processors|256|512| |
69 | | - |\> 4 processors and \<= 64 processors|256 + ((logical CPU's - 4) * 8)|512 + ((logical CPU's - 4) * 16)| |
70 | | - |\> 64 processors|256 + ((logical CPU's - 4) * 32)|512 + ((logical CPU's - 4) * 32)| |
| 66 | + |Number of CPUs|32-bit computer <sup>1</sup>|64-bit computer| |
| 67 | + |------------|------------|------------| |
| 68 | + |\<= 4|256|512| |
| 69 | + |\> 4|256 + ((logical CPU's - 4) * 8)|512 <sup>2</sup> + ((logical CPU's - 4) * 16)| |
| 70 | + |
| 71 | + Starting with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)] SP2 and [!INCLUDE[ssSQL17](../../includes/sssql17-md.md)], the *Workers per CPU* depend on the architecture and number of processors (between 4 and 64, or greater than 64): |
| 72 | + |
| 73 | + |Number of CPUs|32-bit computer <sup>1</sup>|64-bit computer| |
| 74 | + |------------|------------|------------| |
| 75 | + |\<= 4|256|512| |
| 76 | + |\> 4 and \<= 64|256 + ((logical CPU's - 4) * 8)|512 <sup>2</sup> + ((logical CPU's - 4) * 16)| |
| 77 | + |\> 64|256 + ((logical CPU's - 4) * 32)|512 <sup>2</sup> + ((logical CPU's - 4) * 32)| |
71 | 78 |
|
72 | | - > [!NOTE] |
73 | | - > [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] can no longer be installed on a 32-bit operating system. 32-bit computer values are listed for the assistance of customers running [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)] and earlier. We recommend 1,024 as the maximum number of worker threads for an instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] that is running on a 32-bit computer. |
| 79 | + <sup>1</sup> Starting with [!INCLUDE[ssSQL15](../../includes/sssql15-md.md)], [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] can no longer be installed on a 32-bit operating system. 32-bit computer values are listed for the assistance of customers running [!INCLUDE[ssSQL14](../../includes/sssql14-md.md)] and earlier. We recommend 1,024 as the maximum number of worker threads for an instance of [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] that is running on a 32-bit computer. |
| 80 | + |
| 81 | + <sup>2</sup> Starting with [!INCLUDE[ssSQL17](../../includes/sssql17-md.md)], the *Default Max Workers* value is divided by 2 for machines with less than 2GB of memory. |
74 | 82 |
|
75 | | - > [!NOTE] |
| 83 | + > [!TIP] |
76 | 84 | > For recommendations on using more than 64 CPUs, refer to [Best Practices for Running SQL Server on Computers That Have More Than 64 CPUs](../../relational-databases/thread-and-task-architecture-guide.md#best-practices-for-running-sql-server-on-computers-that-have-more-than-64-cpus). |
77 | 85 | |
78 | 86 | - 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. |
79 | 87 |
|
80 | | - The **max worker threads** server configuration option does not limit all threads that may be spanwed in the system. Threads required for tasks such as Availibility 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. |
| 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. |
81 | 89 |
|
82 | 90 | ```sql |
83 | 91 | SELECT s.session_id, r.command, r.status, |
|
0 commit comments