SMB 文件服务器的性能优化
时间:2023-12-26 15:07:01
SMB 文件服务器的性能优化Performance tuning for SMB file servers
4/14/2017
本文内容
SMB 配置注意事项SMB configuration considerations
不要使用您的文件服务器和客户端不需要的任何服务或功能。Do not enable any services or features that your file server and clients do not require. 可包括 SMB 签名、客户端缓存、文件系统小筛选器、搜索服务、计划任务NTFS 加密、NTFS 压缩、IPSEC、防火墙筛选器、Teredo 和 SMB 加密。These might include SMB signing, client-side caching, file system mini-filters, search service, scheduled tasks, NTFS encryption, NTFS compression, IPSEC, firewall filters, Teredo, and SMB encryption.
确保 BIOS 根据需要设置操作系统的电源管理模式,可能包括高性能模式或变更 C 状态。Ensure that the BIOS and operating system power management modes are set as needed, which might include High Performance mode or altered C-State. 确保安装了最新、最灵活、最快的存储和网络设备驱动程序。Ensure that the latest, most resilient, and fastest storage and networking device drivers are installed.
复制文件是文件服务器上常见的操作。Copying files is a common operation performed on a file server. Windows Server 内置文件复制实用工具可以使用命令提示符运行。Windows Server has several built-in file copy utilities that you can run by using a command prompt. 建议使用 Robocopy。Robocopy is recommended. 在 Windows Server 2008 R2 中引入, Robocopy 选项 Robocopy 可以在复制 使用多个线程显著提高远程文件的传输速度。Introduced in Windows Server2008R2, the /mt option of Robocopy can significantly improve speed on remote file transfers by using multiple threads when copying multiple small files. 还建议使用 /log 选项,重定向日志 NUL 减少控制台输出的设备或文件。We also recommend using the /log option to reduce console output by redirecting logs to a NUL device or to a file. 使用 Xcopy 时,建议将 /q 和 /k 将选项添加到现有参数中。When you use Xcopy, we recommend adding the /q and /k options to your existing parameters. 前者通过减少控制台输出来减少 CPU 开销,后者可减少网络流量。The former option reduces CPU overhead by reducing console output and the latter reduces network traffic.
SMB 性能优化SMB performance tuning
文件服务器的性能和可用性 tunings 在每个客户端和服务器之间协商取决于 SMB 协议,以及已部署的文件服务器功能。File server performance and available tunings depend on the SMB protocol that is negotiated between each client and the server, and on the deployed file server features. 目前可用的最高协议版本是 Windows Server 2016 和 Windows 10 中的 SMB 3.1.1。The highest protocol version currently available is SMB 3.1.1 in Windows Server 2016 and Windows 10. 可用于客户端 Windows PowerShell SMBConnection和 SMBSession | 检查网络使用情况 SMB 版本。 Get-SMBSession | FL服务器上的 FL。You can check which version of SMB is in use on your network by using Windows PowerShell Get-SMBConnection on clients and Get-SMBSession | FL on servers.
SMB 3.0 协议系列SMB 3.0 protocol family
SMB 3.0 在 Windows Server 2012 中引入,在 Windows Server 2012 R2 进一步加强 (SMB 3.02) 和 Windows Server 2016 (SMB 3.1.1) 。SMB 3.0 was introduced in Windows Server2012 and further enhanced in Windows Server2012R2 (SMB 3.02) and Windows Server 2016 (SMB 3.1.1). 本版引入了能显著提高文件服务器性能和可用性的技术。This version introduced technologies that may significantly improve performance and availability of the file server.
SMB 直通SMB Direct
SMB Direct 引入了将 RDMA 网络接口用于高吞吐量、低延迟和低延迟 CPU 利用能力。SMB Direct introduced the ability to use RDMA network interfaces for high throughput with low latency and low CPU utilization.
当 SMB 检测到支持 RDMA 当功能网络自动尝试时 RDMA 功能。Whenever SMB detects an RDMA-capable network, it automatically tries to use the RDMA capability. 但是,出于任何原因,SMB 不能使用客户端 RDMA 连接路径,直接使用 TCP/IP 连接。However, if for any reason the SMB client fails to connect using the RDMA path, it will simply continue to use TCP/IP connections instead. 与 SMB 直接兼容的一切 RDMA 所有接口都需要实现 TCP/IP 堆栈,并且 SMB 多通道可以感知到这一点。All RDMA interfaces that are compatible with SMB Direct are required to also implement a TCP/IP stack, and SMB Multichannel is aware of that.
Smb Direct 在任何 SMB 配置不是必要的,但对于那些希望减少延迟和 CPU 低利用率的用户总是建议使用 SMB 直通。SMB Direct is not required in any SMB configuration, but it' s always recommended for those who want lower latency and lower CPU utilization.
SMB 多通道SMB Multichannel
SMB 多通道允许文件服务器同时连接多个网络,并提供更高的吞吐量。SMB Multichannel allows file servers to use multiple network connections simultaneously and provides increased throughput.
有关 SMB 多通道详情请参考 部署 smb 多通道。For more info about SMB Multichannel, see Deploy SMB Multichannel.
SMB 横向扩展SMB Scale-Out
SMB 扩展允许集群配置中的扩展 SMB 3.0 共享显示在集群的所有节点中。SMB Scale-out allows SMB 3.0 in a cluster configuration to show a share in all nodes of a cluster. 利用此主动/主动配置,无需使用多卷、共享和集资源的复杂配置,就可以进一步缩放文件服务器集群。This active/active configuration makes it possible to scale file server clusters further, without a complex configuration with multiple volumes, shares and cluster resources. 最大共享带宽是所有文件服务器集群节点的总带宽。The maximum share bandwidth is the total bandwidth of all file server cluster nodes. 总带宽不再局限于单个集群节点带宽,而是取决于后备存储系统的容量。The total bandwidth is no longer limited by the bandwidth of a single cluster node, but rather depends on the capability of the backing storage system. 你可以通过添加节点来增加总带宽。You can increase the total bandwidth by adding nodes.
SMB 3.0 的性能计数器Performance counters for SMB 3.0
以下 SMB 性能计数器是在 Windows Server 2012 中引入的,并且在监视 SMB 2 和更高版本的资源使用情况时,它们被视为一组基本计数器。The following SMB performance counters were introduced in Windows Server 2012, and they are considered a base set of counters when you monitor the resource usage of SMB 2 and higher versions. 将性能计数器记录到本地原始 ( .blg) 性能计数器日志。Log the performance counters to a local, raw (.blg) performance counter log. 使用通配符 () 来收集所有实例的开销较低 * ,然后使用 Relog.exe 在后期处理过程中提取特定实例。It is less expensive to collect all instances by using the wildcard character (*), and then extract particular instances during post-processing by using Relog.exe.
SMB 客户端共享SMB Client Shares
这些计数器显示有关正在使用 SMB 2.0 或更高版本的客户端访问的服务器上的文件共享的信息。These counters display information about file shares on the server that are being accessed by a client that is using SMB 2.0 or higher versions.
如果你已熟悉 Windows 中的常规磁盘计数器,则可能会注意到某个相似性。If you' re familiar with the regular disk counters in Windows, you might notice a certain resemblance. 这不是意外情况。That' s not by accident. SMB 客户端共享性能计数器的设计与磁盘计数器完全匹配。The SMB client shares performance counters were designed to exactly match the disk counters. 这样一来,您就可以轻松地重复使用目前所用的应用程序磁盘性能优化指南。This way you can easily reuse any guidance on application disk performance tuning you currently have. 有关计数器映射的详细信息,请参阅 按共享客户端性能计数器博客。
SMB 服务器共享SMB Server Shares
这些计数器显示有关服务器上的 SMB 2.0 或更高版本的文件共享的信息。These counters display information about the SMB 2.0 or higher file shares on the server.
SMB 服务器会话SMB Server Sessions
这些计数器显示有关使用 SMB 2.0 或更高版本的 SMB 服务器会话的信息。These counters display information about SMB server sessions that are using SMB 2.0 or higher.
如果在服务器端 (服务器共享或服务器) 会话中打开计数器,则高 IO 工作负荷可能会对性能产生重大影响。Turning on counters on server side (server shares or server sessions) may have significant performance impact for high IO workloads.
继续密钥筛选器Resume Key Filter
这些计数器显示有关简历密钥筛选器的信息。These counters display information about the Resume Key Filter.
SMB 直接连接SMB Direct Connection
这些计数器衡量连接活动的不同方面。These counters measure different aspects of connection activity. 一台计算机可以具有多个 SMB 直接连接。A computer can have multiple SMB Direct connections. SMB 直接连接计数器将每个连接表示为一对 IP 地址和端口,其中,第一个 IP 地址和端口表示连接的本地终结点,第二个 IP 地址和端口表示连接的远程终结点。The SMB Direct Connection counters represent each connection as a pair of IP addresses and ports, where the first IP address and port represent the connection's local endpoint, and the second IP address and port represent the connection's remote endpoint.
物理磁盘、SMB、CSV FS 性能计数器关系Physical Disk, SMB, CSV FS performance counters relationships
有关物理磁盘、SMB 和 CSV FS (文件系统) 计数器如何相关的详细信息,请参阅以下博客文章: 群集共享卷性能计数器。For more info on how Physical Disk, SMB, and CSV FS (file system) counters are related, see the following blog post: Cluster Shared Volume Performance Counters.
SMB 文件服务器的优化参数Tuning parameters for SMB file servers
以下 REG _ DWORD 注册表设置可能会影响 SMB 文件服务器的性能:The following REG_DWORD registry settings can affect the performance of SMB file servers:
Smb2CreditsMin 和 smb2creditsmax 为Smb2CreditsMin and Smb2CreditsMax
HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters\Smb2CreditsMin
HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters\Smb2CreditsMax
默认值分别为512和8192。The defaults are 512 and 8192, respectively. 这些参数允许服务器在指定边界内动态地限制客户端操作并发。These parameters allow the server to throttle client operation concurrency dynamically within the specified boundaries. 某些客户端可能会提高吞吐量,增加并发限制,例如,通过高带宽、高延迟链路复制文件。Some clients might achieve increased throughput with higher concurrency limits, for example, copying files over high-bandwidth, high-latency links.
提示
在 Windows 10 和 Windows Server 2016 之前,根据网络延迟和信用使用情况,向客户端授予的信用额度将在 Smb2CreditsMin 和 Smb2creditsmax 为之间动态变化。Prior to Windows 10 and Windows Server 2016, the number of credits granted to the client varied dynamically between Smb2CreditsMin and Smb2CreditsMax based on an algorithm that attempted to determine the optimal number of credits to grant based on network latency and credit usage. 在 Windows 10 和 Windows Server 2016 中,SMB 服务器已更改为在请求达到配置的最大信用额度时无条件地授予信用额度。In Windows 10 and Windows Server 2016, the SMB server was changed to unconditionally grant credits upon request up to the configured maximum number of credits. 作为此更改的一部分,信用限制机制会在服务器处于内存压力下时减少每个连接的信用时段的大小。As part of this change, the credit throttling mechanism, which reduces the size of each connection's credit window when the server is under memory pressure, was removed. 触发限制的内核内存不足事件仅在服务器内存较低时发出信号 ( # A0 几 MB) 无法使用。The kernel's low memory event that triggered throttling is only signaled when the server is so low on memory (< a few MB) as to be useless. 由于服务器不再缩小信用时段,Smb2CreditsMin 设置不再是必需的,现已被忽略。Since the server no longer shrinks credit windows the Smb2CreditsMin setting is no longer necessary and is now ignored.
可以监视 SMB 客户端共享 \ 信用额度,以查看是否存在任何信用额度问题。You can monitor SMB Client Shares\Credit Stalls /Sec to see if there are any issues with credits.
AdditionalCriticalWorkerThreadsAdditionalCriticalWorkerThreads
HKLM\System\CurrentControlSet\Control\Session Manager\Executive\AdditionalCriticalWorkerThreads
默认值为0,表示不添加其他关键内核工作线程。The default is 0, which means that no additional critical kernel worker threads are added. 此值影响文件系统缓存用于预读和后写请求的线程数。This value affects the number of threads that the file system cache uses for read-ahead and write-behind requests. 如果引发此值,则可以在存储子系统中进行更多的排队 i/o,还可以提高 i/o 性能,尤其是在具有很多逻辑处理器和强大的存储硬件的系统上。Raising this value can allow for more queued I/O in the storage subsystem, and it can improve I/O performance, particularly on systems with many logical processors and powerful storage hardware.
提示
如果缓存管理器脏数据 (性能计数器缓存 \ 脏页) 的数量不断增长, (超过 ~ 25 ) % 的内存或系统正在执行大量同步读 i/o 操作,则可能需要增加此值。The value may need to be increased if the amount of cache manager dirty data (performance counter Cache\Dirty Pages) is growing to consume a large portion (over ~25%) of memory or if the system is doing lots of synchronous read I/Os.
MaxThreadsPerQueueMaxThreadsPerQueue
HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters\MaxThreadsPerQueue
默认值为 20。The default is 20. 增加此值会引发文件服务器可用于为并发请求服务的线程数。Increasing this value raises the number of threads that the file server can use to service concurrent requests. 当需要为大量活动的连接提供服务,并且硬件资源(例如存储带宽)足够时,增加该值可以提高服务器的可伸缩性、性能和响应时间。When a large number of active connections need to be serviced, and hardware resources, such as storage bandwidth, are sufficient, increasing the value can improve server scalability, performance, and response times.
提示
指示可能需要增加值的情况是,如果 SMB2 工作队列增长得非常大 (性能计数器 "服务器工作队列 \ 队列长度 \ SMB2 非阻止性 * " 的大小一直低于 ~ 100) 。An indication that the value may need to be increased is if the SMB2 work queues are growing very large (performance counter ‘Server Work Queues\Queue Length\SMB2 NonBlocking *' is consistently above ~100).
备注
在 Windows 10 和 Windows Server 2016 中,MaxThreadsPerQueue 不可用。In Windows 10 and Windows Server 2016, MaxThreadsPerQueue is unavailable. 线程池的线程数将为 "20 * NUMA 节点中的处理器数"。The number of threads for a thread pool will be "20 * the number of processors in a NUMA node".
AsynchronousCreditsAsynchronousCredits
HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters\AsynchronousCredits
默认值为 512。The default is 512. 此参数限制单个连接上允许的并发异步 SMB 命令数。This parameter limits the number of concurrent asynchronous SMB commands that are allowed on a single connection. 某些情况下 (例如,当存在具有后端 IIS 服务器的前端服务器时) 需要大量并发 (文件更改通知请求,尤其是) 。Some cases (such as when there is a front-end server with a back-end IIS server) require a large amount of concurrency (for file change notification requests, in particular). 此项的值可以增加以支持这些情况。The value of this entry can be increased to support these cases.
SMB 服务器优化示例SMB server tuning example
在许多情况下,以下设置可以优化计算机的文件服务器性能。The following settings can optimize a computer for file server performance in many cases. 所有计算机上的这些设置都不是最佳或最合适的。The settings are not optimal or appropriate on all computers. 应在应用各个设置之前评估其影响。You should evaluate the impact of individual settings before applying them.
参数Parameter
值Value
默认Default
AdditionalCriticalWorkerThreadsAdditionalCriticalWorkerThreads
6464
00
MaxThreadsPerQueueMaxThreadsPerQueue
6464
2020
SMB 客户端性能监视器计数器SMB client performance monitor counters