Every app is different and every server is different. It's only through extensive understanding of the application that decision can be made to improve its performance. There are no specific set of rules we can define that will ensure app will run with great performance on a given server. Only thing we can do is to come up with a framework/checklist that we might want to review.
So let's start by defining key performance pillars:
End user - defines performance of the site as viewed by the end user. For example, do customers notice that how long it takes to render, what's the speed, is it fast enough etc.
Throughput - measuring per second values (Request, bytes and connections) which apply at several levels like, Farm, Server, Website, Application Pool, and even URL users are browsing.
Capacity - How much we can support in terms of Users, Connections, Throughput, and Content etc.
Scaling - a way to fix performance problems.
After we have listed out key performance pillars, we need to measure them.
Measuring End userUse (or may be test) the site as end users would use. What is their connection speed, check out for client or proxy caching happening, what browsers (with versions) are used to browse the site etc. One thing we need to keep in mind that application is developed and tested in high speed LAN and conditions will not be same when deployed on internet where still most of the users are running on modem and low speed connections. So customer experience and your experience will be different.
But the challenge is we really can't get all our customers so best we can do is to bucket-ize the customers and put them into groups like how much % of them are modem users, how many are on high speed connections, how many have direct T1 lines etc. Now the question is, how do I find those buckets? What are the best tools to capture and report such data? One of the tools is Log Parser.
It's an extensive tool that will help us to analyze IIS performance by parsing IIS logs. We will also look out for different type of browsers being used and how long these request takes. This tool can be executed through command line and it expects a query (almost similar to SQL syntax) for performing heuristics on a given log.For example, we will write a script that will return type of browsers used to browse the website.%logparserinstalldir%> logparser.exe GetBrowsers.sql
GetBrowser.sql
SELECT TOP 10 to_int(null(100.0,propcount(*))) as Percent Count(*) as TotalHits cs(user-Agent) as BrowserFROM %logfile%GROUP BY BrowserORDER BY TotalHits desc
Percent
Total Hits
Browser
15
771
MSIE 6.0
50
565
MSIE 7.0
10
109
Some other browser ...
Why is that important to know about browser? It is because each browser has a different caching technique, rendering mechanism etc. Accordingly we may want to change output HTML along with header for better performance.We can start identifying important page(s) that users could be hitting and what is the average, maximum, minimum and hit count for such page(s).
SELECT to_lowercase(cs-url-stem) as URL AVG(time-taken) as AvgTime MIN (time-taken) as MinTime MAX(time-taken) as MaxTime count(*) as HitCountFROM %logfile%WHERE URL = ‘/default.asp'GROUP BY URL
Script below will list out clients connected (requesting something) and we will try to identify slow connection(s).
SELECT c-ip as Client Avg(sc-bytes) Avg(time-taken) to_int ( mul ( div (to_real (sc_bytes), case avg(time-taken) when 0 then 1 else avg(time-taken)), 1000 ) ) as BytesPerSecond Count(*) as HitsFROM %logfile%WHERE sc-bytes > 1 and time-taken > 1000 [ where condition to ensure that we are taking connections that did not get dropped. 1000 is measured in milliseconds which means 1 second]GROUP BY Client, cs(user-Agent) HAVING hits > 1By running above query we can find out slowest client . It could be possible that it is one of the most important clients. This does not mean that server is performing badly nor has a fast connection to internet rather it seems that client is on slow connection may be modem. It gives us few points to discuss. For example, can we do something to reduce the payload (IIS compression is one way to achieve it) so that app works for slow clients as well? Measuring ThroughputPerformance monitor is the key way to learn what the throughput is. However it does only at server and site level. But we can use log parser for other levels for example, for URL, we can use log parser to know URL request per second/hour/minute and no of bytes transferred to different clients as we see in above examples. ETW (Event tracing for windows) is yet another excellent tool to understand performance, throughput of the server and other issues through extensive logging mechanism. It traces each and every call within the server till the time request reaches to server (HTTP.SYS in case of win 2k3) and served back to the client, what all operations are involved for that individual request. I would like to take an example, where ETW tracing proved to be useful in diagnosing performance issues. After publishing a website to another server, very first request to any aspx/asp page was taking huge amount of time. Running an ETW trace on that server resulted in a log file upon investigating which it was found that first request was taking long time because of ISAPI filter installed on top of IIS was taking long time to load hence blocking all other operations.
Now we can understand & define performance and know some ways to measure it we will move on to how we can improve performance of a given web application. Again, there is no defined way to improve the performance. It includes making guesses, see if they work, if they do, celebrate and make another guess. If they don't, undo it and make another guess.
Improving end user performanceIn the internet scenario we can define key issues: -
Download timeAccording to a survey, still more than 50% of internet users still have narrow band connections let's say, modem. So if testing and verification is done in a high speed LAN environment, we cannot understand and foresee customer problems that might be running on narrow band connection.
So specific items we can look at to address such key issues are: -
Bad CSS (Replication of data).article-ByLine { font-family: Tahoma,sans-serif; font-size: 9.5pt; font-style: normal; line-height: normal; font-weight: normal; color: #000000}.article-Caption {font-family: Tahoma,sans-serif; font-size: 8pt; font-style: normal; line-height: normal; font-weight: normal; color: #000000}.article-Headline { font-family: Tahoma,sans-serif; font-size: 14pt; font-style: normal; line-height: normal; font-weight: bold; color: #000000} In above example, highlighted text is same for each definition except font-size. It results, in increased payload. Same CSS can be represented as: -BODY {font-family: Tahoma,sans-serif; font-style: normal; line-height: normal; font-weight: normal; color: #000000}.article-ByLine {font-size: 9.5pt;}.article-Caption { font-size: 8pt}.article-Headline {font-size: 14pt;font-weight:bold}
Hardware Resources If CPU is the issue, think about caching so that we don't compute so often. Is HTTP compression causing this to happen etc.?
If memory is an issue, check if we are caching too much, how many copies of same data we are caching etc. So there is a tradeoff, which is hitting you much, CPU or Memory and take the judgment accordingly. You can monitor memory by making use of existing performance monitor counters. Here are few of them: -
If disk is slow determine who is causing file access. Best tool available for this purpose is Filemon. For example, it could be possible that web site logging is turned on causing several file I/O's hence degrading the performance.
Till now we have discussed key performance pillars, how we can measure them and ways to fix them.
Performance issues can be difficult to troubleshoot and often take a long time to determine the root cause & resolve. This process can be less painful if we collect good data and then use that information further to solve the issue. So how can we collect good data? By asking as many questions we can. For example,
Once we have gathered the above data I am pretty sure we will have a good idea on where to focus. Based on symptoms and data we need to decide if the problem is on client side, server side, database/other tier or combination of one or more of these. There are several tools available that can now assist us to find root cause.
I hope this article gets you going to start troubleshooting and analyzing performance issues for a given website hosted on IIS.
Bye for now,--Parag