📜 ⬆️ ⬇️

Tuning typical roles of Windows. Part One: Files and Printing


We are starting a small series of articles devoted to tuning the performance of a Windows server and its typical roles. The material will be useful both when trying to squeeze the maximum out of the old server (besides painting red), and when planning new high-load systems without buying top-end servers (as integrators advise).


General recommendations for iron


The processor is like the heart of the server, so much depends on it in terms of performance. Thanks to marketers, we know - the more cores and megahertz, the steeper. In fact, everything is not quite so:


  1. Choose a 64-bit processor. Modern server Windows do not support 32-bit processors, and it can address the memory much more.


  2. The number of cores is not a big deal. Not all applications and services can use multiple cores, and in the general case one core with a higher frequency will be more efficient than two with a smaller one.


  3. Hyperthreading - Hyperthreading - when one physical core of a processor is defined as two logical ones. The processor function allows you to process two different threads on the same core, which generally improves performance. But it happens that the performance on the contrary is reduced due to the fact that the cache of the processor core is one.


  4. CPU cache. Everything is simple: the more it is, the better, and often a larger cache gives more performance than the frequency of the processor.


  5. No need to compare processors of different generations and manufacturers in terms of frequency: data processing speed depends on many other factors, such as cache and bus frequency.


  6. For Hyper-V, it is important that the processor supports SLAT (Second Level Address Translation). In Intel terminology, the capability is called Extended Page Tables (EPT), for AMD - Nested Page Tables (NPT). You can check the availability of this processor function using the systeminfo.exe utility.


Check processor under Hyper-V requirements.


With RAM, everything is quite simple: the bigger and faster it is, the better. It becomes a little more interesting if the RAM is not enough and the system needs to use the paging file. Here you can limit the following recommendations:




Placing a paging file on the system disk is not the best option.


Now about network adapters. Of the interesting features can be noted:


  1. Only adapters that support 64-bit systems have DMA (Direct Memory Access), a technology of direct memory access over the network. If you need a really fast network between the nodes of the cluster, you should pay attention to it.


  2. Multiport adapters are convenient for load balancing and fault tolerance. But 2 adapters with one port will be faster than one adapter with 2 ports. You also need to keep in mind that installing more network adapters than cores in the server is fraught with a drop in performance.


HPE ProLiant DL360 Gen7 initially has four network ports.


This concludes a small introductory and will go directly to the optimization of server roles. Let's start with the simplest - with a file server.


File server


Usually, when installing and running a file server, the performance issue is not. But only as long as databases, monstrous Excel files and the like "interesting" things start up on a regular file storage facility. I'll tell you about the parameters that can improve or degrade the performance of SMB.


Separately, I note the issue of server speed, which processes not only clients inside the local network, but also remote ones - for example, via VPN. Personally, I came across a situation when computers started to appear on the network on Windows XP \ 2003 on Windows 7 \ 2008. Then we are faced with the fact that the speed of the network of new computers leaves much to be desired when communicating with old operating systems. Having read the Internet, we performed the following script on new machines:


netsh int tcp set global autotuning=disabled netsh int tcp set global autotuninglevel=disabled netsh int tcp set global rss=disabled chimney=disabled 

The network has earned, the script has been added to the deployed image systems.


And everything was fine until a remote segment appeared on the network with an increased demand for network speed. Files transferred via VPN are not faster than 2 Mb / s. The problem was localized: it turned out that the autotuning function was added specifically for work on LAN \ WAN networks in new operating systems. Using it, the systems determine the connection speed and agree on the TCP frame sizes for optimal performance. In order for VPN to work quickly, and the servers did not slow down when accessing Windows 2003, it was enough not to turn off autotuning , but limit it to the command:


 netsh int tcp set global autotuninglevel=highlyrestricted 

But let's move on to more specialized parameters.


Remember that changes to registry settings and service settings can lead to anything. Therefore, we do everything carefully.


Let's start with tuning file server clients. LanmanWorkstation is responsible for connecting to the SMB server. Most of the settings are in the following registry branch:


 HKLM\System\CurrentControlSet\Services\LanmanWorkstation\Parameters 

Most of the parameters are of type REG_DWORD. In modern Windows, management of some of the settings is possible via the Set-SmbClientConfiguration cmdlet . View current values ​​— respectively, Get-SmbClientConfiguration .



SMB client parameter values.


Parameters that should be paid attention first of all in terms of speed:


