design, deploy and manage state of the art internet/intranet solutions ronnie saurenmann the red guy...

174
Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Frank Koch The Blue Guy (Bad) Infrastructure Arch Microsoft Switzerla

Upload: margery-porter

Post on 19-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 2: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 3: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

The mission

A web solution Internet or Intranet

Fast Scalable Highly Available (24 x 7)

Fully monitored Cost effective

Page 4: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Swiss challenge

Will not have the load of MySpace or Microsoft.com

Take the challenges of Swiss.com Comparis.ch Ricardo.ch

Page 5: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Logical design

.ASPXInline code

Page 6: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Logical design

Code Behind

.ASPXContaining HTML only

Page 7: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Logical design

Code Behind

Web Controls

ASCX

.ASPXContaining HTML only

Busineess Logic Layer

.dll

Data Access Layer

.dll

Page 8: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 9: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Process designOptimal performance

Code Behind

Web Controls

ASCX

.ASPXContaining HTML only

Busineess Logic Layer

.dll

Data Access Layer

.dll

Process 1 (Same App Domain)

Page 10: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 11: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 12: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

AJAX &SilverLight 1.1 alpha

Page 13: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 14: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 15: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 16: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 17: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

IP Sec Filter

DEMO

Page 18: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 19: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 20: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 21: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 22: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

What design do you accept?

Reverse Proxy

Web Server

ISA Server Exchange 2003

Page 23: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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…

Page 24: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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)

Page 25: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 26: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Virtual Machine Manager At-A-Glance

Live Thumbnail

Host Groups

Centralized Library

VMViews

Context Sensitive Actions

Page 27: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 28: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Developing the solution

Page 29: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Performance and Scalability Just buy better HW

Or not!

Page 30: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 31: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Code profiling

Page 32: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Stress testing

Page 33: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 34: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Stress test tool

Page 35: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 36: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Session state management

My real fixation

Page 37: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 38: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

State Alternatives

Page 39: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 40: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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” %>

Page 41: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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)

Page 42: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Caching

Page 43: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

StaticD

ynam

ic

Dyn

amic Static

Page 44: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 45: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 46: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 47: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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".

Page 48: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

SQL 2005 Notification architecture

ASP.NET SQL Server

Northwind

Notification Delivery ServiceTCP Port 1433

SqlCommand

SqlCacheDependency

Page

DataSet

Cache

Change detection

Page 49: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Caching

Page 50: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 51: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 52: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Kernel Caching + config

Page 53: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Distributed cache (Why?)Web Server SQL Server

CacheMiddle tier

Page 54: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Distributed cache Web Server SQL Server

SQL Server Caching tier

Replication

Page 55: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Distributed cache (best)IIS with .NET Cache

SQL Server

SQLDependency (notification)

Page 56: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

SQL Server

Page 57: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 58: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 59: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 60: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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!

Page 61: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 62: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Dynamic SQL

Always use parameterized statements Faster

Compilation cached Plan cached

Avoids SQL Injection attacks

Page 63: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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..)

Page 64: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Isolation level select hints

Page 65: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 66: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 67: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 68: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Paging with LINQ

Page 69: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Design & plan your productive environment

Page 70: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Standalone Web

Server

Standalone Web Server with

Redundant Hardware

Web Server Failover Cluster

Load-balanced Web Server

Increasing Availability

Availability vs. costs

Page 71: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 72: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 73: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 74: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

1 Server 2 Server 3 Server 4 Server0

1000200030004000500060007000

Concurrent User( 1 sec. avg. Response time)

Page 75: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 76: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 77: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 78: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 79: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 80: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 81: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 82: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Database Server Failover Clustering

Shared Disk Array

2nd Private ‘Heartbeat’ network

Clustered Servers

ClientsVirtual Server

Primary Network

Page 83: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

How Database Mirroring WorksAsynchronous Mirroring

MirrorPrincipal

Log

Application

SQL Server SQL Server

2

Data DataLog

>>2

>2

>2 >>>2

3

>>>2

1

Commit

Page 84: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 85: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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.

Page 86: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 87: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 88: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 89: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Server Farms

Page 90: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 91: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 92: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Replication and Synchronization

IIS7

IIS7

IIS7Shared App

Hosting

UNC Share

dConfig

Configuration is shared between multiple nodes, just stays in sync

XML

AppHost.config

Page 93: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 94: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 95: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 96: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

.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

Page 97: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

.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

Page 98: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Deployment

Page 99: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 100: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 101: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 102: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 103: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 104: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Monitoring & Operations

Page 105: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 106: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

What Is a Distributed Application?

Page 107: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Designing Distributed Applications

Demo

Page 108: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Monitoring Data Sources

Page 109: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Monitoring Custom Applications

Page 110: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Monitoring Web Sites and Services

Page 111: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Recording a Browser Session

Page 112: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Website and database monitoring

Demo

Page 113: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

SharePoint Farm Layout

116

Page 114: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Database

File Group

File

117

Detail einer SQL Datenbank

Page 115: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 116: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 117: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 118: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Tracing

Page 119: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 120: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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>

Page 121: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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>

Page 122: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Web Events

Page 123: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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?

Page 124: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

SC Configuration Manager 2007

Demo

Page 125: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

SC Configuration Manager 2007

Page 126: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 127: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 128: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

SC Data Protection Manager 2007

Demo

Page 129: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 130: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 131: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 132: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 133: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 134: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 135: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 136: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 137: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 138: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 139: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 140: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 141: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 142: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 143: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie
Page 144: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 145: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Best Practices & more

Page 146: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 147: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

IIS 7.0 gzip

Page 148: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 149: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Background work

Page 150: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Web Services and Async Pages

Page 151: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 152: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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 153: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Page lifecycle (synchronous)

LoadComplete

PreRender

PreRenderComplete

SaveViewState

Client request

page

send responseRender

Thread 1

Page 154: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Page lifecycle (Async)

LoadComplete

PreRender

PreRenderComplete

SaveViewState

Client

send responseRender

Thread 1

Thread 2

IAsyncResult

request page

Page 155: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Async Pages

Page 156: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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.

Page 157: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

What is a ‘Balanced System’?(cont)

Disk Subsyste

m

Server

NIC

Memory

Network1

53

4

2

SQL File Layout

HBA

Page 158: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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)

Page 159: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 160: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 161: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 162: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 163: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

It is very easy to implement these savings on capable hardware (activate in bios first!)

Page 164: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

You can “see” the states in Perfmon

Min Processor State

Max Processor State

Performance needs

Page 165: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 166: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 167: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 168: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 169: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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/

Page 170: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

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

Page 171: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

Perf counters

Page 172: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

More info

Improving ASP.NET Performance

http://msdn2.microsoft.com/en-us/library/ms998549.aspx

Page 174: Design, deploy and manage state of the art internet/intranet solutions Ronnie Saurenmann The Red Guy (Ugly) Solution Architect Microsoft Switzerland Ronnie

© 2007 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.