Response.Redirect告訴瀏覽器請求另一個不同的頁面,這常常用於引導用戶到登錄頁面或者出錯處理頁面。由於重定向強迫了一個新頁面請求,結果是瀏覽器必須要與Web服務器循環2次,並且Web服務器必須處理一個額外的請求。IIS5.0引進了一個新功能Server.Transfer,它執行在同一服務器上的頁面傳輸,這將避免額外的瀏覽器-Web服務器的數據循環,形成良好的系統性能,對於用戶也有較好的響應時間。
技巧17:避免使用服務器變量
存取服務器變量導致Web站點建立一個特殊的請求並收集所有的服務器變量,而並不是你要求的那個變量。這類似於在文件夾中取回一個特殊的文件,要想取回一個文件,就得首先獲取所在文件夾的信息。
不要存取非法的Request對象(比如Request("Data")),對於那些不在Request.Cookies、Request.Form、Request.QueryString或者Request.ClientCertificate中的項目,隱含就指向了Request.ServerVariables變量,而這些變量要比其他集合對象慢得多。
技巧18:調整Web服務器
有幾個IIS調整參數可以提高站點性能。比如,對於IIS4.0,我們經常發現提高ASP ProcessorThreadMax參數能夠產生重大的效果,特別是在那些要等待後臺資源比如數據庫或中間件產品的站點。在IIS5.0中,你可以發現調整ASP線程通道要比調整AspProcessorThreadMax效果更佳。
最佳的配置設定取決於應用程序代碼、支持的硬件設備以及客戶端的工作量。發現最佳配置的唯一方法就是測試。
相關參考資源
Optimizing ASP scripts
- Developing Scalable Web Applications
- Got Any Cache? by Nancy Winnick Cluts
- Maximizing the Performance of Your Active Server Pages by Nancy Winnick Cluts
- 15 Seconds: Performance Section
- Enhancing Performance in ASP - Part I by Wayne Plourde
- When is Better Worse? Weighing the Technology Trade-Offs by Nancy Winnick Cluts
- Speed and Optimization Resources by Charles Carroll
Tuning IIS
- The Art and Science of Web Server Tuning with Internet Information Services 5.0
- Leveraging ASP in IIS 5.0 by J.D. Meier
- Tuning IIS 4.0 for High Volume Sites by Michael Stephenson
- Tuning Internet Information Server Performance by Mike Moore
- Navigating the Maze of Settings for Web Server Performance Optimization by Todd Wanke
- Managing Internet Information Server 4.0 for Performance by Hans Hugli
ADO and SQL Server
- Top Ten Tips: Accessing SQL Through ADO and ASP by J.D. Meier
- Improve the Performance of your MDAC Application by Suresh Kannan
- Pooling in the Microsoft Data Access Components by Leland Ahlbeck and Don Willits
- SQL Server: Performance Benchmarks and Guides
- Improving the Performance of Data Access Components with IIS 4.0 by Leland Ahlbeck
- Microsoft Data Access Components (MDAC) and ActiveX Data Objects (ADO) Performance Tips by Leland Ahlbeck
- Microsoft SQL Server 7.0 Practical Performance Tuning and Optimization - The Server Perspective by Damien Lindauer
- Microsoft SQL Server 7.0 Practical Performance Tuning and Optimization - The Application Perspective by Damien Lindauer
- Accessing Recordsets over the Internet by Dino Esposito
ASP components and threading models
- ASP Component Guidelines by J.D. Meier
- Q243548: INFO: Design Guidelines for VB Components under ASP
- Threading Models Explained by Nancy Winnick Cluts
- So Happy Together? Using ActiveX components with Active Server Pages by Nancy Winnick Cluts
- Developing Active Server Components with ATL by George Reilly
- Agility in Server Components by Neil Allain
- Building High-Performance Middle-Tier Components with C++ by Jon Flanders
- Active Server Pages and COM Apartments by Don Box
- House of COM: Active Server Pages by Don Box
- House of COM: Contexts by Don Box
- House of COM: Performance Trade-offs of the Windows 2000 Component Execution Environment by Don Box
- Building COM Components That Take Full Advantage of Visual Basic and Scripting by Ivo Salmre
- Component Design Principles for MTS
Dictionary components
- Creating a Page Cache Object by Robert Coleridge
- Abridging the Dictionary Object: The ASP Team Creates a Lookup-Table Object by Robert Carter
- Caprock Dictionary
- Site Server Commerce Edition includes a dictionary component
Session state
- Q175167: HOWTO: Persisting Values Without Sessions
- Q157906: HOWTO: How To Maintain State Across Pages with VBScript
- XML-based Persistence Behaviors Fix Web Farm Headaches by Aaron Skonnard
- House of COM: Stateless Programming by Don Box
Performance and scalability
- Blueprint for Building Web Sites Using the Microsoft Windows DNA Platform
- Server Performance and Scalability Killers by George Reilly
- Microsoft Visual Studio Scalability Center
- Fitch & Mather Stocks 2000
- Tuning the FMStocks Application
- High-Performance Visual Basic Apps by Ken Spencer
- Duwamish Books, Phase 4
- Top Windows DNA Performance Mistakes and How to Prevent Them by Gary Geiger and Jon Pulsipher
- Building from Static HTML to High-Performance Web-Farms by Shawn Bice
Tools
- Microsoft Web Application Stress Tool
- I Can? Stress It Enough -- Load Test Your ASP Application by J.D. Meier
- Windows DNA Performance Kit
- Monitoring Events in Distributed Applications Using Visual Studio Analyzer by Mai-lan Tomsen
Books
- Professional Active Server Pages 3.0, Wrox Press. (Especially Chapter 26: Optimizing ASP Performance, by George Reilly and Matthew Gibbs)
- Microsoft Internet Information Services 5.0 Resource Guide (bundled with Windows 2000 Server Resource Kit, Microsoft Press.
- Microsoft Internet Information Server Resource Kit (for IIS 4.0), Microsoft Press.
- Programming Distributed Applications with COM and Microsoft Visual Basic 6.0 by Ted Pattison, Microsoft Press.
- Effective COM by Don Box, Keith Brown, Tim Ewald, and Chris Sells; Addison-Wesley.
- Developing Web Usability: The Practice of Simplicity by Jakob Nielsen, New Riders.
ASP Web sites
- Microsoft TechNet for IIS
- LearnASP.com
- 4GuysFromRolla.com
- 15Seconds.com
- AspToday.com
- Asp101.com
- AspLists.com. Many specialized mailing lists including:
- UseIt.com: Web Usability
ASP style
- ASP Best Practices by George Reilly
- ASP Quick Lessons by Charles Carroll
- Planning for ASP by John Meade
- ASP Guidelines by J.D. Meier
XML
- Inside XML Performance by Chris Lovett
- Inside MSXML3 Performance by Chris Lovet