Home > Articles > Operating Systems, Server > Microsoft Servers

Windows Server Reference Guide

Hosted by

Doing More While Getting Away With Less

Last updated Sep 26, 2003.

We continue our technical look at what believe to be the ten most important changes to Windows Server 2008, with a group of three services that demonstrate the evolutionary principle applied to software.

#8: Clean Service Shutdown

The problem with today's shutdown procedures is that large applications and services—especially if they're working with very large data blocks—spend more time spooling their data to disk than the allotted time. A process called the Service Control Manager is typically responsible for alerting other processes that Windows is about to shut down. Historically, at that point, it started a fixed, 20-second timer.

At a WinHEC conference keynote speech in Los Angeles, Microsoft technical fellow Mark Russinovich described it this way: "Now, the server application service was busy flushing a whole lot of stuff to disk, and synchronizing its logs and so on. Twenty seconds might not be enough, but the system would go down anyway. The only recourse that people managing these servers had before was to go to the Registry and increase that 20-second default timeout."

In Windows Server 2008, the new system enables services to take as long as they need...which might lead some to think that the shutdown process is slowing down. Not in the cumulative results, though. Under the new protocol, Russinovich explained, a service can register for pre-shutdown notification. "So there's actually two phases of the shutdown. The first is pre-shutdown—the services that have requested this notification get top priority. At that point they can flush their logs, synchronize their database...They get as much time as they want, as long as they're responsive."

Being "responsive" means signaling back to the Service Control Manager that the shutdown process is still going on, and not to have a cow. But if a process doesn't keep on responding after a three-minute nap, it ruins the party for everyone. At that point, the Service Control Manager responds by moving into what's being described as a "legacy phase," where the 20-second clock gets reinstated.

#7: Kernel Transaction Manager

This is a feature that low-level applications developers will come to appreciate perhaps more than the typical admin, but what it accomplishes is the elimination of another source of admin headaches: The Kernel Transaction Manager (KTM) establishes database-style transaction processing for both the NTFS file system (TxF) and the System Registry (TxR). As a result, sequences of operations that involve multiple changes can be stacked up, implemented all at once, and conceivably rolled back—this part of the feature may need to be verified.

As Mark Russinovich explained, "One of the problems with any kind of code where you've got to deal with errors, you know what a pain it can be, especially if that error is part of a multi-step operation. Because if you've got an error after the second or third step, you have to go back and undo those first two steps. So error recovery has always been a big pain, it's very easy to get wrong, and it's a lot of work to implement."

Applications can now be compiled to invoke the KTM when available. As an intermediary between the app and the file system or Registry, it provides a kind of socket called a resource manager. Operations that would affect one of these systems would be delivered to the socket, which stores them as an ACID set. We've talked about this before—Microsoft didn't create the idea: atomic, consistent, isolated, and durable. The idea is that a useful operation may actually consist of several components, especially moving a batch of files from one place to another in the network. Once the resource manager receives the set of components, it can execute the set en masse.

The huge benefit is that other threads that may seek near-simultaneous access to those files or Registry keys, or whatever the transaction may address, will see them as they were until the very moment the transaction is complete. The resource manager masks the intermediate state. Microsoft is encouraging software authors to write new transaction resource managers for different areas of the system.

#6: Server Message Block Version 2

Apparently derived from an IBM project circa 1985, the original Server Message Block protocol was a way for processors in a network to share data blocks relatively reliably. It used a request/response protocol in which a client initiated a transaction with a remote server for a simple file transfer request.

Microsoft was the predominant user of SMB over the years, even as the Common Internet File System (CIFS, essentially based on the SMB platform) began seeing wider use. Downward compatibility is a nice principle to adhere to (of all the principles Microsoft diligently follows, this one is indeed the topper), but there comes a time, five years after which Windows Server's network file transfers need to be rethought.

The big problem here is actually the same one addressed by KTM and parallel session creation: network file transfers are notoriously serialized. SMB version 2 addresses this problem through the creation of symbolic links that span across networks, and that can point to multiple items. Indeed, this is just aliasing. You'd think you've seen aliasing in Windows before. But file system aliases only work on the client side, and are facilitated by Windows Explorer.

For the multiple links to work, SMB2 borrows a service of our previous topic: It uses KTM to wrap modern network resource addresses (as opposed to NetBIOS) in transaction envelopes that can be batched, committed, and rolled back if necessary. And by allowing for (much) larger buffer sizes, Microsoft engineers have reported, media server speeds for transferring large-size files have increased over WS2K3 by thirty to forty times.

Add on top of this the fact that SMB2 traffic can now be encrypted, and you realize that Windows networking has at last entered the 21st century.

Books and E-books

Online Resources