Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

ASP.NET Site Performance Secrets
ASP.NET Site Performance Secrets
ASP.NET Site Performance Secrets
Ebook1,049 pages6 hours

ASP.NET Site Performance Secrets

Rating: 5 out of 5 stars

5/5

()

Read preview

About this ebook

Written in a practical and clear conversational style, this book is filled with real-life website performance scenarios. It is replete with lots of working code samples and practical advice, and just the right amount of theory you need to make sense of it all. This book is written for ASP.NET/SQL Server-based website developers who want to speed up their site using simple, proven tactics without going through a lot of unnecessary theoretical learning. If your website isn't performing well, this is the ideal book for you.
LanguageEnglish
Release dateOct 13, 2010
ISBN9781849690690
ASP.NET Site Performance Secrets

Related to ASP.NET Site Performance Secrets

Related ebooks

Information Technology For You

View More

Related articles

Reviews for ASP.NET Site Performance Secrets

Rating: 5 out of 5 stars
5/5

1 rating0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    ASP.NET Site Performance Secrets - Matt Perdeck

    it.

    Chapter 1. High Level Diagnosis

    Being responsible for a site with slowly loading pages is simply not good. Having twitchy managers look over your shoulder, angry phone calls from advertisers, and other such nastiness is simply no fun. Unfortunately, it can happen to even the best developer—one day your site is cruising along just fine and the next morning, it is really slow. Of course, it may not be completely your fault. Moving the site to that cheap hosting plan may have a bearing on it, or the advertising campaign that marketing just launched without telling you, driving massive traffic to the site. In the end, it doesn't matter—all eyes are on you to make the site faster, and do it quickly. Of course, if you slip in performance improvements in regular releases, there is a better chance you'll avert that sort of crisis.

    The problem is that generating even a moderately complex web page involves many lines of code and many different files. Seeing that time is always short, you'll want to zero in on those lines of code and those files that have the biggest impact on performance, leaving everything else for another day. Do this in a structured, top-down way, and you'll get it done more quickly and with a greater chance of success.

    In this chapter, you'll learn the following:

    The overall process of assuring good performance, and how performance tuning fits into this.

    How to generate Waterfall charts as a way to identify those aspects of your site that cause web page performance issues.

    A number of scenarios of poor performance and how to recognize each scenario using the Waterfall charts you generated. With each scenario, you'll find a reference to the specific chapter that shows how to further pinpoint the bottleneck, and then eliminate it.

    In this chapter, we'll stay at a fairly general level; in the subsequent chapters, we'll dive deeply into the technical aspects of improving your website's performance. This will include performance monitoring (Chapter 2, Reducing Time to First Byte), IIS thread usage (Chapter 6, Thread Usage), database access (Chapter 8, Speeding up Database Access), and on-the-fly JavaScript compression and on-demand loading (Chapter 13, Improving JavaScript Loding).

    To see how to load test your code without touching your production environment, refer to Chapter 14,Load Testing.

    Assuring good performance

    Before you start diagnosing and fixing performance issues, let's first have a quick look at how this fits in to the overall process of assuring good performance. This process consists of these parts:

    Continuous monitoring

    Setting performance goals

    Iterative improvements

    Let's go through each part of the process one-by-one.

    Continuous monitoring

    The performance of your website is affected by both the things you control, such as code changes, and the things you cannot control such as increases in the number of visitors or server problems. Because of this, it makes sense to monitor the performance of your site continuously. That way, you find out that the site is becoming too slow before your manager does.

    At the end of this section, you'll find a list of monitoring services that will keep an eye on your site.

    What do you mean by site is becoming too slow? Glad you asked.

    Setting performance goals

    When this books talks about performance, it ultimately talks about page load time—that's what your visitors and potential customers experience.

    It pays to have a clear understanding of how fast is fast enough. Spending time and effort on making your site faster is time and effort not spent on other improvements. There is little point in making your site faster if it is already fast enough.

    Your manager, client, or marketing department may have ideas about what constitutes fast enough. Alternatively, visit the page Website Response Times at http://www.useit.com/alertbox/response-times.html to gain inspiration for setting performance goals.

    Ok, you've been monitoring your site, and found it is getting too slow. What now?

    Iterative improvements

    Because websites, web servers, and browsers are such complex beasts, it pays to make improvements in a deliberate fashion. Hence, these two golden rules:

    One change at a time: Because multiple changes can affect each other in surprising ways, life will be much easier if you implement and evaluate changes one-by-one.

    Test, test, test: You don't know whether your change really is an improvement until you have tested it thoroughly. Make sure that performance after the change is better than performance before the change, and be ready to roll back your changes if it isn't; what works for other sites may not work for your site.

    This process makes your site run faster. An iterative process is shown as following:

    Record the current performance.

    Diagnose the performance problem—identify the single most important bottleneck.

    Fix that one bottleneck (remember, one change at a time).

    Test your change. Has performance improved? If it didn't, roll back your change and come up with a better fix. If it did, go back to step 1.

    As a result of this, making your site faster is an iterative process:

    If you find bottlenecks that currently do not pose a problem, but will come back to bite you in the future, it may be good to fix them, now that they are clear in your head.

    We can capture all this in a flowchart:

    Monitoring services

    If you search Google for site monitoring service, you'll find lots of companies that will monitor your website's performance for you. They also alert you when the response time gets too high, indicating your site is down.

    Here are a few of the monitoring services that offer a free plan at the time of this writing. Note that the descriptions below relate to the free plan. If you are prepared to spend a bit of money, check their websites for their offerings:

    Pingdom:http://www.pingdom.com/

    Pages you can monitor: 1

    Checking frequency: Once every 1, 5, 15, 30, or 60 minutes

    Checks from: United States, Asia, Europe

    Sends alerts via: E-mail, SMS, Twitter or iPhone

    Reporting: Detailed downloadable stats showing the result of each check

    Mon.itor.us:http://mon.itor.us/

    Pages you can monitor: Unlimited (1 per contact e-mail address)

    Checking frequency: Once every 30 minutes

    Checks from: United States, Europe

    Sends alerts via: E-mail, SMS, Twitter, or IM

    Reporting: Weekly reports, real-time graph

    dotcom-monitor:http://www.dotcom-monitor.com/

    Free 30-day trial

    Pages you can monitor: Unlimited

    Checking frequency: Once per minute

    Checks from: United States, Europe, Israel

    Sends alerts via: E-mail, Phone, SMS, Pager, SNMP

    Reporting: Daily, weekly, and monthly e-mails, extensive online reports, and graphs

    247webmonitoring:http://247webmonitoring.com/

    Pages you can monitor: 5

    Checking frequency: Once every 15, 30, or 60 minutes

    Checks from: United States

    Sends alerts via: E-mail

    Reporting: Real-time graph

    Now that we've seen the process of assuring satisfactory performance, let's focus on how to diagnose and fix performance problems. After all, that is what this book is all about.

    High-level diagnosis with Waterfall charts

    Because our goal is to make a given web page load quicker, let's enumerate the components that make up a web page:

    The file with the HTML: In the ASP.NET world, this file normally has the extension .aspx. Because of this, in the remainder of this book, I'll refer to this file as the main .aspx file. Without this file, there is no page. Generating this file most often takes most of the server resources required to generate the overall page.

    Images and flash files: These files are often large and numerous.

    JavaScript and CSS files: These files can block rendering of the page.

    Based on this, we can categorize bottlenecks that slow down the page-loading into these broad categories:

    Main .aspx file takes too long to generate

    Main .aspx file takes too long to transfer from server to browser

    Images (and flash files) take too long to transfer

    JavaScript and CSS files block page rendering

    In order to speed up loading of a page, we need to know in which of these categories the bottleneck falls. This is the focus of the remainder of this chapter. Once you know the broad category, you can further pinpoint the bottleneck and fix it. You'll see how in the subsequent chapters.

    How do I figure out in which broad category the bottleneck falls? A simple way to do that is with a Waterfall

    Enjoying the preview?
    Page 1 of 1