ActiveX components. In addition to optimizing the code of your Web applications, you can improve their performance by using ActiveX components to create server-side functionality and encapsulate code into one object. (Server-side objects typically provide one or more functions and hide the function's code from the developer and user.) However, components can have an adverse effect on your Web application if you don't understand how they work and perform. In fact, most problems associated with application development projects stem from improper design choices that lead to a poor-performing application. Let's look at a few tips for using components to enhance the performance of your Web applications.
Most developers use Visual Basic (VB) to write inhouse ActiveX components. To effectively use an ActiveX component in a Web application, you need to understand that VB uses a set of rules to determine when to shut down the component. Without these rules, a component can sit in memory and consume system resources when it doesn't need to. Table 1 describes the rules VB uses to shut down unnecessary components (for more information about these rules, consult the VB documentation).
So how much of a server's resources does an ActiveX component require? The answer to that question depends on the type and construction of the particular component. If you use an out-of-process component, it consumes a certain amount of memory every time it executes. Screen 2 shows the WinntMag.exe component from the NT Task Manager (I created this do-nothing component to use in testing concepts in this article). This component has a few properties and one method and uses 2216KB of system memory, which is a lot of RAM for not doing anything. If you add calculating logic, database logic, and error handling code, an out-of-process component starts to use more memory and can affect other resources such as the CPU.
In-process ActiveX components consume system memory within the process space of the application, which in this case is IIS, that uses the component. In-process components don't require the overhead in resources that out-of-process components require. In VB, you choose to make the component either an ActiveX .exe (out-of-process) or an ActiveX .dll (in-process).
The way you construct your components determines how many system resources they use. A Web application transfers data to an ActiveX component through a process known as marshalling. Although marshalling takes a lot of resources, you can minimize its effect. First, limit the number of calls the Web application has to make to the component. Don't call a component over and over again and pass it one piece of data at a time. Instead, create a procedure that feeds the component all the data in one pass as parameters. This simple change can make a huge difference in performance. Finally, make sure your developers understand the advantages and disadvantages of using different component models. For example, they need to be well versed in the advantages and disadvantages of using out-of-process versus in-process components and understand how marshalling affects their components. The VB documentation, Microsoft TechNet, and Microsoft Support Online have detailed information about the ramifications of constructing components.
You need to be careful when referencing a component from a session variable or application variable because the component stays loaded until the reference disappears. Depending on the lifetime of the variable, the reference can last for a long time. Use discretion: If you don't need a component, kill the references to it.
Finally, look at how Microsoft Transaction Server (MTS) works with components. MTS manages components and loads and unloads them as necessary. You can also use MTS to effectively manage transactions for your applications, removing the need for the applications to manage the transactions. (For information about MTS, see Charles Caison, "Optimizing MTS," page 153.)
Optimizing Your Web Server
Whereas the developer can optimize the variables and components associated with many inhouse Web applications, the systems administrator can use many of IIS 4.0's performance tuning features to optimize the Web server. For starters, IIS's bandwidth throttling feature lets you balance the network throughput IIS uses for the entire Web server, as well as individual Web sites, with the other loads on the server. To use this feature, display the properties for the server or site and select the Enable Bandwidth Throttling check box, as Screen 3 shows. Next, in the Maximum network use box, enter a number that is slightly higher than your expected bandwidth requires. You can determine your expected bandwidth by knowing the throughput of your system and monitoring its performance. You can also adjust the Enable Bandwidth Throttling option from the Performance tab for each Web site, as Screen 4 shows. You can use the IIS Global: Measured Async I/O Bandwidth Usage/Minute counter to determine your current bandwidth through the Performance Monitor.
Screen 4 also shows the Performance Tuning option. This option lets you tailor the amount of memory you want to assign to your site (the memory you allot coincides with the number of hits you expect your Web site will receive per day). IIS uses this memory to listen for new requests to your Web site. By setting the slider in Screen 4 to about 10,000 hits per day, you can ensure that IIS doesn't allocate unnecessary memory to listen for more requests. To achieve the optimum performance for your server, you want to set this value slightly higher than the total number of hits you expect to access the site each day.
Finally, Screen 4 shows the HTTP Keep-Alives Enabled property on the Performance tab. IIS enables this property by default to keep a connection open when a browser makes a request. This setting improves the performance of the server because IIS requires fewer new connections for each user. For example, if a user accesses a page with numerous graphics, HTTP Keep Alives let the server keep the connection open while each graphic downloads, instead of requiring a new connection for each graphic.
You can limit the number of connections users can make to your Web server at one time. Screen 5 shows the Property page for the default Web site included with IIS 4.0. To limit the number of connections, select Limited To and enter the maximum number of connections. You can also use the Connection Timeout property to set the number of seconds before the Web server disconnects an inactive user. Setting this parameter is useful because HTTP might not always disconnect an inactive user properly. However, be careful when changing the default value because a session may be inactive for a period for several valid reasons. This precaution is especially true with Internet sites where you might encounter a slow response time and other unexpected delays because of the Internet's unpredictable infrastructure.
Performance Monitor Objects for IIS
IIS 3.0 and 4.0 install Performance Monitor objects that you can use to monitor your Web servers. Table 2, page 141, lists the objects that come with IIS 4.0. These objects let you see inside IIS and your Web applications. Keep in mind that you can't look at these objects in a vacuum: You must take into account any other applications running on the server hosting IIS and the effect those applications and the operating system (OS) have on the server. Therefore, compare the IIS objects and their counters with the other applications.
If you use ActiveX components with your IIS server, you need to monitor the components' performance with the IIS Performance Monitor objects. Screen 6, page 140, shows the Add to Chart dialog box from Performance Monitor with the WinntMag.exe process selected. This object is the same one I used in Screen 2. The trick with using Performance Monitor to track processes is that the process must be running when you use the Add to Chart dialog box to place it. In this example, I forced the object to load by running a simple program that uses the object. After I add the WinntMag.exe object to my chart, I can add other counters and track the overall system's performance.
Scratching the Surface
This article only scratches the surface for tuning the performance of IIS. For more information about performance tuning, check out the Microsoft Windows NT Server 4.0 Resource Kit and go to http://www.microsoft.com/iis and http://www.15seconds.com.
End of Article
Prev. page
1
[2]
next page -->