Ultra-Fast ASP.NET doc

488 990 0
Ultra-Fast ASP.NET doc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Kiessig Ultra-Fast ASP.NET Companion eBook Available this print for content only—size & color not accurate Books for professionals By professionals ® Cyan MaGenTa yelloW BlaCk US $49.99 Shelve in .NET User level: Intermediate–Advanced www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version THE APRESS ROADMAP Ultra-Fast ASP.NET Pro Silverlight for the Enterprise Pro ASP.NET 3.5 in C# 2008 Pro Silverlight 3 in C# Pro ASP.NET MVC Beginning Silverlight 3 Beginning ASP.NET E-Commerce in C# Beginning ASP.NET 3.5 in C# 2008 ISBN 978-1-4302-2383-2 9 781430 223832 5 49 9 9 Ultra-Fast ASP.NET Dear Reader, Ultra-Fast ASP.NET presents a practical approach to building fast and scal- able web sites. In addition to a wealth of tips, tricks, and secrets, I present a way of thinking about performance issues that will help you obtain real results. By applying the Ultra-Fast approach to your projects, you’ll squeeze every last ounce of performance out of your code and infrastructure, giving your sites unrivaled speed. I wrote this book in part because I want the Web to be better and faster than it is today and because I want you to help make that happen. I share the insights I’ve developed during the time I’ve spent working with and advising some of the world’s largest web sites and during my 30+ years as a software architect and con - sultant. As a result, you’ll learn the best optimization and refinement techniques to give your apps a boost without the pain of tweaking and experimentation. My approach is mostly prescriptive; rather than drowning you in options, I explain specific high-impact recommendations and demonstrate them with detailed examples. Using this knowledge you’ll soon be building robust, high- performance web sites that scale easily as your site grows. You will learn how to: • Apply the key principles that will help you build Ultra-Fast and Ultra-Scalable web sites. • Use the Ultra-Fast approach to be fast in multiple dimensions. You’ll have not only fast pages but also fast changes, fast fixes, fast deployments, and more. • Identify performance traps (such as with session state) and learn how to avoid them. • Put into practice an end-to-end systems-based approach to web site performance and scalability, which includes everything from the browser and the network to caching, back-end operations, hardware infrastructure, and your software development process. Richard Kiessig trim = 7.5" x 9.25" spine = 0.9375" 496 page count The eXperT’s VoiCe ® in .neT Ultra-Fast ASP.NET Richard Kiessig Build Ultra-Fast and Ultra-Scalable web sites using ASP.NET and SQL Server i Ultra-fast ASP.NET Building Ultra-fast and Ultra-scalable Web Sites Using ASP.NET and SQL Server ■ ■ ■ Richard Kiessig Ultra-fast ASP.NET Copyright © 2009 by Richard Kiessig All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2383-2 ISBN-13 (electronic): 978-1-4302-2384-9 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Matthew Moodie Technical Reviewer: Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Copy Editors: Kim Wimpsett and Tiffany Taylor Production Assistance: Patrick Cunningham Indexer: Becky Hornyak Artist: April Milne Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders- ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please e-mail info@apress.com, or visit http://www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. iii Contents at a Glance ■About the Author xviii ■Introduction xx ■Chapter 1: Principles and Method 1 ■Chapter 2: Client Performance 13 ■Chapter 3: Caching 71 ■Chapter 4: IIS 7 127 ■Chapter 5: ASP.NET Threads and Sessions 161 ■Chapter 6: Using ASP.NET to Implement and Manage Optimization Techniques 201 ■Chapter 7: Managing ASP.NET Application Policies 229 ■Chapter 8: SQL Server Relational Database 263 ■Chapter 9: SQL Server Analysis Services 349 ■Chapter 10: Infrastructure and Operations 385 ■Chapter 11: Putting It All Together 411 ■Glossary 435 ■Index 439 ■CONTENTS iv Contents ■About the Author xviii ■About the Technical Reviewer xix ■Introduction xx ■Chapter 1: Principles and Method 1 The Difference Between Performance and Scalability 2 Why Ultra-fast and Ultra-scalable? 2 Optimization 3 Process 4 The Full Experience 5 End-to-End Web Page Processing 5 Overview of Principles 8 Performance Principles 8 Secondary Techniques 9 Environment and Tools Used in This Book 10 Software Tools and Versions 10 Terminology 11 Typographic Conventions 11 Author’s Web Site 12 Summary 12 ■Chapter 2: Client Performance 13 Browser Page Processing 14 Network Connections and the Initial HTTP Request 14 ■ CONTENTS v Page Parsing and New Resource Requests 16 Page Resource Order and Reordering 17 Browser Caching 18 Network Optimizations 19 Script Include File Handling 21 Increase Parallelism by Queuing Resources Before Scripts 22 Minimize the Number of Script Files 23 Requesting Objects After the Rest of the Page 26 Script Defer 26 Server-Side Alternatives to Script 26 Download Less 27 Reduce the Number of Resources per Page 27 Minify Your HTML, CSS, and JavaScript 28 Maximize Compressibility 30 Image Optimization 30 Web Site Icon File 34 General HTML, CSS, and JavaScript Optimization 35 Using JavaScript to Gate Page Requests 39 Submit Buttons 39 Links 40 Using JavaScript to Reduce HTML Size 41 Generate Repetitive HTML 41 Add Repetitive Text to Your Tags 43 Upload Less 43 ■CONTENTS vi CSS Optimizations 45 Image Sprites and Clustering 49 Leveraging DHTML 52 Using Ajax 52 Using Silverlight 55 Building HTML Controls 55 Calling into Silverlight from JavaScript 58 Other Ways to Use Silverlight to Improve Performance 59 Improving Rendering Speed 60 Precaching 61 Precaching Images 62 Precaching CSS and JavaScript 62 Tableless Layout Using CSS 64 Optimizing JavaScript Performance 66 Summary 67 ■Chapter 3: Caching 71 Caching at All Tiers 72 Browser Cache 73 Caching Static Content 73 Caching Dynamic Content 76 ViewState 78 Protecting ViewState Data Integrity 79 Cookies 85 Setting Session Cookies 86 Multiple Name/Value Pairs in a Single Cookie 86 Cookie Properties 86 ■ CONTENTS vii Silverlight Isolated Storage 96 Sample Application: “Welcome Back” 96 Deploying and Updating Silverlight Applications 101 Proxy Cache 101 Using the Cache-Control HTTP Header 102 Managing Different Versions of the Same Content 103 Web Server Cache 103 Windows Kernel Cache 104 IIS 7 Output Caching 109 ASP.NET Output Caching 110 ASP.NET Object Caching 117 SQL Server Caching 122 Distributed Caching 123 Cache Expiration Times 124 Dynamic Content 124 Static Content 124 Summary 125 ■Chapter 4: IIS 7 127 Application Pools and Web Gardens 127 Request-Processing Pipeline 130 Windows System Resource Manager 131 Common HTTP Issues 134 HTTP Redirects 135 HTTP Headers 136 Compression 139 Enabling Compression 140 Setting Compression Options 141 ■CONTENTS viii Using web.config to Configure Compression 142 Caching Compressed Content 143 Programmatically Enabling Compression 144 HTTP Keep-Alives 144 Optimizing Your URLs 144 Virtual Directories 145 URL Rewriting 146 Managing Traffic 150 Using robots.txt 150 Site Maps 151 Bandwidth Throttling 152 Failed Request Tracing 154 Miscellaneous IIS Performance Tuning 159 Summary 159 ■Chapter 5: ASP.NET Threads and Sessions 161 Threads Affect Scalability 161 ASP.NET Page Life Cycle 163 Application Thread Pool 165 Synchronous Page 165 Asynchronous Page 166 Load Test 167 Improving the Scalability of Existing Synchronous Pages 170 Executing Multiple Async Tasks from a Single Page 170 Handling Timeouts 172 Asynchronous Web Services 173 Asynchronous File I/O 176 Asynchronous Web Requests 178 [...]... Surprisingly, less hardware is often required, and quality assurance and operations teams can often be smaller That’s what I mean by ultra-fast and ultra-scalable (I will often refer to it as just ultra-fast for short, even though scalability is always implied.) The ultra-fast approach is very different from an impulsive, “do-it-now” type of programming The architectural problems that inevitably arise... are marathons, not sprints; advance planning and preparation pay huge long-term benefits I’ve summarized the goals of the ultra-fast and ultra-scalable approach in Table 1-1 2 CHAPTER 1 ■ PRINCIPLES AND METHOD Table 1-1 Goals of the Ultra-fast and Ultra-scalable Approach Component Ultra-fast and Ultra-scalable Goals Pages Every page is scalable and fast under load Tiers All tiers are scalable and fast... 422 Caching (Chapter 3) 425 IIS 7 (Chapter 5) 426 ASP.NET Threads and Sessions (Chapter 5) 427 xvi ■ CONTENTS Using ASP.NET to Implement and Manage Optimization Techniques (Chapter 6) 428 Managing ASP.NET Application Policies (Chapter 7) 429 SQL Server Relational Database (Chapter 8) 430 SQL Server Analysis Services (Chapter 9) ... building a document-management-oriented filesystem; I am the primary inventor of several related patents Multiple financial institutions are now using the system to help address risk-management issues I went to work for Microsoft in late 1999 My first project there was to develop a comprehensive architecture to deliver MSN content via TV-oriented middleware platforms such as WebTV using C#, ASP.NET, ... not just fast, but ultra-fast xx ■ INTRODUCTION Who This Book Is For The first two and last two chapters in this book provide information that will be useful to all web developers, regardless of which underlying technology you use The middle seven chapters will interest intermediate to advanced architects and developers who are designing, building or maintaining web sites using ASP.NET and SQL Server... 220 Dynamically Generating JavaScript and CSS 220 Example 221 Accessing ASP.NET Controls from JavaScript 222 Multiple Domains for Static Files 223 Image Resizing 224 Summary 227 ■Chapter 7: Managing ASP.NET Application Policies 229 Custom HttpModules 230 Requirements for the Example HttpModule... User Feedback 416 The Ultra-fast Spin 416 League 418 Tools 419 Architecture 420 Checklists 422 Principles and Method (Chapter 1) 422 Client Performance (Chapter 2) 422 Caching (Chapter 3) 425 IIS 7 (Chapter 5) 426 ASP.NET Threads and Sessions (Chapter... request process You should leverage the browser’s cache, cookies, on-page data (hidden fields or ViewState), proxies, the Windows kernel cache (http.sys), the IIS cache, the ASP.NET application cache, page and fragment output caching, the ASP.NET cache object, server-side per-request caching, database dependency caching, distributed caching, and caching in RAM at the database See Chapters 3 and 8 • 8 Focus... Fine-Tuning 197 Full-Custom Session State 197 Session Serialization 198 Alternatives to Session State 199 Summary 199 ■Chapter 6: Using ASP.NET to Implement and Manage Optimization Techniques .201 Master Pages 201 User Controls 204 Example 205 Registering and Using the Control ... demonstrations that help drive the points home Contacting the Author You can reach me at rick@12titans.net Please visit my web site at http://www.12titans.net/ I would love to hear about your experiences with the ultra-fast approach Techniques to improve performance and scalability are constantly evolving, along with the underlying technology I am very interested in hearing about any techniques I haven’t covered . eXperT’s VoiCe ® in .neT Ultra-Fast ASP. NET Richard Kiessig Build Ultra-Fast and Ultra-Scalable web sites using ASP. NET and SQL Server i Ultra-fast ASP. NET Building Ultra-fast and Ultra-scalable. Silverlight for the Enterprise Pro ASP. NET 3.5 in C# 2008 Pro Silverlight 3 in C# Pro ASP. NET MVC Beginning Silverlight 3 Beginning ASP. NET E-Commerce in C# Beginning ASP. NET 3.5 in C# 2008 ISBN. ASP. NET 3.5 in C# 2008 ISBN 978-1-4302-2383-2 9 781430 223832 5 49 9 9 Ultra-Fast ASP. NET Dear Reader, Ultra-Fast ASP. NET presents a practical approach to building fast and scal- able web sites.

Ngày đăng: 12/08/2014, 18:22

Mục lục

    The Difference Between Performance and Scalability

    Why Ultra-fast and Ultra-scalable?

    End-to-End Web Page Processing

    Environment and Tools Used in This Book

    Software Tools and Versions

    Author’s Web Site

    Network Connections and the Initial HTTP Request

    Page Parsing and New Resource Requests

    Page Resource Order and Reordering

    Script Include File Handling

Tài liệu cùng người dùng

Tài liệu liên quan