Scale applications to the enterprise

Why can't a developer build a single-user application, install it on an enterprise server, and accurately call it an enterprise application? The answer has to do with scarce server resources such as network sessions and database connections. If a server application attempts to perform a unit of work but has to wait for these resources to become available, scalability has stopped.

Microsoft Transaction Server (MTS) helps you ensure that applications will use server resources economically. This overview describes several issues Windows NT systems administrators face when they manage MTS servers.

What Is Microsoft Transaction Server?
MTS is a product for running business applications on an NT server. It combines the ease and flexibility of PC programming with the reliability of mainframe applications. MTS automatically provides functionality to single-user applications that lets them run reliably as multiuser applications. MTS also provides process isolation, network sessions, shared data, database connections management, multithreading, application security, automatic transactions, and an easy-to-use point-and-click administrative interface.

MTS relies heavily on packages. Packages are collections of ActiveX components that function together as an MTS application. MTS implements these components as single-use DLLs that provide business functions to the application. The MTS package can provide services to Web clients and to LAN-based applications. In addition, MTS provides access to several types of databases, including SQL Server databases, UNIX databases, and mainframe databases.

Although MTS has existed in one form or another for more than 3 years, widespread use of the product has only recently begun to take off. Several technology companies, including Digital Equipment, Texas Instruments, and HP, use and support Active Server Technologies such as Distributed Component Object Model (DCOM) and MTS.

In an effort to demonstrate that MTS can scale to support enterprise applications, at the May 1997 Scalability Days, Microsoft used NT Server, SQL Server, and MTS to demonstrate a system that generated one billion transactions. In addition, IBM has used MTS to demonstrate a distributed online transaction processing system that executes one billion transactions per day on a cluster of servers running NT Server 4.0.

With MTS, developers do not have to change any code to scale single-user applications to multiuser applications. This factor is important to systems administrators because application changes usually involve disrupting the server and spending time implementing the software upgrade. At the very least, upgrades usually involve a server reboot. In addition, changes to working software sometimes introduce new bugs to the server. MTS eliminates these problems.

With MTS, systems administrators use a consistent interface, the MTS Explorer, to create and administer applications. The interface provides flexibility in deploying applications. For example, you can use the same code to configure an application to run on a standalone system, on one server, or on multiple servers. Because the interface is consistent across applications, you do not have to learn a new configuration tool with each new application. The MTS Explorer runs as a snap-in to the Microsoft Management Console (MMC), the management interface that Microsoft now distributes with NT. You install components, such as MTS and IIS 4.0, into the MMC and administer those components from within the MMC.

MTS can help simplify your job. By making applications scalable and reliable, developers write less code. This scenario means fewer application components and fewer possible points of failure. With fewer possible points of failure, an application is less likely to fail and bring the server down with it.

With code that takes advantage of context objects, you can build ActiveX components specifically for MTS. Context objects are like guardian angels that follow around each instance of MTS objects to provide information about that instance. MTS can provide advantages to applications whether or not they have been built specifically for MTS, although the use of context objects makes an MTS application more robust.

We'll highlight some specific benefits available to components that are installed into MTS. MTS-specification applications can take advantage of all these benefits but even applications not written with MTS-specific code can take advantage of the first four.

Database Connection Pools. When using an Open Database Connectivity (ODBC) database with an MTS application, database connections can service more clients because MTS recycles the connections when the MTS application no longer needs them. Performance and scalability improve because neither the application nor MTS has to create new connections for each request and user. The same connections are shared and recycled among instances of MTS applications.

Secure MTS Applications. MTS can configure security into components. Developers do not need to add security code. MTS security uses NT security features to grant levels of access to MTS packages and components.

Component Management. MTS can distribute components across multiple machines to ease the processing burden placed on a server. You can use the MTS Explorer to distribute components to a client machine whether or not that client is running MTS. If the client is not running MTS, MTS can generate an executable that will automatically install and configure clients to access remote MTS server applications. The client must support DCOM for this procedure to work.

Transaction Monitoring. MTS can manage transactions in components that are not coded specifically to use the context object. Even without MTS-specific code, you can use MTS to roll back transactions if an operation fails.