Parameter nameDefault valueValue optionsWhat is responsibleComment
DisableBandwidthThrottling00―1Enable - Disable Throttling for high latency networksEnabling this option can increase network bandwidth with high latency (WAN)
FileInfoCacheEntriesMax641―65536Maximum number of values ​​in the file metadata cacheIncreasing this setting reduces traffic and increases network bandwidth when accessing a large number of files.
DirectoryCacheEntrySizeMax641―65536Maximum cache size for directoriesMeasured in kilobytes
FileNotFoundCacheEntriesMax1281―65536Maximum number of values ​​in the file information cacheIncreasing this setting reduces traffic and increases network bandwidth when accessing a large number of files.
MaxCmds501―65536Maximum number of commands per sessionIncreasing the parameter will increase the memory consumption, but will increase the speed. Only for SMB v1
DormantFileLimit10231―65536Maximum number of files that can be opened after being "released" by the application
ScavengerTimeLimitten0―127How often does the garbageman run, clearing the file descriptor cacheMeasured in seconds, relevant for Windows XP \ 2003

As an example of tuning, we can cite the following values:



Of course, specifically these values ​​- not a panacea. Parameters must be selected individually.


With other parameters that have less impact on performance, I suggest to get acquainted under the spoiler.

Parameters configured via powershell and registry:


Parameter nameDefault valueValue optionsWhat is responsibleComment
ConnectionCountPerNetworkInterfaceone1―16Maximum number of connections to the server with non-RSS interfaceMS does not recommend changing the default value.
ConnectionCountPerRssNetworkInterfacefour1―16Maximum number of connections to the server with RSS interface
ConnectionCountPerRdmaNetworkInterface21―16Maximum number of connections to the server with an interface with RDMA support
MaximumConnectionCountPerServer321―64Maximum number of connections to one server
DormantDirectoryTimeout600Maximum amount of directory processing timeMeasured in seconds
FileInfoCacheLifetimetenCache information storage time
DirectoryCacheLifetimetenTime to store directory metadata in cache
FileNotFoundCacheLifetimefiveCache retention time for files not found
CachefiletimetenCache storage time for a file after the file is “released” by the application
DisableLargeMtu0 (win8)0―1Enable ― disable large MTUWith the enabled option, the request size is limited to 64 KB, with the enabled option - 1 MB.
RequireSecuritySignature00―1Enable ― Disable SMB Signature MandatoryEnabling this option slows down the speed of operation, but increases protection against the MITM attack.
DirectoryCacheEntriesMaxsixteen1―4096Maximum number of values ​​in the directory information cacheIncreasing this setting reduces traffic and increases network bandwidth when accessing large directories.
Maxcredits128Maximum number of commands per sessionSame as MaxCmds, but for SMB v2

Parameters configured via powershell:


EnableMultiChannelone0―1Enable ― disable the use of multiple physical adapters
EnableByteRangeLockingOnReadOnlyFilesTrueTrue \ FalseEnable ― Disable Read-Only File Locking
EnableInsecureGuestLogonsTrueTrue \ FalseEnable ― disable guest login to resourceDisconnection will not allow accessing folders on a non-home server (NAS) without authorization to the shared folders for all.
EnableLoadBalanceScaleOutTrueTrue \ FalseEnable — Disable support for load sharing when connecting to a cluster.
EnableSecuritySignatureTrueTrue \ FalseEnable ― Disable SMB Signature Capability
ExtendedSessionTimeout1000Server timeoutMeasured in seconds
Keepconn600Time to close inactive sessionMeasured in seconds, applicable only to SMB v1
OplocksDisabledFalseTrue \ False
Switched automatically depending on the value of the parameter UseOpportunisticLocking
Sessiontimeout60Time to close inactive sessionMeasured in seconds
UseOpportunisticLockingTrueTrue \ FalseEnable ― disable flexible locking (oplock) of files with their bufferingThe included mechanism greatly increases the speed, but on unreliable networks can damage files
Windowseize threshold1 for server systems, 8 for client systemsMinimum window size before Multichannel mode

If we speak directly about the file server, here are some general recommendations:


  1. For better performance, do not use unnecessary functions like file system mini-filters, IPSec, NTFS encryption and compression, SMB encryption, and others. The inclusion of an antivirus can significantly spoil the speed, and if the network perimeter is protected, it is better not to install it.


  2. You should regularly check the relevance of drivers, especially on network cards. There were situations when, due to driver curves, the network card worked stably only when forcing one hundred megabits. And only with the release of fresh drivers managed to squeeze a full gigabit.


  3. Copying files is a fairly regular operation for a file server. When copying over the network, it is preferable to use the utility robocopy.exe with the / mt key, which includes multithreading for a large number of small files. A bit of speed will be added by the lack of output to the console - the / log key for robocopy and / q for xcopy.

