万本电子书0元读

万本电子书0元读

顶部广告

ASP.NET Site Performance Secrets电子书

售       价:¥

0人正在读 | 0人评论 9.8

作       者:Matt Perdeck

出  版  社:Packt Publishing

出版时间:2010-10-13

字       数:735.1万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
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.
目录展开

ASP.NET Site Performance Secrets

Table of Contents

ASP.NET Site Performance Secrets

Credits

About the Author

About the Reviewers

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Errata

Piracy

Questions

1. High Level Diagnosis

Assuring good performance

Continuous monitoring

Setting performance goals

Iterative improvements

Monitoring services

High-level diagnosis with Waterfall charts

Creating a Waterfall chart using Firebug

Installing Firebug

Creating the Waterfall chart

Interpreting the Waterfall chart

Request and response information

Timeline information

Page-level information

Saving information

Categorizing bottlenecks using Waterfall charts

Scenario 1: Main .aspx file takes long to arrive

Scenario 2: Main .aspx file takes long to load over the Internet

Scenario 3: Images take long to load

Scenario 4: JavaScript file blocks rendering

Waterfall generators for other browsers

Fiddler (browser-independent)

Internet Explorer via WebPagetest

Google Chrome

Apple Safari

More Waterfall chart generators

Find out more

Summary

2. Reducing Time to First Byte

Pinpointing bottlenecks

Memory

Windows Server 2003

Windows Vista, Windows Server 2008, or Windows 7

Simulating a memory shortage

Caching

CPU

Thread usage

Long wait times

Additional measures

Deployment

Building projects in release mode

Publishing your website

Disabling debug mode

Reducing number of assemblies

Reducing round trips

Using Server.Transfer instead of Response.Redirect

Always specifying the default file in URLs

Permanent redirects

Minimizing CNAME records

SSL

Unwanted requests

Search engine bots

Hotlinking

CAPTCHA

Scrapers

Usability testing

Find out more

Summary

3. Memory

Managed resources

Life cycle

Generations

Large Object Heap

Counters

CLR profiler

Garbage collector versions

Acquire late

Release early

Using StringBuilder to concatenate strings

Using StringBuilder

When not to use StringBuilder

StringBuilder capacity

Using Compare for case-insensitive compares

Using Response.Write buffer

Pooling objects over 85 KB

Unmanaged resources

IDisposable

Counters

Sessions

Reducing session state life time

Reducing space taken by session state

Using another session mode

Stop using session state

Find out more

Summary

4. CPU

Identifying bottlenecks

Tools

Data access

Connection pooling

DataSet versus List

Returning multiple result sets

Sending multiple inserts in one go

Using native data providers

Exceptions

Revealing the time taken by exceptions

Counters

DataBinder.Eval

Garbage collector

Threading

StringBuilder

Regex instantiation

UtcNow

Foreach

Virtual properties

Avoid unnecessary processing

Trimming HTTP pipeline

Find out more

Summary

5. Caching

Browser caching

OutputCache directive

Enabling caching in code

Disabling caching in code

Proxy caching

Caching different versions of the same page

Cookies

Removing query string from URL

URLRewrite extension to IIS 7

RewritePath method in Global.asax

Resetting the form action attribute

Output caching

What to cache and what not to cache

Enabling output caching

Output cache example

VaryByParam

VaryByHeader

VaryByCustom

VaryByCustom by browser

Fragment caching

Post-cache substitution

Output cache provider

Creating an output cache provider

Set

Get

Add

Remove

Using an output cache provider

Kernel caching and IIS 7 output caching

Configuring IIS caching

Limitations of kernel caching

Checking the contents of the kernel cache

Data caching

Basic use

Expiry

Priority

File dependencies

Database dependencies

Restrictions on queries

Starting the Service Broker

Starting the listening service

Creating the dependency

Item removed callback

Things to keep in mind

Optimal use of server cache

Find out more

Summary

6. Thread Usage

Asynchronous web service access

Synchronous version

Asynchronous version

Asynchronous data access layer

Usage

Implementation

Performance testing

Asynchronous generic handlers

Synchronous version

Asynchronous version

Implementation

Performance testing

Asynchronous file writes

Synchronous version

Asynchronous version

A word of caution

Asynchronous web requests

Configuration changes

IIS 6, IIS 7 Classic Mode

I/O-related configuration

ASP.NET 2.0

IIS 7 integrated mode

Maximum queue size

Setting timeouts aggressively

Find out more

Summary

