技巧 27:進行性能測試 正如我們在前面已經講過,性能是一個特征。如果您想要改善站點的性能,那么就制定一個性能目標,然后逐步改進,直到達到目標為止。不要,就不進行任何性能測試。通常,在項目結束時,再作必需的結構調整已經為時太晚,您的客戶將為此感到失望。將性能測試作為您日常測試的一部分來進行。可以對單個組件分別進行性能測試,如針對 ASP 頁或 COM 對象,或將站點作為一個整體來測試。
許多人使用單個瀏覽器請求頁面,來測試 Web 站點的性能。這樣做就會給您一個感覺,即站點的響應能力很好,但這樣做實際上并不能告訴您在負載條件下站點的性能如何。
一般情況下,要想準確地測試性能,您需要一個專門的測試環境。此環境應包括硬件,其處理器速度、處理器數量、內存、磁盤、網絡配置等方面與生產環境的硬件相似。其次,您必須指定客戶機的工作負荷:有多少同時的用戶,他們發出請求的頻率,他們點擊頁面的類型等等。如果您沒有站點實際使用情況的數據,您必須估計一下使用的情況。最后,您需要一個可以模擬預期客戶機工作負荷的工具。有了這些工具,您就可以開始回答諸如“如果我有 N 個同時的用戶,那么需要多少服務器?”之類的問題。您還可以找出出現瓶頸的原因,并以此為目標進行優化。
下面列出了一些好的 Web 負載測試工具。我們特別推薦 Microsoft Web application Stress (WAS) 工具包。WAS 可使您記錄測試腳本,然后模擬數百或成千上萬個用戶訪問 Web 服務器。WAS 報告很多統計信息,包括每秒鐘的請求數,響應時間分布情況和錯誤計數。WAS 有豐富的客戶機界面和基于 Web 的界面兩種,Web 界面可使您進行遠程測試。
一定要閱讀 IIS 5.0 Tuning Guide。
技巧 28:閱讀資源鏈接 下面是一些與性能有關的出色的資源鏈接。如果您想了解有關信息,請閱讀 Developing Scalable Web Applications。
資源 優化 ASP 腳本
優化 IIS
ADO 和 SQL Server
ASP 組件和線程模型
詞典組件
會話狀態
性能和可擴展性
工具
書目
ASP Web 站點
ASP 樣式
XML
優化 ASP 腳本 Developing Scalable Web Applications
Got Any Cache? Nancy Winnick Cluts 著
Maximizing the Performance of Your Active Server Pages,Nancy Winnick Cluts 著
15 Seconds: Performance Section
Enhancing Performance in ASP - Part I,Wayne Plourde 著
When is Better Worse? Weighing the Technology Trade-Offs,Nancy Winnick Cluts 著
Speed and Optimization Resources,Charles Carroll 著
優化 IIS The Art and Science of Web Server Tuning with Internet Information Services 5.0
Leveraging ASP in IIS 5.0,J.D. Meier 著
Tuning IIS 4.0 for High Volume Sites,Michael Stephenson 著
Tuning Internet Information Server Performance,Mike Moore 著
Navigating the Maze of Settings for Web Server Performance Optimization,Todd Wanke 著
Managing Internet Information Server 4.0 for Performance,Hans Hugli 著
ADO 和 SQL Server Top Ten Tips: accessing SQL Through ADO and ASP,J.D. Meier 著
Improve the Performance of your MDAC Application,Suresh Kannan 著
Pooling in the Microsoft Data Access Components,Leland Ahlbeck 和 Don Willits 合著
SQL Server: Performance Benchmarks and Guides
Improving the Performance of Data Access Components with IIS 4.0,Leland Ahlbeck 著
Microsoft Data Access Components (MDAC) and ActiveX Data Objects (ADO) Performance Tips,Leland Ahlbeck 著
Microsoft SQL Server 7.0 Practical Performance Tuning and Optimization - The Server Perspective,Damien Lindauer 著
Microsoft SQL Server 7.0 Practical Performance Tuning and Optimization - The Application Perspective,Damien Lindauer 著
Accessing Recordsets over the Internet,Dino Esposito 著
ASP 組件和線程模型 ASP Component Guidelines,J.D. Meier 著
Q243548: INFO: Design Guidelines for VB Components under ASP
Threading Models Explained,Nancy Winnick Cluts 著
So Happy Together? Using ActiveX components with Active Server Pages,Nancy Winnick Cluts 著
Developing Active Server Components with ATL,George Reilly 著
Agility in Server Components,Neil Allain 著
Building High-Performance Middle-Tier Components with C++,Jon Flanders 著
Active Server Pages and COM Apartments,Don Box 著
House of COM: Active Server Pages,Don Box 著
House of COM: Contexts,Don Box 著
House of COM: Performance Trade-offs of the Windows 2000 Component Execution Environment,Don Box 著
Building COM Components That Take Full Advantage of Visual Basic and Scripting,Ivo Salmre 著
Component Design Principles for MTS
詞典組件 Creating a Page Cache Object,Robert Coleridge 著
Abridging the Dictionary Object: The ASP Team Creates a Lookup-Table Object,Robert Carter 著
Caprock Dictionary
Site Server Commerce Edition includes a dictionary component
會話狀態 Q175167: HOWTO: Persisting Values Without sessions
Q157906: HOWTO: How To Maintain State Across Pages with VBScript
XML-based Persistence Behaviors Fix Web Farm Headaches,Aaron Skonnard 著
House of COM: Stateless Programming,Don Box 著
性能和擴展性 Blueprint for Building Web Sites Using the Microsoft Windows DNA Platform
Server Performance and Scalability Killers,George Reilly 著
Microsoft Visual Studio Scalability Center
Fitch & Mather Stocks 2000
Tuning the FMStocks Application
High-Performance Visual Basic Apps,Ken Spencer 著
Duwamish Books,Phase 4
Top Windows DNA Performance Mistakes and How to Prevent Them,Gary Geiger 和 Jon Pulsipher 合著
Building from Static HTML to High-Performance Web-Farms,Shawn Bice 著
工具 Microsoft Web Application Stress Tool
I Can't Stress It Enough -- Load Test Your ASP Application,J.D. Meier 著
Windows DNA Performance Kit
Monitoring Events in Distributed Applications Using Visual Studio Analyzer,Mai-lan Tomsen 著
書目 Professional Active Server Pages 3.0,Wrox Press(特別是第 26 章:Optimizing ASP Performance,George Reilly 和 Matthew Gibbs 合著)。
Microsoft Internet Information Services 5.0 Resource Guide(與 Windows 2000 Server Resource Kit 在一起),Microsoft Press。
Microsoft Internet Information Server Resource Kit(用于 IIS 4.0),Microsoft Press。
Programming Distributed Applications with COM and Microsoft Visual Basic 6.0,Ted Pattison 著,Microsoft Press。
Effective COM,Don Box、Keith Brown、Tim Ewald 和 Chris Sells 合著;Addison-Wesley。
Developing Web Usability: The Practice of Simplicity,Jakob Nielsen 著,New Riders。
ASP Web 站點 Microsoft TechNet for IIS
LearnASP.com
4GuysFromRolla.com
15Seconds.com
AspToday.com
Asp101.com
AspLists.com。許多專業的郵件列表包括:
Fast Code! ASP Advanced Not NewbieState Management Scalability Visual Basic Components XML C++/ATL Component Building UseIt.com: Web 可用性