Using XML To Supercharge Website Performance

With the advent of XML, we have the ability to supercharge our websites with huge performance increases. XML allows us to separate code, content, and presentation. Web developers now have three separate files which in turn will create the HTML that we output. Since the content is in a distinct file separate from the code and presentation, we now have the ability to create static content that is updated based upon changing business needs. The strategy is to have processes that create static content periodically, rather than every time a page is requested, substantially boosting performance of our web pages, and reducing the load on the database.

How XML Increases Performance

The use of XML can boost performance many ways, including:

  • Content is local to the web server, therefore decreasing network traffic.
  • Less load on the data tier since your database is queried every minute, or even once a day–rather than, for example, 50 times a minute. (Creation of static content is usually done hourly or nightly.)
  • Your HTML will be created and displayed faster because your application won’t have to query the database and transfer the data over the network over and over again.

You don’t have to port your entire site to an XML solution to gain the advantages of using XML. In most cases, just using XML in selective areas of your website can generate huge performance boosts.

In this article we are going to look at a real-world example of using XML to boost performance. If you want to follow along with the examples, you will need the following. If you just want to read along, and not perform the exercises, that is good too.

Requirements:

  • SQL Server 7.0 (example uses pubs database)
  • XML Creator Object (provided with download found later on this page)
  • MS XML 3.0 (free from Microsoft)
  • ADO 2.6 (free from Microsoft)


Recognizing Areas That Will Produce Huge Performance Increases

Before implementing XML, you will need to identify which areas of your site will give you the greatest performance increases by using XML. You will want to find out which queries are being executed most frequently. Once you find out which queries are being executed the most, you will then have to verify that it makes sense to use XML in those areas.

For example, let’s use SQL Server Profiler, a utility that ships with SQL Server and allows us to trace the various events that occur between your ASP application and SQL Server. Using this utility we can create a trace to run for 15 or 30 minutes and see which stored procedures were executed the most in that time frame. If you are unfamiliar with Profiler, please refer to the article entitled SQL Server 2000 Performance Tuning Tools.

After running the trace, let’s say we have discovered that a stored procedure named “Categories_Get” has been executed 40 times within 15 minutes! After further inspection, we discover that the reason this stored procedure is being executed so much is because it returns a listing of categories. We just happen to have an e-commerce store, and on every single page we have a navigation bar that links to the various categories of our store. Not surprisingly, this is the stored procedure that returns the listing of categories and their associated ID’s. This is a perfect example of where XML can deliver big performance increases.

Implementing XML Into Your Existing Applications Based On the Example Above

Implementing XML will consist of the following steps:

1. Install necessary components.
2. Run the Install Script. 
3. Configure the Job.
4. Create an XSL Document Template based on an XML Document.
5. Add an include file containing XML functions to your ASP page, remove your old code, add one line of code–and you’re finished!

Step 1: Install Necessary Components

In order for the XML Creator component to function properly, you will need install ADO 2.6 and MS XML 3.0, assuming you have not done so already. Both are provided free from Microsoft.

Next, you will need to download a component, which will take a recordset and create an XML document. I created the component using Visual Basic and it references ADO 2.6 and MS XML 3.0; therefore, you should not have to worry about memory leaks if you use this component.

Once you have downloaded the XML Creator component, you will have to register the component on the machine that has SQL Server on it. For this article, we are going to use SQL Server as the scheduler. We will create a new job that will execute a stored procedure at certain intervals. That stored procedure will then a) create the component and b) call a method with a connection string, stored procedure, and a path to save the XML document. Therefore, we will have to install the components on a machine that has SQL Server, although, it does not have to be your production machine. You could implement this solution in numerous ways; however, for this article, I will show you how to use SQL Server to accomplish the task at hand, with all code provided.

To register the XML Creator component, open a DOS command prompt, navigate to the directory where xml_create.dll is located, and run:

Regsvr32 xml_create.dll

Continues…

Pages: 1 2




Related Articles :

  • No Related Articles Found

No comments yet... Be the first to leave a reply!

Software Reviews | Book Reviews | FAQs | Tips | Articles | Performance Tuning | Audit | BI | Clustering | Developer | Reporting | DBA | ASP.NET Ado | Views tips | | Developer FAQs | Replication Tips | OS Tips | Misc Tips | Index Tuning Tips | Hints Tips | High Availability Tips | Hardware Tips | ETL Tips | Components Tips | Configuration Tips | App Dev Tips | OLAP Tips | Admin Tips | Software Reviews | Error | Clustering FAQs | Performance Tuning FAQs | DBA FAQs |