To assess the performance of the SMB protocol, you can use performance counters that exist for both the server and the client.


Let me remind you how to see them.

The perfmon.exe utility will help here. After launch, it is convenient to switch the display to the “report” mode:



Then you need to add the necessary performance counters. For example, add the “SMB Server Shares” counter by clicking on the green plus, choosing the counter and share we need:



And enjoy the result:



I recommend reading the Microsoft blog more fully with the procedure for using performance counters, collecting and analyzing results.


We turn to tuning. The Lanmanserver service is responsible for the operation of the SMB server, so part of the parameters can be changed in the corresponding registry branch:


 HKLM\System\CurrentControlSet\Services\LanmanServer\Parameters. 

It is more convenient, of course, to use the Set-SmbServerConfiguration cmdlet .



Displaying parameter values ​​using the Get-SmbServerConfiguration cmdlet.


Parameters that should be paid attention first of all:


Parameter nameDefault valueParameter typeWhat is responsibleComment
Smb2CreditsMax8192uint32Maximum number of SMB v2 commandsThese two parameters allow you to dynamically distribute the load. Sometimes when using high-speed channels with high latency (WAN), changing these parameters will increase the speed. To see if there are any problems, help the performance counter “SMB Client Total Resources - Credit Delays / c”
Smb2CreditsMin512uint32Minimum number of SMB v2 commands
MaxThreadsPerQueue20unit32Maximum number of server threads when processing simultaneous requestsIncreasing the parameter affects the hardware boot, but increases performance. The indicator to change a parameter can be the value of the performance counter “Server Work Queues - Queue Length - SMB2 NonBlocking” becomes more than 100.
Asynchronouscredits512uint32Maximum number of simultaneous asynchronous commands in one sessionIn some cases, for example, when using a loaded web server, increasing the value of the parameter increases performance
MaxMpxCt50uint32Maximum number of outstanding client requests for each clientAffects only SMB v1 clients

There is another registry entry that is not controlled by the powershell cmdlet:



This parameter is responsible for additional workflows responsible for writing and reading in the system cache of the file system. By default, there are no additional processes, and changing this parameter can significantly speed up the operation of the file server. Especially in the presence of multi-core processors and productive disk system. You can think about increasing this parameter while the “Cache -“ Dirty ”page performance counter grows.


An example of tuning is the following parameter values:



Values ​​must also be selected individually.


I propose to read about other parameters under the spoiler.
Parameter nameDefault valueParameter typeWhat is responsibleComment
AnnounceCommentnullstringServer view
AnnounceServerFalsebooleanEnable - Disable Server View
AuditSmb1AccessFalsebooleanEnable - Disable SMB Access Audit v1The parameter appeared only in Windows 10 \ 2016
AutoDisconnectTimeout15uint32The time after which the inactive session is disconnected
AutoshareserverTruebooleanEnable - disable default server network resources
AutoShareWorkstationTruebooleanEnable — Disables the network resources of the default workstation.
CachedOpenLimittenuint3Maximum number of open files in cache
DurableHandleV2TimeoutInSeconds180uint32Disable inactive handle timeout
EnableAuthenticateUserSharingFalsebooleanEnable — Disable Connection Sharing
EnableDownlevelTimewarpFalsebooleanEnable - Disable Low Level Time Distortion
EnableForcedLogoffTruebooleanEnable - Disable forced exit
EnableLeasingTruebooleanEnable - Disable Rent
EnableMultiChannelTruebooleanEnable — Disable the use of multiple physical adapters.
EnableOplocksTruebooleanEnable - Disable flexible locks (oplock)
EnableSecuritySignatureFalsebooleanEnable - Disable SMB Signature Capability
EnableSMB1ProtocolTruebooleanEnable - Disable SMB v1 protocol
EnableSMB2ProtocolTruebooleanEnable - Disable SMB v2 + Protocol
EnableStrictNameCheckingTruebooleanEnable - Disable incoming connection check
EncryptDataFalsebooleanEnable — Disable data encryption support.
IrpStackSize15unit32The size of the stack IRP (I / O requests)
KeepAliveTime2unit32TCP keepalive request rate for SMB connection
MaxChannelPerSession32unit32The number of channels in one session
MaxMpxCount50unit32Maximum number of commands per sessionThe parameter must be configured the same way as the MaxCmds client parameter
MaxSessionPerConnection16384unit32Maximum number of sessions in one connection
MaxWorkItemsoneuint32Maximum number of work itemsThis parameter affects SMB v1 only.
NullSessionPipesnullstringChannels available in zero session
NullSessionSharesnullstringNetwork resources available in zero session
OplockBreakWait35uint32Timeout before interruption of the lock
PendingClientTimeoutInSeconds120uint32Client waiting time
RejectUnencryptedAccessTruebooleanEnable — Disable unencrypted access requests.
RequireSecuritySignatureFalsebooleanEnable — Disable SMB Signature MandatoryEnabling this option slows down the speed of operation, but increases protection against the MITM attack.
ServerHiddenTruebooleanEnable - Disable Server ViewBy default, the server does not present itself.
SmbServerNameHardeningLevel0uint32Server Name Simplification Level
TreatHostAsStableStorageFalsebooleanEnable — Disable Trusted Disk StorageEnabling this option tells the server about the reliability of disk storage, it is worth including it when working with a disk with a non-volatile write cache. Then the server will not wait for confirmation to write to the disk, which will speed up performance.
ValidateAliasNotCircularTruebooleanEnabling - disabling the use of aliases
ValidateShareScopeTruebooleanEnable — Disable resource name checking when creating a new resource.
ValidateShareScopeNotAliasedTruebooleanEnabling - disabling the checking of resource aliases when creating a new resource
ValidateTargetNameTruebooleanEnable - disable checking the name of the target resource when creating an alias