7. Reducing Long Wait Times

Measuring wait times

Creating custom counters

Creating counters with Visual Studio

Creating counters programmatically

Updating counters in your code

Viewing custom counters in perfmon

Waiting concurrently

Retrieving multiple result sets from the database

Reducing overhead by using off-box session modes

Reducing trips to the database

Setting EnableSessionState

Reducing serialization and transfer overhead

Cutting your dependence on sessions

Thread locking

Minimizing the duration of locks

Using granular locks

Using System.Threading.Interlocked

Using ReaderWriterLock

Acquiring a reader lock

Acquiring a writer lock

Alternating readers and writers

Optimizing disk writes

Avoiding head seeks

Using FileStream.SetLength to avoid fragmentation

Using 64 K buffers

Disabling 8.3 filenames

Find out more

Summary

8. Speeding up Database Access

Pinpointing bottlenecks

Missing indexes and expensive queries

Missing indexes

Expensive queries

Unused indexes

Locking

Execution plan reuse

Performance counters

dm_exec_query_optimizer_info

sys.dm_exec_cached_plans

Fragmentation

Memory

Disk usage

CPU

Fixing bottlenecks

Missing indexes

Clustered index

Non-clustered index

Included columns

Selecting columns to give an index

When to use an index

When not to use an index

Column updated often

Low specificity

When to use a clustered index

Maintaining indexes

Expensive queries

Cache aggregation queries

Keeping records short

Considering denormalization

Being careful with triggers

Using table variables for small temporary result sets

Using full-text search instead of LIKE

Replacing cursors with set-based code

Minimizing traffic from SQL server to web server

Object naming

Using SET NOCOUNT ON

Using FILESTREAM for values over 1 MB

Avoiding functions on columns in WHERE clauses

Using UNION ALL instead of UNION

Using EXISTS instead of COUNT to find existence of records

Combining SELECT and UPDATE

Locking

Gathering detailed locking information

Reducing blocking

Reducing deadlocks

Execution plan reuse

Ad hoc queries

Simple parameterization

sp_executesql

Stored procedures

Preventing reuse

Fragmentation

Index rebuild

Index reorganize

Heap table defragmentation

Memory

Disk usage

Optimizing query processing

Moving the logfile to a dedicated physical disk

Reducing fragmentation of the NTFS filesystem

Considering moving the tempdb database to its own disk

Splitting the database data over two or more disks

Moving heavily-used database objects to another disk

Using the optimal RAID configuration

CPU

Find out more

Summary

9. Reducing Time to Last Byte

Pinpointing bottlenecks

Compression

ViewState

What is ViewState?

Why reduce ViewState?

Measuring your ViewState

Quickly finding where ViewState is an issue

Measuring compressed ViewState

Having ViewState size on status bar

Optimizing forms

White space

Fixing bottlenecks

ViewState

Seeing ViewState generated by each control

Disabling Viewstate

Identifying controls that do not need ViewState

Reloading from database cache

Storing a shorter version of the property value

Storing ViewState on the server

Compressing Viewstate

Implementing compression

Implementing decompression

Using ViewState compression on a page

Reducing white space

Creating the filter

Creating the HTTP Module

Adding the HTTP Module to web.config

Additional measures

Event validation

Inline JavaScript and CSS

Avoiding inline styling

Reducing space taken by ASP.NET IDs

Opting out of IDs

Keeping IDs short

Using ASP.NET comments instead of HTML comments

Using Literal control instead of Label control

Avoiding repetition

Using shorter URLs

Find out more

Summary

10. Compression

Agreeing on compression

Configuring compression in IIS 7

Installing the dynamic content compression module

Enabling compression

Setting compression by site, folder, or file

Compression level

Disabling compression based on CPU usage

Setting the request frequency threshold for static compression

Caching compressed dynamic files

Storing compressed files in the output cache

What if a client doesn't accept compressed content?

Configuring compression in IIS 6

Switching on compression in the IIS Manager

Setting permissions on the folder where compressed static files are cached

Updating the metabase

Resetting the IIS server

Configuring compression in IIS 5

Using compression in your development environment

Installing IIS 7

Enabling compression

Creating a development site in IIS

Modifying your project so it uses the development site

Measuring the difference compression makes

Improving the compressibility of your pages

Is compression the magic bullet?

Find out more

Summary

11. Optimizing Forms

Client-side validation

ASP.NET validation controls

Quick example

Available validator controls

Validation summary

Disabling validation

Overhead

