Welcome!

.NET Authors: Liz McMillan, Peter Silva, Yakov Werde, Matthew Pollicove , Kevin Benedict

Related Topics: .NET, PowerBuilder

.NET: Article

Solutions for Optimizing ASP.NET Applications

The case for third-party acceleration

In principle, embedded ASP.NET session tools should allow you to move session data out-of-process without any additional application coding. However, all of your .NET objects must be serializable to do this. Since custom classes aren't serializable by default, you have to mark your classes as serializable and make sure that all data types used in your classes are, in fact, serializable. If they aren't, you have to do some significant recoding. Once you complete this process, ASP.NET allows you to use either State Server (a free ASP.NET software package for implementing remote session storage) or SQL Server to manage session out-of-process. Unfortunately, the combination of serialization, out-of-process communication, and added network trips required by either of these solutions (reading from the database at the beginning of each session and writing to the database at the end) can make your out-of-process session take as much as six times longer as an in-process session. Effectively, you're adding scalability at the cost of performance.

Product-Based "Buy" Optimizations
Now, let's consider some third-party "buy" options to optimize the scalability and performance of your ASP.NET application. Of course, no third-party solution can compensate for poor coding or architecture, or can completely remove the need to pay attention to performance when coding. But a variety of third-party hardware, software, and service-based solutions now available can help you make some significant optimizations without touching your application code. Product-based solutions for load balancing, payload reduction, caching, and application acceleration can tackle some of the biggest performance hogs quickly and predictably.

Load Balancing
Any distribution solution requires some sort of load balancing - the ability to split the incoming workload across multiple Web servers. Microsoft provides Network Load Balancing (NLB) as part of all versions of Windows 2003 Server. NLB is an algorithmically based load-balancing solution, typically balancing workloads symmetrically across multiple servers. If you have four servers, each would take 25% of the load. You can alter that balance to anticipate stronger and weaker servers. NLB also supports affinity, so that particular IP addresses will consistently go to the same server.

NLB uses the concept of distributed algorithms and virtual IPs to operate. There is no central management point for NLB: Every server knows the rules for load balancing and they all listen on the same virtual IP to all the traffic. Based on the algorithmic rule, all servers know which server should respond to a given packet. To manage server failure, each server in the cluster sends out a "heartbeat," letting the other servers know it's still functioning. Should a server go down, within a minute the servers will reconfigure themselves to cover all traffic without the missing server.

Hardware load balancers can do the same tricks that NLB can do and more. They can handle larger amounts of traffic, and they have more sophisticated load-balancing options, such as using agents to receive current load data from each server so that the least-loaded server gets the next request. Hardware load balancers are generally purchased in pairs for failover purposes. Their sophisticated options come at a price, of course, but for larger, busier Web farms, they are indispensable.

Payload Reduction
Several companies, including Cisco, Citrix Systems, F5 Networks, and Strangeloop offer solutions for reducing the size of the Web page. These solutions use compression to reduce payload size and also can accelerate the performance of secure sites by offloading processor-intensive SSL encryption and decryption tasks. These appliance-based optimization solutions are designed to work with all types of Internet applications, regardless of the platform or development technology, and can free up significant network bandwidth and server resources.

You can also look to third-party software components, such as Flesk's ViewStateOptimizer, to replace ASP.NET's default ViewState management function. By stripping ViewState data from each response and reinserting it into subsequent corresponding requests, these solutions reduce the payload sent to and from the browser. To use this solution, you still have to modify your code to call into the Flesk component for ViewState persistence, but it does allow you to configure your application to store ViewState data in session state variables or in disk files (see Figure 1), and employ automatic data compression.

The Strangeloop AS1000 appliance provides a solution to ViewState data by storing the data on the appliance - since the appliance sits in front of the Web servers (see Figure 2), it can automatically remove the ViewState from the Web page on the way to the browser from the Web server and reinsert the data as the postback comes from the browser to the Web server.

Caching
As an alternative to ASP.NET's built-in caching features, several companies now offer appliances that can provide a plug-and-play alternative for caching both static and dynamic content, without requiring you to change your application code. Both the F5 WebAccelerator appliance and the Strangeloop AS1000, for example, automatically identify static content such as images and adjust HTTP headers to increase browser caching of this content.

Beyond browser caching, the Strangeloop AS1000 automatically learns what Web pages are cacheable based on their frequency of change and can automatically cache even dynamic Web pages, creating an effective alternative to ASP.NET's more manual-intensive output caching features.

Acceleration Services
The product-based optimizations I've mentioned so far are all solutions that run in your data center, but you can also take advantage of third-party acceleration services. For example, a growing number of sites use the Akamai EdgePlatform, a network of 200,000 worldwide servers, to optimize caching and accelerate the delivery of images and other static and dynamic content.

You can also use vendor-based services to handle streaming media. Akamai, NaviSite, OnStream Media, and others provide a range of services for streaming audio and video content that can otherwise rapidly consume your network, memory, and processor resources. Adobe also offers a service specifically geared to optimize Flash media delivery, and Microsoft offers a similar service for Silverlight streaming.

Embracing Product-Based Strategies for Optimizing Applications
The ultimate scalability and performance of your ASP.NET application depends on a variety of factors, and you're not going to be able to "buy" your way out of every bottleneck you may encounter. But for a growing number of performance issues, third-party solutions can offer a compelling alternative to manually tuning your code. Product- and service-based optimizations can provide simple drop-and-go solutions for many performance challenges, without forcing you to forgo the productivity-enhancing programming techniques you need to get your application out the door quickly. Most important, they eliminate the question marks associated with any code-based optimization project and provide a known return for a known cost.

More Stories By Kent Alstad

Kent Alstad, CTO of Strangeloop Networks, is principal or contributing author on all of Strangeloop's pending patents. Before helping create Strangeloop, he served as CTO at IronPoint Technology. Kent also founded, Eclipse Software, a Microsoft Certified Solution Provider, that he sold to Discovery Software in 2001. In more than 20 years of professional development experience, Kent has served as architect and lead developer for successful production solutions with The Active Network, ADP, Lucent, Microsoft, and NCS. Kent holds a bachelor of science in psychology from the University of Calgary.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.