Lanmanserver and Lanmanworkstation Tuning |
Tuesday, 20 February 2007 by Michel Roth | |
IntroductionFileserving in Windows environments is usually of critical importance. After all, if you can't reach your files or have to wait five minutes every time you browse a share, the heat starts to build up in the IT department. File serving is more than just saving a file to your home directory. I wrote a two-part article on MSTerminalServices.org on file serving and Terminal server environments. I suggest you read that article (Part 1 and Part 2 ) first to get a feel for the proper context of this article. One of the main reasons I wrote that article is that fileserving can easily become a bottleneck if not configured properly, especially in Terminal Server environments. To solve these performance problems, you sometimes have to tune the fileserver (lanmanserver) and the "fileserver-client" (lanmanworkstation). However, this isn't for the faint of heart and can cause huge problems if you do it wrong. Unfortunately, documentation on these tuning parameters is rather scarce. So in this article, I'll try to explain what the important parameters are, what they do, and how they relate to each other. Once you know this, you'll be able to tune your fileserving environments yourself. Before we jump into this, please note that there are also a great deal optimizations that you can do in the "Terminal Server <--> Terminal Server Client" hemisphere. Although the basic fileserving principles also apply in that area, this article is not meant to help you perform those optimizations. Also, there is a lot of additional tweaking you can do in other parts of the (Terminal Server) registry. I've purposely left these optimizations out because I wanted this article to focus on the performance of Fileserving components only. This article was written assuming you're running Windows 2000 (SP4+) or Windows Server 2003, Service Pack 1.
Core Components Both the server and the client components are run as a service. Not surprisingly, this is the "Server" service for the server component and the "Workstation" service for the client components. Settings for these services are stored in the Windows registry. For the Server service this location is: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver. The corresponding location for the Workstation service is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanworkstation.
Lanmanserver The first sub key we encounter is the "AutotunedParameters" key. If you look at it you'll see that it's empty. Don't worry--it's supposed to be empty. This registry key exists because, by default, the Server service is auto-tuning. This means that every time the system boots, the server takes a look at the hardware configuration and incorporates any changes in the configuration of the Server service. Changes in hardware that are monitored are the amount of memory and the number of processors. There's even a formula for it: (4*(MB*SMBServerPerfSetting)*OSVersion/1)*(#Processors) where:
MB = Megabytes RAM on the server In the formula you'll notice that it refers to the SMBServerPerfSetting. This brings us to the only GUI ‘tool" native to Windows that you can use to "tune" the Server service. When you select the properties of a connection and then select the properties of "file and printer sharing for Microsoft networks", you should end up with a window like this: This is where you can optimize the Server service for a specific role. Consequently, if you do the numbers you'll see that the higher you set the SMBServerPerfSetting, the higher the outcome of the formula is. But what is this number? Good question. This number represents the value Windows will use for the MaxWorkItems, an important value in tuning the Server service. However, MaxWorkItems is just one of the parameters you can set to tune your fileserver. Let's take a look at the (registry) values.
ParametersBefore we begin discussing the relevant parameters you can use to tune the Server service you should know that you should create them in the parameters sub key of the lanmanserver registry key. Let's take look at the most important parameters:
MaxWorkItems Possible values: 1-65535
InitWorkItems Possible values: 1-512
MaxMpxCt Possible values: 1-65535
MaxWorkItems and MaxMpxCt Relationship
MaxRawWorkItems Possible values: 1-512
MaxFreeConnections Possible values: 2-4096
MinFreeConnections Possible values: 0-256
SizReqBuf When running applications that use a lot of copy or move functions to a remote server (profiles anyone?), the speed at which this function completes is determined by network speed (of course) and by the SMB size. By increasing this WorkItems size, you will allow the server to complete its file copies faster. This will increase the performance of the application making the copy/move calls. For computers running Windows Server 2003 and with 512 MB or more of physical memory, the default size of the request buffers is 16,644 bytes; for servers with less physical memory, the default size is 4,356 bytes. If this entry is present in the registry, its value overrides the default value. Possible values: 1-65535
Lanmanworkstation As you can see, there's no "AutotunedParameters" here. However, there is a "parameters" sub key in which we can do some tuning. It is not uncommon (especially in Terminal Server environments) to have to tune the Workstation service to alleviate performance problems. This is due to the nature of Terminal Servers. My article on MSTerminalServices.org discusses this in detail, but in a nutshell it's like this: the workstation service was (and is) designed for a single workstation (like your desktop). However, a Terminal Server can easily host 50 desktop sessions, but unless you do manually intervene this server most likely is still configured just as your desktop would be. It's pretty obvious that this could lead to some performance problems.
ParametersAlthough there aren't that many important parameters like in lanmanserver, there are still a few parameters of the Workstation service you should definitely know about.
MaxCmds MaxCmds actually serves the same purpose as the MaxMpxCt on the Fileserver. Not surprisingly these two parameters have a special relationship. It's like this: whenever an SMB session is setup (i.e. a shared file is accessed), the SMB session is negotiated. During this negotiation the Fileserver passes down the value of MaxMpxCt to the client (a Terminal server for example). The client then compares this value to his own MaxCmds value. The lower of the two values then is used to set a maximum on the number of outstanding client requests to the File server. Possible values: 1-65535
MaxThreads Possible values: 1-255
MaxCollectionCount Possible values: 1-65535
Monitoring
Physical Disk
Redirector
Server Work Queues
Server Again, there's so much more you can monitor but interpreting the results depends heavily on your environment. Just browsing the performance monitor objects I mentioned and playing around with it will give you a lot more information.
TuningSo what do I set these registry values to? Unfortunately it's not that simple. For starters, it depends on your specific environment. Also, an unfortunately side effect of almost every one of these registry values is that when they are increased, they consume more kernel memory. Seeing as (the lack of) kernel memory is often a bottleneck in scaling up in Terminal Server environments, you should be very careful in adjusting/creating the registry settings we discussed. If you are not careful, you could end up having more performance problems than you started out with. You need to know why. Tuning LanManServer and LanManWorkstation in the registry, requires the use of more Non-Paged Pool memory. This can be a real issue on the File Server (LanManServer). Let me briefly explain where Non-Paged pool memory fits into the whole "2GB-Kernel--Memory-Bottleneck-Of-32-Bit-Windows". When you have a 32 bit operating system, this means that you have a 32 bit address space. That translates to 4GB of addressable memory space (2 to the power of 32). This 4GB is evenly shared between the user mode and kernel mode. User mode is the memory space that applications run in and kernel mode is used by the system for everything else. This 2 GB kernel mode memory is divided into several areas, amongst which is the NonPaged Pool. Because there's only 2GB to share, the NonPaged pool gets configured with a maximum size at boot time. By default this is 256 MB. This 256 MB is the area in which you should perform your (LanManServer) tuning. Why should you worry about this 256 MB? Well, because if the NonPaged pool is depleted then your system usually becomes unresponsive until some NonPaged pool becomes available again. So how does this apply to LanManServer tuning? Well, if you tune LanManServer in such a way that it allocates memory than the NonPaged pool has available and you indeed use up ALL of that allocated memory then you have effectively pushed Windows beyond its limits.
So what should you do? A safe way of doing it is to tune LanManServer in such a way that it can never deplete the NonPaged pool. The amount of memory LanManServer allocates in the NonPaged Pool is primarily determined by two parameters: MaxWorkItems and SizReqBuf. So if you set MaxWorkItems to 8192 and SizReqBuf to 16644 (default) (which in reality is 20480 due to tracking overhead) the amount of memory LanManServer will allocate is (8192 x 20480 bytes) 160 MB. This fits nicely into the 256 MB NonPaged Pool area. So there is however a decent chance that having 8192 WorkItems does not cut it for you. This is when the bits start to hit the fan. If you're in that rather sad place, you really have only three options, with option 3 being the safest choice:
.ADM Templates
Thincomputing.net Lanmanserver Tuning.zip
These optimizations should applied to your FILESERVER, not your Terminal Server. I've included the possibility to 'undo' the optimizations made the template. You can do this by selecting -Undo Lanmanserver Optimizations- and REBOOTING.
Thincomputing.net Lanmanworkstation Tuning.zip
These optimizations should applied to your TERMINAL SERVER, not your File server. I've included the possibility to 'undo' the optimizations made the template. You can do this by selecting -Undo Lanmanworkstation Optimizations- and REBOOTING.
Final ThoughtsAlthough some settings have been improved in Windows 2000 and even more in Windows Server 2003, I must say that I'm a bit disappointed that file serving problems like I discussed in the article are still quite common in Terminal Server environments. These problems have been around just as long as Terminal Server has, and one would think these problems would at least be a lot less common, but maybe that's just my point of view.
Microsoft, finally, recently has published an excellent article which discusses these issues in very good detail. This article isn't just about Terminal Server environments but it is still the best article Microsoft has ever written on the subject. Bookmark KB317249.
There's however a good chance that these problems with the file serving components of Windows will relatively soon be something of the past or at least be a lot less common. Windows Vista and Longhorn server will incorporate many changes, amongst which are major revisions in the file serving components. For example Vista comes with a major revision of the SMB protocol identified as SMB 2.0. The current protocol (SMB 1.0) was built to support file-serving solutions a couple of decades ago and was based on the assumptions existing then.
All these enhancements in SMB 2.0 will result in better performance and security over LAN and WAN. Sounds good huh? I'll believe it when I see it, but the file serving future looks bright!
|
Hi Michel, download links for the adms are broken. Could you please fix them?
Regards FD
Sorry about that.
You can download them hereh: http://www.thincomputing.net/index.php?option=com_docman&task=cat_view&gid=9&Itemid=15
I tested this with an internally developed SMB test and with XP as the server and client, with both sets of settings configured and applied.
The SMB test writes or reads 1024 bytes from a file 10,000 times.
The results were as follows (with throughput of 86.4Mbps, using iperf):
without settings:
Write: 7187ms
Read: 5672ms
with settings:
Write: 6297ms
Read: 5250ms
Hi Matt,
Very cool results, thanks for sharing. I would imagine that these results would look perhaps even better on a 2003 to 2003 test. Any reason why you chose XP to XP?
The download for Thincomputing.net LanmanServer Tuning ADM Templatehot at http://www.thincomputing.net/index.php?option=com_docman&task=cat_view&gid=9&Itemid=15
is corrupt and can not be unzipped.
Actually, All the zip files at
http://www.thincomputing.net/index.php?option=com_docman&task=cat_view&gid=9&Itemid=15
are all corrupt and can not be unzipped.
This can happen if you are behind a proxy.
Also try to use FireFox.
Downloaded the lanmanserver zip file but only 1.01KB. Corrupted. Any alternative source for download or just sahre hte registry key values.