Scale Your Applications with Component Load Balancing

ith more and more companies moving their applications to the Internet, Visual Basic developers are faced with the problem of having to build components that scale to thousands of users. This either takes learning all of the tricks to squeezing every bit of performance out of VB or moving to a language like C++. You have probably also created an extremely convoluted network architecture to partition users across multiple servers to provide some level of redundancy. In doing so, you struggled with having to install and administer COM components on multiple servers; figuring out which server has which version of the component, messed around in the registry to ensure that everything is configured correctly, or faced DLL hell because other applications were installed on servers that overwrote supporting DLLs.

Until now, there has been no simple solution for developers to easily create COM applications that provide the scalability and reliability necessary for Web applications. Adding your components to MTS helped, but it was still a bottleneck and a single point of failure in your application. If the server went down, then that part of the site would come down. To help with some of these issues, Microsoft has introduced a new server called Application Center.



Visual Basic is great for building applications quickly but unfortunately, with VB, the tradeoff is usually poor scalability. The Internet has made this limitation of VB applications a constant challenge for developers, who must build components that scale to thousands of users.



Microsoft’s new Application Center offers component load balancing technology that allows administrators to create a cluster of servers that will respond to component requests.

Background on Application Center
Application Center is designed to provide a more robust environment for configuring, testing, deploying, maintaining, and scaling Web applications that are deployed across a server farm. There are a number of features in Application Center that will be of great interest to any VB developer, as they will assist in developing more scalable applications that are easier to administer and deploy. This article will focus on the component load balancing (CLB) feature of Application Center, which can significantly improve application scalability.

Note: Application Center runs only on Windows 2000 Server, Advanced Server, and Datacenter Server with IIS 5.0 installed.

COM Activation of Objects
In order to understand what CLB is, you will first need to understand the basics of how COM+ instantiates objects. When an application makes a call to instantiate a new object using the New keyword or the CreateObject function, a Windows service, the Service Control Manager (SCM), is performing the instantiation. The SCM acts as a middleman between your application and the COM component. The request for an object is passed to SCM as either a request for the ProgID, such as Word.Application, or as a GUID of the class, such as {000209FF-0000-0000-C000-000000000046}. The SCM uses this information to locate the COM DLL or EXE in the file system by searching the keys in the registry.

When the physical location of the COM component is found, the SCM instantiates an object and returns a pointer to the object in the case of an in-process COM DLL, or a proxy object in the case of an out-of-process COM EXE. With out-of-process objects, the SCM must create two objects to marshal data across processes. These two objects are the proxy and stub objects. From the perspective of the client application, it always thinks it is communicating directly with the instantiated object because the proxy implements the interfaces of the class being instantiated.

With Windows NT 4.0 and DCOM, Microsoft extended the SCM to allow applications to instantiate objects on a remote server by passing the server name into the CreateObject function:

Set oCustomer = CreateObject("MyExe.MyClass", _  "ServerName")

or setting the RemoteServerName value in the registry for your components. DCOM allows your applications to be partitioned into three physical tiers and moves some of the workload off of the client machines. For Web sites, this means that part of the workload can be removed from the Web server and placed on an application server. The Web server can service the HTTP requests and the application server can handle the “business logic.”

With CLB, Microsoft extends the SCM to dynamically assign a server within a server farm to handle activation requests of objects. Instead of relying on one machine to process the requests, CLB distributes the load across multiple servers.

Setting Up Component Load Balancing

Figure 1: Application Center MMC snap-in with a routing cluster configured.

CLB is based on the fact that there is one computer or a cluster of computers that receive a request for an object. This server or cluster is called the COM+ routing cluster. It forwards requests to other servers within a COM+ application cluster. The COM+ application cluster is the group of servers that are configured to service requests from a routing cluster. To create a COM+ routing cluster, the Microsoft Management Console (MMC) snap-in for Application Center provides a wizard that steps you through the process. Figure 1 displays a routing cluster called ZodiacCluster in the tree view on the left.

The COM+ routing server must perform two tasks: route requests to the appropriate application server and poll the application servers for information regarding the current load on the server. The data collected is timing data on each component configured to be load balanced on the server. The routing server uses the timing data to rank the servers and control which server will receive the next request.

Figure 2: Setting up the COM+ application cluster.

Once the COM+ routing cluster has been setup, the COM+ application cluster must be configured. Servers can be added to the application cluster through the properties tab of COM+ routing cluster. Figure 2 displays the properties tab with two servers in the application cluster.

Figure 3: Activation settings for classes on a CLB server.

The last configuration that must be made is to configure which components are load balanced. This is performed on a per-class basis. Each class in the application cluster must be declared to support dynamic load balancing. To perform this, an administrator can check off the “Component supports dynamic load balancing” checkbox on the activation page of a class’s property page in the Component Services Explorer as shown in Figure 3.

Turning on this checkbox allows CLB to collect timing data on each component every 200 milliseconds. How the CLB service collects this data is undocumented. Once the components have been configured they can be deployed to each server in the application cluster. Application Center offers tools to help define and deploy the application.

From the client’s standpoint, instantiating objects being load balanced by CLB is the same as instantiating a component using DCOM. All you need to do is pass the name of the CLBS into the CreateObject function or set the RemoteServerName attribute for the component in the registry.

Figure 4: Architecture behind the Component Load Balancing Service.

The CLBS uses two services to manage the routing of activation requests. The first, as mentioned before, is the SCM which runs in the RPCSS service. In addition, Application Center has another service called COMLB. This service is responsible for collecting the timing information and maintaining the ordered list of servers to route requests to. Figure 4 shows the architecture.

In Application Center, the SCM is extended to inspect an ordered list of servers in the COM+ application cluster. This ordered list is maintained by the COMLB service. The listing of servers is maintained in shared memory between the SCM and the COMLB services. In order to keep the listing of servers accurate and determine which server has the lightest load, the COMLB services uses the stub objects in COM+ to intercept the calls and perform some pre and post processing. In MTS, the stub was used to determine how many instances of a class were active.

Once the server has been chosen from the order lists of servers in the shared memory, the COM+ routing server SCM forwards the activation request to the other server’s SCM. If the instantiation of the object fails, the COM+ routing server moves to the next server in a round-robin algorithm and continues until a valid interface pointer is returned to the client. From this point, all communication will occur directly between the client and the server that handled the request.

Issues with Application Center
One problem that arises with CLB is that the configuration of the components must be the same on all of the servers within the application cluster. If one of the servers has a different configuration, random results may occur. If one component was set with a different security setting on servers in the application cluster, users may be able to run the application if the CLB server forwards a request to a server that allows them access, but other times it may forward the request to a server that denies them access. These types of random results would be difficult to track down. To solve this, Microsoft has added tools in Application Center to give administrators the ability to easily deploy applications across multiple computers.

The other issue that arises is performance. By moving the components to another computer throughput will decline. This is true whenever calls are made over a network instead of calling and out-of-process or in-process component on the same server. Initial test show that an out-of-process component on the same server is three times faster then calls to another box and an in-process component on the same server is five times faster. This needs to be considered when you are planning the architecture for your Web site. If throughput is the most critical factor in your Web site, CLB is not the technology for you.

CLB is an extremely useful technology for building highly scalable applications and providing availability to your application servers. It provides the mechanism to route client requests to the least busy server, which results in a quick response time to client applications. This mechanism of finding the least busy server and forwarding requests to other servers is built directly into the COM SCM and a new service called COMLB.



Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: