Speaker Kick Off Meeing

Download Report

Transcript Speaker Kick Off Meeing

DEV315
Best Practices for
running IIS 6.0 and
ASP.NET
Rob Howard
Program Manager
Web Platform & Tools Team
ASP.NET Community
Contact:
[email protected]
http://weblogs.asp.net/rhoward
ASP.NET Resources
http://www.asp.net/forums
http://www.asp.net/whidbey
http://www.asp.net/roadshow
Agenda
www.asp.net Vital Statistics
Hardware & Infrastructure
Recommendations & Resources
Live Site
www.asp.net – Vital Stats
General statistics (hosted by OrcsWeb)
Over 4,000 files
23% ASP.NET Page files (.aspx)
46% Code-behind / BLL / DAL
31% Resource files: images, etc.
Server cluster hosts many applications
www.asp.net (plus online starter kits)
weblogs.asp.net / blogs.msdn.com
forums.asp.net / www.dotnetnuke.com
www.asp.net Year-Year
May 2003
~485GB bandwidth usage
2mm Unique visitors
42K downloads of .NET Framework
23K Forum Posts
May 2004
~1.5TB bandwidth usage*
2.9mm Unique visitors
62K downloads of .NET Framework
28K Forum Posts
* With HTTP Compression / traffic due to blogs
Hardware & Infrastructure
Load Balancer
Network Hardware
Web servers
Internet Information Server 6.0
ASP.NET 1.1
Business Logic Tier
Data Access Tier
Process Boundary
Database server
SQL Server 2000
Data Tier – Stored Procedures
Original Hardware Specs.
2 Web Servers
Windows Server 2000
Dual-750 MHZ Processors
500 MB RAM
1 Database Server
Windows Server 2000
Single 750 MHZ Processor
1 GB RAM
Original Hardware
Site was highly Database bound
CPU ~95% utilization on database server
File IO bound on Database
Highly transactional / dynamic site
Lots of database updates from Forums
Lots of TempDB usage
This was our own fault
Database & logs on single disk
OS on single disk
Web Server Upgrade
Replaced Web Servers
Upgraded to Windows Server 2003
2 dual-processor 2.2 GHZ + 1 GB RAM
Windows Server 2003
More secure & easier to isolate
Better performance & scale capability
Fault tolerance & configuration
Notable
Performance improved with no code changes
A year later … still under-utilized
IIS 5 Request Processing
X
INETINFO.exe
Metabase
X X
X
User mode
Kernel
mode
TCP/IP
Request
Response
DLLHOST.exe
DLLHOST.exe
IIS 6.0 Request Processing
Inetinfo
Application Pools
WWW Service
Administration
XML
Metabase
&
Monitoring
X
…
User mode
Kernel mode
Queue
Cache
HTTP
Request
Response
Database Design Changes
ASP.NET Forums was biggest culprit
Highly transactional tables
Lots of updates (read, last visit, …)
Posts table
Stores a list of all messages
Clustered index on PostID
Denormalized data
Tracked top-level posts
Clustered index on ForumID
Database Hardware Upgrade
Single Database Server
Windows Server 2000
2 dual-processor 2.8 GHZ (Hyper-threaded)
2 GB Memory
Performance changes
Faster disks, more CPU, more memory
RAID-0 disk arrays
Separate controllers for OS, database, logs
Database Hardware Upgrade
Database no longer impacting performance
CPU utilization ~6% / avg (2003)
CPU utilization ~18% / avg (2004)
SQL is a memory hog ~1.5 GB
Memory is inexpensive, buy lots for SQL
Site Performance
HTTP Compression
Reduces bandwidth usage
Not enabled by default
Uses gzip compression
Not like IIS 5 compression
Compression was built-in, but…
…most people purchased
Steps to enable:
Good write-up at:
http://dotnetguy.techieswithcats.com/arch
ives/003475.shtml
HTTP Compression
IIS Web Service extensions
Add new Web Service extension
Http Compression (name doesn’t matter)
Add required file
\Windows\System32\inetsrv\gzip.dll
Set extension status to ‘allowed’
Edit the metabase
Requires IIS shut-down
\Windows\System32\inetsrv\MetaBase.xml
Find IIsCompressionScheme (add aspx)
Disable Process Recycle
Too aggressive
…unless leaks
…or desired
Tune Maximum Memory
Set this value
Risk paging to disk
Recommended settings
No more than 60% Physical
Using 2GB address space
No higher than 800MB
If 3GB+ address space
No higher than 1800MB
Data Abstraction Layer
Controlling Access to the Database
Data Access Layer
Class to entity relationship
[Area]DB
ControlGalleryDB
Data exchange
No DataReaders passed
Populated class instances returned
Connection string
Stored within configuration
No embedded connection strings in the app.
Business Logic Layer
Everything is a Module
Survey
HTML Module
HTML Module
HTML
Rotator
Article Module
Evolution of IBuySpy Portal
Originally code named ‘Calypso’
Based off original IBuySpy portal
Dynamic user control loading into page
Minor architecture changes
Configuration read from file
Updated Starter Kit reflects this change
BLL Code Location
All code is inline
Negative: No design-time support in VS
Positive: Isolation & easy updates
Extensive user of User Controls
Page is a frame for User Controls
Dynamically loaded / cached
Languages used
C# is primary language
Some VB code
Recommendations &
Resources
Key Performance Counters
Processor: % Processor Time
Processor time of all processors
System: Processor Queue Length
Exceeds 2 / CPU > 5 min. potential bottleneck
Physical Disk: Avg. Queue Length
Exceeds 2 / Drive > 5 min. potential bottleneck
Physical Disk: % Disk Time
General picture of how busy the disk is
Memory: Pages / Sec
Memory paged to disk
Key Performance Counters
Processor, CPU % Utilization
Low numbers = blocking or lock contention
ASP.NET, Requests Queued
Linear growth here indicates server maxed
ASP.NET Applications, Requests/Sec
Dynamic throughput (should be consistent)
ASP.NET Application, Errors Total
Indicates functional problems (should be 0)
ASP.NET App/Worker Process Restarts
Indicates serious functional problems
Tools / Resources
Recommended Reading
Microsoft SQL Server 2000 Performance
Optimization and Tuning Handbook by Ken
England, published by Digital Press
Query Analyzer
Execution Plan
Trace
SQL Profiler
Live profiling of database
Track down expensive procedures
Recommendations
De-normalize in some cases
Normalization can affect performance
Understand clustered indexes
Common data stored together physically on disk
Understand covered queries
All data stored in index – faster lookups
Use separate SQL accounts
Makes tracing / security easier
Know where you’re slow
Likely database
Definitely network
Recommendations
Cache aggressively
Per-Request or other time duration
Data Readers vs. DataSet
DataSet used when data can be cached
Return multiple results
Batch common work together
Use stored procedures
Security & Efficiency
Close connections
Ensure any open connections are closed
Recommendations
Process hop as little as possible
BLL / DAL in the same process
ASP.NET 1.1 / IIS 6 Whitepaper
Per-Request or other time duration
Using Session State on server farm
Mark as read-only if you don’t update
IIS 6 Kernel Cache
Can dramatically improve performance
ViewState size
Increases total size of page
Lessons Learnt
Hardware is inexpensive, people aren’t
Database background is critical
Database de-normalization is ok
Robots.txt file
Cross-site scripting attacks
No Ad-Hoc SQL (SQL script attacks)
HttpContext.Items (per-Request Cache)
Summary
www.asp.net
Real world web site
Community Portal
Invest in hardware
It’s ok to de-normalize for performance
Stay in the same process
Cache as much as possible
© 2004 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.