Validate JavaScript library

Initialization

Built-in validation methods

Adding validation methods

Formatting error messages

Content Delivery Network (CDN)

Overhead

Submitting forms asynchronously

UpdatePanel control

Page Methods

Web service

Generic handler

Building the generic handler

Cross Site Request Forgery (CSRF) attacks

Calling the generic handler

WCF Data Services and the Entity Framework

Creating the entity data model

Creating the WCF Data Service

Calling the WCF Data Service from JavaScript

Bugs and limitations in WCF Data Services

Allowing the precompiled site to be updatable when publishing your site

Providing database access to [NT AUTHORITY\NETWORK SERVICE]

Disabling batch compilation

Creating an activity indicator

AJAX-type grids

Free, lightweight grids

Paid, heavyweight grids

Building your own grid

Working sample code

Find out more

Summary

12. Reducing Image Load Times

Caching

Cache-Control response header

Preventing conditional requests

Expires header

Configuring Cache-Control in IIS 7

Configuring Cache-Control in IIS 6

Giving identical URLs to identical images

Serving images from cookieless subdomains

Parallel loading

Image control adapter

Image size

Using the optimal image format

Why to avoid scaling images in HTML

Tools

PNGOUT

Pngcrush

Jpegtran

NConvert

ImageMagick

Combining images

Ways to avoid images

Rounded corners in CSS

Utility symbols

Shortcut icon

Content Delivery Network

Find out more

Summary

13. Improving JavaScript Loading

Problem: JavaScript loading blocks page rendering

Confirming with a test site

Approaches to reduce the impact on load times

Approach 1: Start loading after other components

Approach 2: Loading JavaScript more quickly

Techniques used with images

Free Content Delivery Networks

GZIP compression

Minifying a JavaScript file

Tools

Impact of minification

Implementing minification

HTTP handler

Configuring the handler in web.config

Enabling GZIP compression for dynamic files

Combining or breaking up

When and why to combine

When and why to break up

Measuring each scenario

Preventing 304 messages

Implementing automatic file combining

ASP.NET ScriptManager Control

Compression (deflate) and HTML, CSS, JS Minification in ASP.NET

Combres 2.0

FileCombine

Removing unused code

Approach 3: Loading JavaScript on demand

Separating user interface code from render code

OnDemandLoader library

Initializing OnDemandLoader

Invoking not-yet-loaded functions

Preloading

Approach 4: Loading Javascript without blocking

Moving all <script> tags to the end of the page

Separating user interface code and render code

Introducing page loading indicator

Loading code in parallel with page

Initializing the loader object

Loading the code while the page is loading

Ensuring that code runs after the page is rendered

Improving ad loading

Improving CSS Loading

Minifying CSS

Removing unused CSS selectors

Loading CSS without blocking rendering

Find out more

Summary

14. Load Testing

Using a load test environment

Load testing individual components during development

Testing page-by-page

Testing performance improvements

Acceptance testing

Additional best practices

Building a load test environment

Hosting the website under load

Installing IIS on Vista or Windows 7

Limitations

Installation

Opening the Firewall

Installing Windows Server 2008

Running Windows Server 2008 alongside Vista or Windows 7

Installing Virtual PC 2007

Installing Windows Server 2008

Getting more out of Virtual PC

Keystrokes

Screen size

Installing Virtual Machine Additions

Creating a shared folder

Installing .NET 4 or .NET 3.5 Service Pack 1

Installing and configuring IIS 7 on Windows Server 2008

Opening the Firewall

Installing Windows Server 2003

Running Windows Server 2003 alongside Vista or Windows 7

Installing Windows Server 2003

Creating a shared folder

Installing .NET 4 or .NET 3.5 Service Pack 1

Installing and configuring IIS 6 on Windows Server 2003

Opening the Firewall

ASP.NET test site

Installing a database

Downloading

Installation

Opening port in Firewall

Enabling remote administration

Test page

Setting up a load generator

Load generation services

WCAT

Installing WCAT

Creating a simple test

Settings and scenario file

Scenario attributes

Default element

Transaction

Running a simple test

Recording scenario files using fiddler

Adding thinking time

Other free load generation tools

Visual Studio Team System 2008 Test Edition/Visual Studio 2010 Ultimate

Setting up a demo site

Creating a simple web test

Creating a second web test

Coded web tests

Combining web tests into a load test

Running the load test

Load testing components

Making sure the load generator isn’t bottlenecking

Find out more

Summary

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部