Just-In-Time (JIT) Activation and As-Soon-As-Possible (ASAP) Deactivation. With JIT and ASAP, MTS improves scalability and performance because it activates components only when it needs them and deactivates them otherwise. As MTS deactivates objects, they become available to other processes. Because objects are already warmed-up and the server does not have to create new objects for each client, the objects are served up more quickly to subsequent processes. Components that do not use MTS-specific code must wait for the client application to release objects. The SetAbort and SetComplete methods provide immediate object deactivation.

Shared Properties. Components can create, use, and update global data. Objects do not need to manage state information because components can share information with other components in the same package. MTS handles state management for any number of simultaneous clients.

Improved Security. MTS provides two types of package security: programmatic and declarative. Programmatic security deals with MTS-specific interfaces that developers use to create customized security within application logic. Available to all MTS applications, declarative security lets you take advantage of existing NT security to assign various levels of permissions to access packages, components, and interfaces. You can run packages on nearly any computer on the network, as long as the operating system (including Windows 9x) supports DCOM. Because declarative security is based on NT security, you can use it only for packages running on NT.

Managing Applications with the MTS Explorer
The MTS Explorer interface simplifies creating and administering MTS packages and applications. You can add packages to an MTS application in two ways. You can use the package Wizard to create an empty package from within the MTS Explorer and then add components, or you can install a prebuilt package. To create an empty package, right-click Packages Installed in the MTS Scope Pane and select New, Package from the context menu, as Screen 1 shows. The Package Wizard will start and let you install a prebuilt package or create an empty one. Select Create an empty package, which Screen 2 shows.

The Package Wizard steps through naming a package and choosing the account the package will run under. The package can run under the account of the currently logged-on user or a specific user whose username and password you supply.

To add ActiveX DLLs to the package, double-click the new package, double-click the Components folder, and drag the DLL from Windows Explorer to the right pane of the MTS Explorer. MTS will register all the objects and display an icon for each component. Screen 3 shows the MTS Explorer with the Bank Client sample components installed.

You can right-click a component to display a property sheet for configuration. Options on the Transaction tab determine how the component will support transactions. The options are Requires a transaction, Requires a new transaction, Supports transactions, and Does not support transactions. If the component does not include MTS-specific code, choose Does not support transactions.

Declarative security is based on roles. A role is a logical group of users that can invoke interfaces on a component. For example, you can create a role named Clerk for an accounting package. Instead of giving members of that role full control over the application components, you can configure the role to have read-only access. Based on the NT accounts database and security, MTS objects can offer functionality to users based on their role. You add existing NT users and groups to a role to define membership.

To create a new role, select a package in the Scope Pane, and right-click the Roles folder. Select New, Role from the context menu that appears. To add users to a role, select the Roles folder, and select the applicable role. Right-click the Users folder. Select New, User and use the Add Users and Groups to Role dialog box.

The Security tab lets you enable security for the component. To choose which roles can access the component, right-click the Role Membership folder for the component. Next, select New, Role and select the role that will have access rights to the component.

Your component is now an MTS component. Using MTS Explorer's Status View, you can monitor the state of an application. Status View lets you quickly see the state of packages, processes, and computers.

Different types of objects have different Status Views. For example, Status View for components in a package lets you see the component's identifier, objects in call, and which objects have been activated. Status View for the Packages Installed folder can tell you which package is running. Status View for the Computers folder can tell you whether Microsoft distributed transaction coordinator (DTC) has been started.

To use MTS Status View, from the right pane of the MTS Explorer, double-click the icon of the package you want to monitor. Double-click the Components folder. On the View menu, select View, Status View. You can now see which components have been activated. Status View provides this information graphically (animated icons show you which components have been activated) and numerically. For example, in Screen 4, the Account, GetReceipt, MoveMoney, and UpdateReceipt components are active.

Transaction Statistics is another useful window. To open this window, click Transaction Statistics in the left pane, under the name of the computer you are managing. The Transaction Statistics window, shown in Screen 5, provides information about currently active components, all components that have been active, aggregate information on component response times, and when DTC was started.

Other Tools for Monitoring MTS Applications
Several other tools available to systems administrators make monitoring MTS applications easy. The first tool we will look at is Performance Monitor.

Performance Monitor shows you what is happening with MTS, the application, and server resources. Performance Monitor provides graphical statistics that you can use to measure your computer's performance. With Performance Monitor, you can measure resources in use or used over time. (For more general information about Performance Monitor, see Michael D. Reilly, "The Windows NT Performance Monitor," March 1997.)

