design, deploy and manage state of the art internet/intranet solutions ronnie saurenmann the red guy...
TRANSCRIPT
Design, deploy and manage state of the art internet/intranet solutions
Ronnie SaurenmannThe Red Guy (Ugly)Solution ArchitectMicrosoft Switzerland
Ronnie SaurenmannThe Red Guy (Ugly)Solution ArchitectMicrosoft Switzerland
Frank KochThe Blue Guy (Bad)Infrastructure ArchitectMicrosoft Switzerland
Frank KochThe Blue Guy (Bad)Infrastructure ArchitectMicrosoft Switzerland
Disclaimer
There is no Black or White in architecture You must not agree on all the things that we
says But you should Use your common sense
The mission
A web solution Internet or Intranet
Fast Scalable Highly Available (24 x 7)
Fully monitored Cost effective
Swiss challenge
Will not have the load of MySpace or Microsoft.com
Take the challenges of Swiss.com Comparis.ch Ricardo.ch
Logical design
.ASPXInline code
Logical design
Code Behind
.ASPXContaining HTML only
Logical design
Code Behind
Web Controls
ASCX
.ASPXContaining HTML only
Busineess Logic Layer
.dll
Data Access Layer
.dll
Process designNot optimal
Code Behind
Web Controls
ASCX
.ASPXContaining HTML only
Busineess Logic Layer
.dll
Data Access Layer
.dll
Process 1 Process 2 (ev. second machine)
Web Services, WCF, .NET Remoting
Process designOptimal performance
Code Behind
Web Controls
ASCX
.ASPXContaining HTML only
Busineess Logic Layer
.dll
Data Access Layer
.dll
Process 1 (Same App Domain)
Impact of AJAX and Silverlight
AJAX Partial need to expose services instead of
pages Silverlight
Move the UI tier from .aspx to Silverlight Needs to expose all the Business Logic as
services
AJAX / Silverlight ready
Code Behind
Web Controls
ASCX
.ASPXHTML only
AJAX.js
Data Access Layer
.dll
Process 1 (Same App Domain)
.ASMXor
.SVCJSON
Service Wrapper
Busineess Logic Layer
.dll
Silverlight.DLL & XAML
Browser
AJAX &SilverLight 1.1 alpha
Impact of AJAX and Silverlight
Architect now your solution with separate BL .DLL Best on different VS project
Write BL interfaces compatible with services technology e.g. SOAP / JSON Using DataSets as transport are not always
the best choice Silverlight 1.1 will not support DataSet (yet) Plain .NET objects (using LINQ) is probably a
better choice Works also with other platform/technologies
Internet
Backend
Perimeter`
`
`
Internal Clients
Web Servers
Web Servers
Application Servers
Database ServersHTTP/HTTPS
External Clients
Perimeter Firewall
Internal Firewall
Application Servers
About network segmenting
Regarding FirewallsHow many different firewalls do you want?
And how many can YOU configure?
Think about application firewallsISA 2006 is better than you thinkDon’t forget URLscan which is free for IIS
Add port firewalls as you likeDo you know that they come for free in the OS?Configurable via scripts & Group Policies
Port Filtering ExamplesAt your web server
From Internet / ISA: port 80 / 443 onlyTo / from intranet: all
At your DB serverFrom web server only 1433 / …To / from intranet: all
IP Sec Filter
DEMO
IPSeccmd.exe -w REG -p "Block TCP 80 Filter" -r "Block Inbound TCP 80 Rule"
-f *=0:80:TCP -n BLOCK -x
IPSeccmd.exe -w REG -p "Block UDP 1434 Filter" -r "Block Inbound UDP 1434 Rule„ -f *=0:1434:UDP -n BLOCK -x
Port Filtering: some ideasYou hardly need encryption, so don’t use itAssume your server is hacked, so block incoming traffic (on other servers)Don’t over-engineer at the beginning
Follow “external to backend” process firstDon’t forget OS Firewall configuration
Windows 2008 has combined GPs to make your life much easier
You can script this, don’t worry
Internet
Backend
Perimeter`
`
`
Internal Clients
Web Servers
Web Servers
Application Servers
Database ServersHTTP/HTTPS
External Clients
Perimeter Firewall
Internal Firewall
Application Servers
AD or not AD, this is the question
Would you use an AD in the DMZ?
Advantages
Easier management via GPCan use Kerberos delegationCan use mutual authenticationEasier account managementNo additional software costsWindows 2008:
Read-only DCNo local password caching
Disadvantages
Need more server / higher load on serverHigher risks?
If you use the same local account credentials anywayReplication needs more ports
SMTP can be used with efforts*
SummaryYou won’t probably do this on Windows 2003
Maybe you take a look again with Windows 2008
* http://technet2.microsoft.com/WindowsServer/en/library/c238f32b-4400-4a0c-b4fb-7b0febecfc731033.mspx?mfr=true
What design do you accept?
Reverse Proxy
Web Server
ISA Server Exchange 2003
Server management ideasAs more server you have in the AD, as easier
Reverse Proxy might be a good compromise
Use (local) policies to secure your server
Free templates from Microsoft.comMore management ideas later
Patching, monitoring, backup…
Separate your logical networks
Dev
Test
Real
Make sure, your developer have no direct access to the productive servers (Use IP filter, firewalls, VLAN…)
No, they really don’t need it
Take a look at MSF to learn more (www.microsoft.com/msf)
DevelopmentMaybe on your Vista client (IIS 7)
No site limits, “just” connection limitsLocal admin or not?
Think about Virtualized Environments“Free” for Microsoft customers:
Free Virtual PC 2007, Virtual Server 2005 R2Free guest OS
4 for Enterprise Host EditionsUnlimited for Datacenter Host Editions
System Center Virtual Machine Manager
Virtual Machine Manager At-A-Glance
Live Thumbnail
Host Groups
Centralized Library
VMViews
Context Sensitive Actions
Web-based UI
Centralized Library
Web Interface for Delegated
Provisioning
Delegated User Begins Creating Virtual Machine
Virtual Machine Automatically
Placed on Optimally
Designated Host
Updated Web Interface for Delegated
Provisioning
Virtual Machine Hosts
Virtual Machine Created from
Administrator-Assigned Template
Delegated Provisioning
Developing the solution
Performance and Scalability Just buy better HW
Or not!
Code profiling
Goal is to optimize what make sense Find the slowest most used functions
Code profiler is part of Visual Studio 2005 Team Edition for Software Developer Works on web apps too
Code profiling
Stress testing
ASP.NET Web Testing Integrated into Visual Studio 2005 Recorded tests
XML format List of URLs and Parameters Validation and Extraction
Coded tests Convert from Recorded Tests Extensible via Program Logic
Not only for ASP.NET HTTP-based / Any web page
Can be used to test Web Services
XML
Stress test tool
Design For A Web Farm (even for single machine deployment)
Design for deployment within a Web farm Never assume that a client will return to
the same machine Distributed access to session state Limit use of class (static) fields and
methods Lazy initialization of cached data Can start, stop, recycle at anytime
Session state management
My real fixation
Session state mangement Do you really need session state?
Consider alternatives Use HttpContext.Items
For items that should live only for the request Use viewstate or cookies
For small items like Roles, Language settings, etc...
Use Cache For perf improvement and larger items
Even better if you can share it across users Private cache with UserID + Key
State Alternatives
Session state mangement
Use a DB If you need load balancing and fault tolerance
you would chose anyway SQL as a State server
Store only the needed stuff, not the full state Better control on read and writes
Not every page reads and writes Shopping basket is a good candidate for
direct DB storage
Use Session State Wisely
If Session state is required, use out-of-process features
ASPState Service SQL Server
Enables Web farm deployment and improves reliability Session state survives process recycling! Session state survives crashes/restarts Multiple machines point to a common state store
But there is a perf penalty Disable it on the page that you don’t need it
<%@ EnableSessionState=“false” %> <%@ EnableSessionState=“readonly” %>
Session State Performance
0
200
400
600
800
1000
1200
1400
ASP.NET SQL Store ASP.NET State Store ASP.NET InProc
Req
ues
ts/S
ec (
2P S
erve
r)
Caching
StaticD
ynam
ic
Dyn
amic Static
Design For Caching
Leverage the built-in ASP.NET caching features Output Caching Partial Page Caching Cache API
HttpRuntime.Cache
Recommendation: Specifically design pages around these features
– can lead to massive perf wins Ajax style app will put even more load on your
server
Downstream Cache
Output Cache generates HTTP headers for downstream caching servers Microsoft Internet Security and Acceleration
Server Akamai
Potentially reducing the load on your server as downstream caching technology caches documents
Partial Page Caching
Partial Page Caching allows caching page regions using user controls (.ascx) User controls have <%@ OutputCache %>
directive
Additional Features “VaryByControl”– Varies cached items by controls “VaryByCustom” – Allows user cache key method
Recommendations: Look to use this feature very aggressively If you don’t think you can use it, look again
because you haven’t thought about it hard enough
SQL Caching basics Cached items should be invalidated when
underlying data changes Two mechanisms are available to determine
changes: Polling mechanism with SQL 2000 Query notifications with SQL Server 2005
Queries must explicitly include column names in the SELECT statement
Table names in queries must include the ownername e.g. "dbo.authors".
SQL 2005 Notification architecture
ASP.NET SQL Server
Northwind
Notification Delivery ServiceTCP Port 1433
SqlCommand
SqlCacheDependency
Page
DataSet
Cache
Change detection
Caching
Cache Properties in Config <caching> section group under
<system.web>: Cache
limiting the memory usage disabling features
outputCache disabling output or fragment caching.
outputCacheSettings settings that can be used by individual
pages/controls
Kernel Caching in IIS6/7
ASP.NET leverages kernel cache on IIS6/7 As fast as static html in these cases Most home pages could be cached in this way
Requirements for kernel cache promotion: HTTP GET Request (no posted pages) No VaryByParam No VaryByHeader No security restrictions to page
Kernel Caching + config
Distributed cache (Why?)Web Server SQL Server
CacheMiddle tier
Distributed cache Web Server SQL Server
SQL Server Caching tier
Replication
Distributed cache (best)IIS with .NET Cache
SQL Server
SQLDependency (notification)
SQL Server
Connection Pooling ADO.NET has built-in connection pooling
Automatic caching/re-use of connections Recommendation:
“Open connections in your code late, and then close them early”
Don’t hold on to connections for long periods of time – do not try to build your own “smart” connection pool logic
Close the connection as soon as you are finished with it (this returns it to the pool) Explicitly Call Dispose on Resources You Open
SQL Connection security Standard (sa, password)
Easier to set up A bit faster (almost negligible)
Windows (Integrated) Much more secure
no passwords in config files Easier deployment of config files
Password encrypted on the wire Generally, local accounts are faster than domain accounts.
Domain accounts are easier to administer Need to create a new application user Needs an AppPool for each app-user
Sharing a Pool means sharing the same app-user
Impersonation
Impersonation Don’t impersonate end user
One connection per user! Use an application user Do security check on the middle tier Impersonation on its own does not cause
performance issues but prevents efficient resource pooling New connection cost time and memory plus are not
infinite Rule of thumb for perf max 300-400 connection
SQL Perf
Performance and Scalability Issues Not knowing the performance and scalability
characteristics of your system Retrieving too much data Misuse of transactions Misuse of indexes Inefficient schemas Using an inefficient disk subsystem
Too many CPU but not enough disks!
Dynamic SQL vs. Stored Procedures
What about performance? The first call the SP will be faster The second call a SP or parameterized
dynamic SQL are about the same (SQL Server and ADO.NET)
A non parameterized dynamic statement will always be slower
Dynamic SQL
Always use parameterized statements Faster
Compilation cached Plan cached
Avoids SQL Injection attacks
Isolation Level
Use the Appropriate Isolation Level WITH NOLOCK (READUNCOMMITED)
Huge perf gain, don’t need to wait for others commit
But can read dirty data (that will not exit in case of an abort)
WITH READPAST Skips the locked row Good for job queue / polling Good for table with inserts but few updates (e.g
message board, car listing, etc..)
Isolation level select hints
Indexes Create indexes based on use Create an index on all foreign keys Consider indexes on columns used in
WHERE, ORDER BY, GROUP BY, and DISTINCT clauses
Remove unused indexes Use the Index Tuning Wizard Do maintenace plan!!
Update statistics Index rebuild
Paging done right
Needs to retrieve and transfer only the needed rows (between SQL and IIS) E.g. starting from row 134240 and max 25
rows Should stop the query as soon as reached the
scope e.g. at row 134265. Most solutions move too much data around
E.g 132465 rows moved from DB to Web Server to produce a page that displays 25 rows
Must support sorting
Paging done right
Using LINQ with “skip” and “take” Optimized with new ROW_COUNT feature in
SQL Server 2005 Page 1 or Page 10000 same speed
Query stops as soon as it has the right page size (e.g 10 rows)
Only the page size (e.g. 10 rows ) is transferred from the DB
Falls back to a simpler version on SQL 2000
Can be done without LINQ too http://weblogs.asp.net/scottgu/archive/
2006/01/01/434314.aspx
Paging with LINQ
Design & plan your productive environment
Standalone Web
Server
Standalone Web Server with
Redundant Hardware
Web Server Failover Cluster
Load-balanced Web Server
Increasing Availability
Availability vs. costs
Redundant hardwareRedundant hardware can be one option. Pick the parts you are most afraid about
Power supplies (yes, no, maybe?)RAID storage (disks will fail one day!)Network cards (cables? switches? internet?)“RAID” for memory (support in rack / case?)Redundant motherboards, processors…
Very expensive, but possible
NEC Express5800/1320Reliability and Performance through the fusion of the NEC A3 chipset and the Dual-Core Intel® Itanium® 2 processor
Supercomputer-class PerformanceScalable performance powered by the Dual-Core Intel® Itanium® 2 processorVery Large Cache ArchitectureDedicated Cache Coherency Interface
Outstanding Flexibility and OperabilityInvestment protection: Easy migration to future processorsResource virtualization through floating I/OSuperb Windows Server support and rich scale-up application lineupSuperior standard chassis configuration:Small footprint and highly scalable I/O
Things to know about clusteringDo NOT cluster IIS with Cluster service
NLB is the smarter choiceSoftware NLB is not as bad as people think
Find the right balance between switches, uni- or multicast and NIC teaming. It will work, but not for all combinations!
Scales up to 32 nodesUse DNS RR for more<16 seems best choice
1 Server 2 Server 3 Server 4 Server0
1000200030004000500060007000
Concurrent User( 1 sec. avg. Response time)
Standalone Web Server
Standalone Web Server with Multiple
Sites
Load-balanced Web Cluster
Increasing Scalability
Single CPUWeb Server
(1 processor)
Multi CPUWeb Server
(2 processors)
Multi CPUWeb Server
(4 processors)
Multi CPUWeb Server
(8 processor)
Scale Out
Sca
le U
p
Incr
easi
ng S
cala
bilit
y
Scalability vs. costs
Things to know about scalabilityNetwork is the first limitation
100 Mbit cards allow ~11 Mbyte / secondDon’t forget system bus speed (66 MHz cards)(SSL) Offload NICs frees processor cycles
There is a free add-on for Windows Server 2003Windows Server 2008 allows even more offloading
RAM is nextContent from RAM is faster than from disk64bit platform allows more RAM than 32bit
Terrabytes vs. 2 Gbyte
32-bit and 64-Bit Comparison32-bit Memory Limitations
Can only address ~2 gigabytes no matter how much memory in machineBasically allowing you around 800 MB for data/pages caching
64-bit .NETCan address ~ 1 terabyte per process
Impact on Middle Tier ApplicationsApplications that cache/manipulate large amounts of data in-memory (object-level caching).NET Cache API
32-bit .NET 2.0Windows Server 2003
CachePerf.NET 2.0 32-bit Windows
88101023
7491
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
0 5000 10000 15000 20000 25000 30000 35000 40000
Unique Possible Queries
Pe
ak
TP
S
64-bit .NET 2.0Windows Server 2003
CachePerf .NET 2.0 64-bit Windows
64636450 6423 6414
13 80
1000
2000
3000
4000
5000
6000
7000
0 5000 10000 15000 20000 25000 30000 35000 40000
Unique Possible Queries
Pe
ak
TP
S
More hardware ideasUse Multicore instead of multi processors
Cheaper hardware, less licensing costsBe smart on processor / system design!
RAM & system bus access, power consumption…
Chose right hardware for right OS edition
Web vs. Standard vs. Enterprise vs. Datacenterhttp://www.microsoft.com/technet/prodtechnol/windowsserver2003/
technologies/webapp/iis/iis6perf.mspx
OS edition comparisonWebserver Standard Enterprise Datacenter
RAM 2 GByte 4 GByte 64 GByte 128 GByte
Processors 2 4 8 32
Architecture
32bit 32 / 64bit 32 / 64bit 32 / 64bit
Clustering NLB NLB NLB / MSCS NLB / MSCS
Media Srv Yes Yes Yes
Virt. Lic. 0 0 4 Unlimited
Misc Hot add mem
Hot add mem Hot add mem
Database Server Failover Clustering
Shared Disk Array
2nd Private ‘Heartbeat’ network
Clustered Servers
ClientsVirtual Server
Primary Network
How Database Mirroring WorksAsynchronous Mirroring
MirrorPrincipal
Log
Application
SQL Server SQL Server
2
Data DataLog
>>2
>2
>2 >>>2
3
>>>2
1
Commit
How Database Mirroring WorksSynchronous Mirroring
MirrorPrincipal
Log
Application
SQL Server SQL Server
2
2.1
4
Data DataLog
3>2 >3
5
Witness
1
Commit
Database Mirroring Failover
Operation Mode Witness Safety
LevelAutomatic Failover
Possible Data Loss on Failover
Synchronous with Witness Yes FULL Yes No
Synchronous without Witness
No FULL No No
Asynchronous No OFF No Yes*
ALTER DATABASE <database> SET PARTNER SAFETY {FULL | OFF}
* For planned downtime scenarios, the best practice recommendation is to change the safety mode to FULL (synchronous), do a manual failover, and then put the
safety mode back to OFF (asynchronous), wherever applicable, to avoid data loss.
Category Scenario Standard Edition
EnterpriseEdition
High Availability
Database Mirroring for High Transactional Systems
Data Integration & Cleansing
Integration from Multiple Data Sources Replication with Oracle Database Snapshot
Business Intelligence
High Scale & Real Time Analysis and Reporting Complex Analytic & Data Mining
Scalability
Number of CPUs 4 64
Multi-Instance Support 16 50
Dynamic AWE Memory Management
Indexing
Table and Index Partitioning Indexed Views Parallel Index Operations Parallel Consistency Checks (DBCC)
SQL Server Editions
Feature Standard Edition Enterprise Edition
Failover Clustering 2-nodes Only Up to 8 nodes
Database Mirroring Safety FULL Only All Modes
Database Snapshot
Fast Recovery
Online Index Operations
Online Page and File Restore
Parallel Index Operations
Updateable Distributed Partitioned Views
Table and Index Partitioning
High Availability Options
Not all problems can be addressed by adding more hardware
Bad application design or bad code can be one reason for bad performanceMicrosoft Log Parser (free) can help to identify requests using most resources:
SELECTTOP 10STRCAT(EXTRACT_PATH(cs-uri-stem),'/') AS RequestPath,EXTRACT_FILENAME(cs-uri-stem) AS RequestedFile,COUNT(*) AS Hits,MAX(time-taken) AS MaxTime,AVG(time-taken) AS AvgTime,AVG(sc-bytes) AS AvgBytesSentFROM %source% TO %destination%GROUP BY cs-uri-stemORDER BY MaxTime, TotalHits DESC
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1287
Server Farms
UNC path: what to rememberIIS 6 (and higher) will cache UNC
content1 connection per user per UNC path
Registry keys for max. port numbers usedYour file server might have an issue, too!
Designate a dedicated user for access!By default, every 5sec ask for file “change time”
Make UNC path high availableDFS or cluster technologies
remember time-outs!
II7: supports UNC config files
1. Configure master server
Life Before IIS7
IIS6
IIS6
IIS6
Replication and synchronization are challenging, requiring custom code
XML
Metabase.XML
XML
Metabase.XML
XML
Metabase.XML 2. Replicate config
3. Change configuration
XML
XML
XML
4. Re-replicate config
Replication and Synchronization
IIS7
IIS7
IIS7Shared App
Hosting
UNC Share
dConfig
Configuration is shared between multiple nodes, just stays in sync
XML
AppHost.config
Staging and Rollback
IIS7XML
AppHost.config
IIS7
IIS7
UNC
Staging New Config
Version 2
Version 1
Easily manage multiple configuration versions for staging and rollback
AppPool
Pool normal Apps together conserve resources reduces administrative overhead
Isolate Mission-Critical Apps insulate them from misbehaving applications more easily monitor, troubleshoot different recycling needs
Create different pools by technology version Different version of.NET
1.1, 2.0
AppPools
Isolate Misbehaving Apps Microsoft.com isolates misbehaving apps from
well-behaving apps New apps go into an "on probation" pool If the app proves to be stable over time
it is moved to a pool for well-behaved apps
Consolidate reliable applications or static sites into a single
pool Watch for Windows Authentication to DB
Needs a pool for each app-user
.NET Versioning
.NET Framework 3.0
=.NET Framework 2.0 + bunch of new DLLs
If you have already installed .NET 2.0, installing .NET 3.0 will not break
existing application
.NET Versioning.NET Framework 3.5
(fresh install of Windows Server 2008 has 2.0 + SP1)
=.NET Framework 2.0 + SP1 + 3.0 + SP1 + bunch of
new DLLs
If you have already installed .NET 2.0 or 3.0, installing .NET 3.5 will apply a Service Pack 1 but should not break existing application
but you need to retest
Deployment
XCOPY deployment
GAC Don’t use it
Avoid XCOPY Under Heavy Load For production environments you should
remove a server from rotation stop IIS perform the XCOPY update restart IIS put the server back into rotation
XCOPY
Copy 50 files to a virtual directory each file copy takes 100 milliseconds the entire file copy takes 5 seconds the appdomain may be unloaded and loaded
more than once Can tune it with
waitChangeNotification maxWaitChangeNotification
Visual Studio project type
VS2005 Web Applications Web Application Project template (included in VS2005
SP1) mirrors the 1.1 file structure Single assembly For complex web application it is the recommended choice
VS2005 Websites Referred to as the web site template Web app defined by files in a folder
No project file needed Dynamic Compilation / Multiple assemblies
use the Web Deployment project add-in In my opinion good only for quick prototype
Tips Try to generate fewer assemblies
Use Web Application project template Or use the Web Deployment project add-in
http://msdn2.microsoft.com/en-us/asp.net/Aa336619.aspx
Or aspnet_merge.exe
Ensure pages are batch compiled As the number of assemblies in a process
grows the virtual address space can become fragmented
When the virtual address space is fragmented, out-of-memory conditions are more likely to occur
Debug is false
Ensure debug is set to false Pages are not batch compiled Pages do not time out Additional files are generated in the
Temporary ASP.NET Files folder System.Diagnostics.DebuggableAttribute is
added to generated code it disables certain optimizations
Monitoring & Operations
System Center Operations Manager
Service (and server) monitoringHealth, availability, performanceMonitoring, alerting & reporting
Agents for Windows & non-WindowsNetwork, hardware, clients, SAP…From Microsoft and our partners
Create your own management packsIncl. design your own Distributed Applications
What Is a Distributed Application?
Designing Distributed Applications
Demo
Monitoring Data Sources
Monitoring Custom Applications
Monitoring Web Sites and Services
Recording a Browser Session
Website and database monitoring
Demo
SharePoint Farm Layout
116
Database
File Group
File
117
Detail einer SQL Datenbank
Monitor .NET applications.NET application health (Auto-discover)
Handled & unhandled execeptionsPerformance degradation issues
Extended by AviCode (www.avicode.com)
WinForms, WCF…Event correlation client / serverExtensive reporting
ASP.NET 2.0 Instrumentation
New facilities for analyzing health and performance and diagnosing failures
Name Description
Performance counters New peformance counters supplement the onesintroduced in ASP.NET 1.x
Windows event tracingIntegration with ETW subsystem to support low-overheadtracing of HTTP requests through the system
Application tracing ASP.NET trace facility upgraded with new features andto allow coupling to System.Diagnostics.Trace
Health monitoringNew provider-based subsystem for logging notable events("Web events") that occur during an application's lifetime
Application Tracing
Now supports coupling to System.Diagnostics.Trace Systems.Diagnostics.Trace -> ASP.NET trace ASP.NET trace ->System.Diagnostics.Trace Web events -> System.Diagnostics.Trace
Tracing
Health Monitoring ("Web Events")
Framework for monitoring status of running applications and logging significant events Application starts and stops Failed logins and unhandled exceptions "Heartbeats" and more
Log events in Windows event log, SQL Server database, and elsewhere
Extensible and provider-based
Logging HeartBeats in the Windows Event Log
<healthMonitoring enabled="true" heartBeatInterval="3600"> <rules> <add name="Microsoft.com Heartbeats" eventName="HeartBeats" provider="EventLogProvider" profile="Default" /> </rules></healthMonitoring>
Logging Failure Auditsin SQL Server<healthMonitoring enabled="true"> <rules> <remove name="Failure Audits Default" /> <add name="Failure Audits Default" eventName="Failure Audits" provider="SqlWebEventProvider" profile="Default" /> </rules></healthMonitoring>
Web Events
Manage your solution:System Center Configuration Manager 2007Software deployment
WoL, Maintenance Windows, Task Sequences
Patch ManagemetMicrosoft, hardware, partner, own Apps
Asset ManagementHard- & software inventorySoftware metering (license & CAL tracking)Desired Configuration Monitoring
Do my IIS server look all the same?
SC Configuration Manager 2007
Demo
SC Configuration Manager 2007
Backup your solution:System Center Data Protection Manager 2007Backup Windows Server
System state, bare metal recovery (DVD, WDS)
Smart Continuous File BackupDefault: 15min with end user recovery options
(Online) Application backup & recoveryAD, SQL, Exchange, Virtual Server 2005 …Supports cluster & other availability solutions
Backup of SharePoint server farmsIIS, site DB, config DB
Clients
ActiveDirectory
File Serverswith Tape Library
DPM Servers
Online Snapshots
Exchange ServersSQL Servers
SharePoint Serversincluding clusters
Disk-based Recovery
Offline tape
Tape-based Archive
DPM 2007
Continuous Data Protection for Windows Application and File ServersRapid & Reliable Recovery from disk instead of tape
Advanced Technology for enterprises of all sizes
SC Data Protection Manager 2007
Demo
Microsoft System CenterPick the features you need
Monitoring: SC Operations ManagerConfiguration: SC Configuration ManagerBackup: SC Data Protections ManagerVirtualization: SC Virtual Machine Manager
One by one or get discounts for the suite System Center Essentials for smaller needs
No backup, web console or security rolesSC Virtual Machine Manager SB Edition
Best Practices & more
IIS 6/7 Compression (gzip) Save bandwidth
But cost more CPU Static (.htm) compression is enabled by
default You can enable it for ASP.NET content
Easier with IIS 7.0 through UI On the fly compression shutoff/resume
depending on CPU load system.webServer/httpCompression section
dynamicCompressionDisableCpuUsage dynamicCompressionEnableCpuUsage
IIS 7.0 gzip
Background work
Timer class in the System.Threading Enables you to do work without any request
Batch processing Cache preloading
Don’t abuse it Thread from ASP.NET Thread Pool consumption
Background work
Web Services and Async Pages
Web Services optimization
Consider using the OneWay attribute if you do not need a response This "fire and forget" model allows the Web
server to make the call and continue processing immediately
Works with .asmx and WCF services
ASP.NET v2 Asynchronous Page Model
Synchronous Remote resource (web service, database) is slow
threads are blocked waiting for the answers Web application may be unresponsive
Asynchronous pages Create non-blocking call to access remote
resources Isolates issue to pages accessing remote
resources Potential to reduce # threads, improve latency and
throughput Use it for
Slow Web Services calls Slow DB requests
Page lifecycle (synchronous)
…
…
LoadComplete
PreRender
PreRenderComplete
SaveViewState
Client request
page
send responseRender
…
Thread 1
Page lifecycle (Async)
…
…
LoadComplete
PreRender
PreRenderComplete
SaveViewState
Client
send responseRender
…
Thread 1
Thread 2
IAsyncResult
request page
Async Pages
What is a ‘Balanced System’?
A system where the most expensive resource can be leveraged to its maximum without any of the other components in the system bottlenecking it.
What is a ‘Balanced System’?(cont)
Disk Subsyste
m
Server
NIC
Memory
Network1
53
4
2
SQL File Layout
HBA
What is a ‘Balanced System’?Most expensive: still Processor
Increasing the number of Processors usually requires a server hardware, or hardware architecture change
Before investing in a new hardware platform carefully consider its advantages and disadvantagesWindows and SQL Server 2005 support 3 different hardware platforms:
x86 - Standard 32-bit platformIA-64 (Itanium) – Intel’s proprietary 64-bit platform (runs 64-bit code natively; 32-bit code in emulation mode)x64/EM64T - AMD/Intel supported 64-bit platform (runs 32-bit and 64-bit code natively)
Server Platform – Processor Caches
Front Side Bus by IntelOne or more processor connected over bus to Memory ManagerMemory Manager handles one or more busesMemory Access over bus and Memory Manager
Advantage:Easy to scale up building blocks in NUMA architecture. E.g. HP Superdome, IBM x-Series
Problem:Imbalance between Core Performance Processor Caches and Front Side Bus Speed can bottleneck system in memory access
Server Platform – Processor Caches
Hypertransport by AMDAMD Opteron has Memory Manager and Memory with every processorNUMA type of architecture on per processor/socket basisHypertransport connects different processors like NUMA InterconnectMostly remote memory access over Hypertransport
Advantage:Extreme fast local memory accessLess power consumption than separate Memory Manager
Disadvantage:Architecture hardly expandable beyond 4 sockets. No real good database server architecture based on more than 4 AMD socketsSupport of new memory (like DDR3) needs new processor revision
Server Platform – Processor Speed
Increased Frequency only gives advantage when memory access infrastructure is scalingSaw enough examples over last 6 years where increase in frequency did not result in proportional throughputMore price efficient to go with frequency steps offered cheaperProcessor Frequencies not comparable between different processor architectures
Save energy with modern processors
Example: Processor state power policyReduce frequency if performance allows
State Freq % Type0 2800 100 Performance1 2520 90 Performance2 2142 85 Performance3 1607 75 Performance4 964 60 Performance5 482 50 Performance
Maximum Processor State
Minimum Processor State
http://www.amd.com
It is very easy to implement these savings on capable hardware (activate in bios first!)
You can “see” the states in Perfmon
Min Processor State
Max Processor State
Performance needs
Memory – How much is enough
How much Memory?4GB per processor core is not uncommon on 64-bit systems today
First indication to evaluate:SQL Buffer Pool Cache Hit Ratio (ideally 99% to 100%)
Page Life Expectancy (150 or greater; ideally > 300) – especially when coupled with high wait times on PAGEIOLATCH_xx
Maximum workspace memory, Memory grants pending (pending memory grants may indicate memory pressure)
Lazy writes/sec constantly active
Consider adding more memory based on the above
For x64 architectures be aware of memory limits on chip sets (as of 05/2007):
Intel 4-socket chip set: 64GB using 4GB DIMMs
AMD 4-socket chip set: 128GB using 4GB DIMMs
Disk Subsystem - Design for Performance
RAID Level: 0, 1, 5, 10, 0+1RAID 10 – recommended for all kind of data and log
RAID 5 – use for small system deployment only
RAID 0 – not recommended at all
Beware of “spindle sharing”; avoid when possibleNo sharing of spindles for Tlog and data files
Extreme caution advised for sharing with other applications
Check disk latency in Perfmon1 - 5 ms for Log (Ideally 1ms or better)
10-30 ms for Data
Read and Writes CachesDo not use write cache w/o a battery backup
SQL Server File LayoutPhysical Separation of Data, Transaction log, and Tempdb (At a minimum, separate transaction log from others)How many data files/file groups?
Start with 1 data file per CPU CoreHow many log files
No need to have multiple Log Files, except for space reasonsStart with relative large Log FileUse % based growth for small files, fixed amount for larger files
Space ManagementPre-allocate space for all SQL Server database filesMonitor space usage regularly, manually grow file with proportional fill during off-peak hours, use auto-growth for safety only
TempDB can become performance critical especially with Features of SQL Server 2005 (Snapshot Isolation, Online Index Operations)
Place on disk array with excellent read/write performance (definitely move from the default drive)Multiple Tempdb files with proportional fill to avoid pagelatch contention (recommended 1 per CPU core)Manage file growth through monitoring, avoid auto-growth
NetworkMost commonly overlooked resource!Use gigabit where possible (quite affordable)Useable gigabit bandwidth typically ~350 MbpsBe careful… Network can become a bottleneck even if bandwidth not exhausted. Possible factors:
Excessively high interrupts/secDPCs localized to single processorProcessor handling interrupts/DPCs is maxed out
One NIC per NUMA node; maximum 4 to 8 cores per NIC
SQL Server Best Practices SiteOn TechNet
Get the real-world guidelines, expert tips, and rock-solid guidance to take your SQL Server implementation to the next level.
http://www.microsoft.com/technet/prodtechnol/sql/bestpractice/default.mspxContents
Technical WhitepapersToolBoxTop 10 ListsAsk a Question
Other ResourcesSQLCAT Blog: http://blogs.msdn.com/sqlcat/SQL ISV PM Blog: http://blogs.msdn.com/mssqlisv/
Performance Counters
ASP.NET 1.x defined ~60 perf counters Global - Aggregated across all applications Application - Specific to application instance
ASP.NET 2.0 adds ~25 more, including: Several that relate to health monitoring, such
as events raised total and events raised/sec Application versions of several global counters State service sessions active, abandoned,
timed out, and total You can expose your own
Perf counters
More info
Improving ASP.NET Performance
http://msdn2.microsoft.com/en-us/library/ms998549.aspx
Resources for Architect
MSDN Architecture Site Architecture Forums ARCast series Architecture Journal http://blogs.technet.com/chITPro-DE http://blogs.msdn.com/swiss_dpe_team
© 2007 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.