I repeat: changing the parameters can lead to server malfunction. Therefore, it is better to first "practice on cats." Or at least make backups.


I turn to the next, seemingly simple role - the print server.


Print server


In addition to the recommendations of the "faster, higher, stronger" in terms of hardware, you need to note several other interesting points.


Transferring a print queue to a non-system disk will greatly increase server performance. This is done in the properties of the print server, in the "advanced settings" tab.



Setting the location of the print queue.


Whenever possible it is better to draw tasks on the client . In this case, the client will translate the document into a special format for printing (PDL). The server will not waste resources on this conversion.


By default, this feature is already enabled; you can turn it on ― by using Group Policy for all printers. Printers can be individually configured using the command


 printui /Xs /n "printer" ClientSideRender disabled 

It makes sense to turn off rendering on the client with a sufficient margin of print server performance to offload clients.


Printers with XPS (OpenXPS) support put less pressure on the server than printers without it. Printers with PCL 6 and Postscript support are a bit less efficient because of the vector format. Therefore, when choosing a printer is better to choose with support for XPS, and install the appropriate driver.


With the release of Windows 8 \ 2012, there is support for print drivers v4 . The 4th version drivers are more productive, but Windows 7 will print on the fourth type driver, drawing tasks on the client. Therefore, if there are still old Windows on the network, it is worthwhile to install third type drivers. You can look at the driver type in the print server properties on the Drivers tab:



Installation window for additional drivers.


If we talk about the capabilities of drivers of the fourth type, then these include:



Branch Office technology also deserves attention . With its help, the client works with the printer directly, bypassing any processing on the print server. True, you will need printers with support for TCP \ IP or WSD. You can learn more about the technology on the Microsoft website, and you can enable or disable it for a specific printer using the powershell cmdlet:


 Set―Printer ―name <printername> ―ComputerName <computername> ―RenderingMode BranchOffice 

The technology does not work if print processing is used on the server.


To diagnose bottlenecks when printing, pay attention to three processes:



And also look at the expense of these processes of memory, processor and hard disk load. For a more subtle search for bottlenecks, special performance counters will help.



A set of typical print subsystem performance counters.


List of counters with explanations - under the spoiler.
TitleDescription
Total jobs printedNumber of jobs printed
Total pages printedNumber of pages printed
Call Add Network PrinterNumber of connections to the shared printer since the last restart of the service
TasksNumber of jobs printed since the last service restart
Jobs Handled by the Print ManagerThe current number of jobs in the print service
Maximum jobs processed by the dispatcherMaximum number of jobs in print service
Maximum linksThe maximum number of accesses to the print queue
Task errorsNumber of job errors
Errors "Missing Paper"The number of errors caused by the lack of paper
Errors "The printer is not ready"Number of printer errors
Printable bytes / cThe speed of the current printing in bytes, allows you to approximately estimate the time the printer is busy
LinksThe current number of accesses to the print queue

In general, selecting parameters for a specific situation can improve the performance of these simple roles up to 50%. A refurbished server will still give light to modern monsters with the default settings.


Tell us in the comments about the performance improvement of any Windows roles you would be interested to read. Have you ever been involved in tuning roles and services? What results have been achieved?


')

Source: https://habr.com/ru/post/332600/


All Articles