Let's consider a sample application included with MTS. The Bank Client application lets you test MTS installations with SQL Server and shows you how MTS handles package deployment and administration. With the SQL Server Performance Monitor, you can quickly see the difference that MTS makes with respect to the number of database connections that an application uses.

We compared the Bank Client Application with the VisData sample application included with Visual Basic (VB) 5.0. Both sample applications accessed SQL Server; therefore, we used the SQL Performance Monitor with both.

We started five instances of the VisData application and observed the results in the SQL Performance Monitor. As Screen 6, page 171 shows, each of the five instances of the application requires a separate database connection. (At the bottom of the graph, you can see that the number of database connections in use increases from a minimum of seven to a maximum of twelve.) In addition, the application holds each database connection, consuming valuable resources, until you shut down the application.

Next, we started five instances of the Bank Client application. In Screen 7, SQL Performance Monitor informs us that the number of database connections in use increases from seven to nine. In other words, all five instances of our application accessed the SQL Server database but required only two database connections. MTS recycles connections among the instances of the application, but each instance believes that it has a persistent connection to the database. Furthermore, MTS reclaims those database connections when you no longer need them. If an instance of an application must access the database again, MTS will provide an existing connection from the database connection pool. This example demonstrates MTS JIT activation and ASAP deactivation.

The Network Monitor utility captures and displays network traffic. With Network Monitor, you can determine the effects that various component deployment arrangements have on network throughput.

Event Viewer is useful when your server application is failing or causing unexpected behavior. If you suspect that MTS is causing a problem on your server, check the Application log in the Event Viewer and examine the event messages. If MTS is the source of the error, you will see it listed in the Source column.

You can use User Manager for Domains to create and manage user accounts and groups and manage security policies. Use those users and groups and MTS roles to implement MTS security.

The Windows NT Diagnostics tool provides valuable information that is difficult to obtain otherwise. For example, you can click the Services tab to determine whether the services that MTS needs, such as SQL Server and DTC, are running.

The Memory tab can tell you about your server's memory utilization, thread usage, and active processes. You can also find information about your virtual memory paging file. At a glance, you know how much of your paging file is in use and the peak usage size. If either the current usage or the peak usage approaches the size of the file, you might need to increase the paging file size. You can resize the paging file from the Performance tab of the System applet in Control Panel.

MTS Applications and Network Performance
The tools we've mentioned provide valuable information that can help you increase system performance in many different areas. Now let's look at specific ways to increase performance in an area of particular concern: network performance.

Network performance is important to distributed applications, such as those MTS manages, because network performance often affects the user's perception of the application. If the network is performing poorly, users might perceive the application as performing poorly and unreliably. If the network is quick and responsive, the likelihood increases that users will perceive the application as quick, responsive, and reliable. Network performance is crucial to the overall performance of the application.

When you've collected information about your system and have found a bottleneck, you must determine how you will eliminate the problem. Always make only one change at a time, or you won't be able to determine which change affected the system.

One of the best ways to improve network performance is to reduce network traffic. You can migrate applications to lower bandwidth Internet/intranet protocols, such as HTTP, or localize servers inside departmental subnetworks. Migrating applications to Internet/intranet protocols works particularly well because you can use components installed into MTS in either standard client/server applications or HTTP-based applications.

You can also split your network into several subnetworks. If you increase the number of subnets and subsequently limit computers that frequently talk to one another to one subnet, you free bandwidth on the remaining subnets. This method is analogous to building additional roads to relieve traffic congestion.

Another effective but expensive option is to raise the speed limit of your network. You can upgrade your data link equipment to increase network speed. Upgrading your entire network is a major architectural change that you will probably do over time. To start, you can upgrade the backbone technology, the links between servers or certain subnetworks or users, to higher speed networks.

From Single Use to Multiuse with MTS
MTS provides a powerful environment for scaling single-use ActiveX components to multiuse components. In addition, NT offers several tools for monitoring MTS applications to ensure that all systems are running correctly. MTS lets software developers take advantage of the PC's convenience and flexibility to write enterprise applications. MTS offers systems administrators the piece of mind to know that those applications will run as reliably as mainframe applications.