38
Building High Building High Performance, Robust Performance, Robust Server Applications Server Applications with Internet with Internet Information Server 5.0 Information Server 5.0 Van Van Van Van IIS - Program Manager IIS - Program Manager Microsoft Corporation Microsoft Corporation

Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Embed Size (px)

Citation preview

Page 1: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Building High Performance, Building High Performance, Robust Server Applications Robust Server Applications with Internet Information with Internet Information Server 5.0Server 5.0

Van VanVan VanIIS - Program ManagerIIS - Program ManagerMicrosoft CorporationMicrosoft Corporation

Page 2: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

AgendaAgenda

What is a WindowsWhat is a Windows®® DNA Application? DNA Application? Design for Success: Building Windows Design for Success: Building Windows

DNA Applications using Internet DNA Applications using Internet Information Server 5.0Information Server 5.0 PresentationPresentation Business LogicBusiness Logic Data ServicesData Services

Testing for SuccessTesting for Success Performance Tuning ApplicationsPerformance Tuning Applications

Page 3: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Windows DNA ApplicationsWindows DNA ApplicationsWhat is it?What is it?

ExtensibleExtensible ModularModular Integrates with existing back end Integrates with existing back end

ScalableScalable High PerformanceHigh Performance High AvailabilityHigh Availability

ReliableReliable Handle failures gracefullyHandle failures gracefully

““End-to-End” Application SolutionEnd-to-End” Application Solution

Page 4: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Windows DNA ApplicationsWindows DNA Applications3-Tier Application3-Tier Application

Divide your Windows DNA Application into Divide your Windows DNA Application into three logical layersthree logical layers PresentationPresentation Business LogicBusiness Logic Data ServicesData Services

Use Active Server Pages (ASP) as the “glue” Use Active Server Pages (ASP) as the “glue” to link presentation with business logicto link presentation with business logic

Do NOT put business logic in ASPDo NOT put business logic in ASP

Page 5: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

3-Tier Web Architecture3-Tier Web Architecture

Inte

rne

t In

form

ati

on

Inte

rne

t In

form

ati

on

Se

rve

r a

nd

AS

PS

erv

er

an

d A

SP

DCOMDCOM

Data servicesData services

SQL ServerSQL Server

OracleOracle

MicrosoftMicrosoftExchangeExchange

MSMQMSMQ

Business logicBusiness logic

MTSMTSCom

pone

nts

Compo

nent

s

PresentationPresentation

Internet Internet ExplorerExplorer

OthersOthers

HTTPHTTP

HTTPHTTP

Page 6: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Design For SuccessDesign For Success

Page 7: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Process IsolationProcess IsolationPerformance versus RobustnessPerformance versus Robustness

Page 8: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Flow ControlFlow ControlDesign Applications NOT PagesDesign Applications NOT Pages1 of 51 of 5

Normal ResponseNormal Response

Client

ASPA

ASPB

IIS

Request

Response

Page 9: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Flow ControlFlow ControlDesign Applications NOT PagesDesign Applications NOT Pages2 of 52 of 5

Normal ResponseNormal Response

Response.EndResponse.End

Response. Response.

IsClientConnectedIsClientConnected

Client

ASPA

ASPB

IIS

Request

Response

Page 10: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Flow ControlFlow ControlDesign Applications NOT PagesDesign Applications NOT Pages3 of 53 of 5

Normal ResponseNormal Response

Response.EndResponse.End

Response.RedirectResponse.RedirectClient

ASPA

ASPB

IIS

Request (1)

Response.Redire

ctRequest (2)

Response

Page 11: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Flow ControlFlow ControlDesign Applications NOT PagesDesign Applications NOT Pages4 of 54 of 5

Normal ResponseNormal Response

Response.EndResponse.End

Response.RedirectResponse.Redirect

Server.TransferServer.Transfer

Client

ASPA

ASPB

IIS

Request

Server.Transfer

Response

Page 12: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Flow ControlFlow ControlDesign Applications NOT PagesDesign Applications NOT Pages5 of 55 of 5

Normal ResponseNormal Response

Response.EndResponse.End

Response.RedirectResponse.Redirect

Server.TransferServer.Transfer

Server.ExecuteServer.Execute

Client

ASPA

ASPB

IIS

Request

Server.Execute

Response

Page 13: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

3-Tier Validation3-Tier Validation“End-to-End” Solution“End-to-End” Solution

Validate in all 3-tiersValidate in all 3-tiers Client side validation with “smart” clientsClient side validation with “smart” clients Server side validation for legacy clientsServer side validation for legacy clients Data validation when persistingData validation when persisting

Scalable - distribute work as necessaryScalable - distribute work as necessary Reliable - fault tolerant architectureReliable - fault tolerant architecture Extensible - interchangeable pagesExtensible - interchangeable pages

Page 14: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

<%@ LANGUAGE=JavaScript %><%@ LANGUAGE=JavaScript %>

<html><html>

<body><body>

<form method=post><form method=post>

What is your favorite sport? <%= getSportsListBox() %>What is your favorite sport? <%= getSportsListBox() %>

<p><p>

<input type=submit><input type=submit>

</form></form>

</body></body>

</html></html>

<%@ LANGUAGE=JavaScript %><%@ LANGUAGE=JavaScript %>

<html><html>

<body><body>

<form method=post><form method=post>

What is your favorite sport? <%= getSportsListBox() %>What is your favorite sport? <%= getSportsListBox() %>

<p><p>

<input type=submit><input type=submit>

</form></form>

</body></body>

</html></html>

CachingCachingOutputOutput

<%function getSportsListBox(){ SportsListBox = Application("SportsListBox") if (SportsListBox != null) return SportsListBox; crlf = String.fromCharCode(13, 10) SportsListBox = "<select name=Sports>" + crlf; SQL = "SELECT SportName FROM Sports ORDER BY SportName"; cnnSports = Server.CreateObject("ADODB.Connection"); cnnSports.Open("Sports", "WebUser", "WebPassword"); rstSports = cnnSports.Execute(SQL); fldSportName = rstSports("SportName"); while (!rstSports.EOF){ SportsListBox = SportsListBox + " <option>" + fldSportName + "</option>" + crlf; rstSports.MoveNext(); } SportsListBox = SportsListBox + "</select>" Application("SportsListBox") = SportsListBox return SportsListBox;}%>

<%function getSportsListBox(){ SportsListBox = Application("SportsListBox") if (SportsListBox != null) return SportsListBox; crlf = String.fromCharCode(13, 10) SportsListBox = "<select name=Sports>" + crlf; SQL = "SELECT SportName FROM Sports ORDER BY SportName"; cnnSports = Server.CreateObject("ADODB.Connection"); cnnSports.Open("Sports", "WebUser", "WebPassword"); rstSports = cnnSports.Execute(SQL); fldSportName = rstSports("SportName"); while (!rstSports.EOF){ SportsListBox = SportsListBox + " <option>" + fldSportName + "</option>" + crlf; rstSports.MoveNext(); } SportsListBox = SportsListBox + "</select>" Application("SportsListBox") = SportsListBox return SportsListBox;}%>

Page 15: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Presentation LayerPresentation Layer

Page 16: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Let the client do the workLet the client do the workUse double dynamic HTMLUse double dynamic HTML

Use the browser capabilities componentUse the browser capabilities component Test for script supportTest for script support Test for D/HTML supportTest for D/HTML support *Use application state for this component*Use application state for this component

Send HTML, DHTML, and client-side Send HTML, DHTML, and client-side scripting based on capabilitiesscripting based on capabilities Ubiquitous, easy, fast to downloadUbiquitous, easy, fast to download DHTML dynamic page repaintingDHTML dynamic page repainting Client-side scripts pushes work to clientClient-side scripts pushes work to client

Page 17: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Business Logic LayerBusiness Logic Layer

Page 18: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

ComponentsComponents

Implement the business logic layer Implement the business logic layer using server-side COM componentsusing server-side COM components Visual Basic®Visual Basic® C++C++ Java™Java™

Server components provideServer components provide Abstraction of complexityAbstraction of complexity Encapsulation of internal detailsEncapsulation of internal details Modularity for code reuseModularity for code reuse

Page 19: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

ComponentsComponents

Basic PrinciplesBasic Principles Reuse existing componentsReuse existing components Buy new componentsBuy new components Build your own componentsBuild your own components

Provide a scriptable interface for your Provide a scriptable interface for your ASP useASP use COM InterfaceCOM Interface No need for graphical UINo need for graphical UI

Choose language accordinglyChoose language accordingly

Page 20: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

ComponentsComponentsThreading ModelsThreading Models

Every component hasEvery component hasa “Threading Model”a “Threading Model” SingleSingle ApartmentApartment FreeFree BothBoth

Choice of Threading Model determinesChoice of Threading Model determines Thread that your component will be created onThread that your component will be created on Whether calls are direct or through proxyWhether calls are direct or through proxy

Page 21: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

ComponentsComponentsThreading Model ImpactThreading Model Impact

PerformancePerformance Calls may be marshaled by proxyCalls may be marshaled by proxy

Access to contextAccess to context Context is an attribute of the threadContext is an attribute of the thread

SecuritySecurity May lose impersonated identityMay lose impersonated identity

Page 22: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Threading ModelsThreading ModelsPage Scoped ObjectsPage Scoped Objects

BothBoth and and Apartment Apartment are equally goodare equally good FreeFree is less good is less good SingleSingle is bad is bad

Page 23: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Threading ModelsThreading ModelsSession Scoped ObjectsSession Scoped Objects

Mark Mark SessionSession objects as objects as BothBoth ApartmentApartment is OK is OK

Locks down sessionLocks down session FreeFree is mediocre is mediocre SingleSingle is bad is bad

Page 24: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Mark Mark Application Application objects as objects as BothBoth ASP never locks down Application ASP never locks down Application

Scoped ObjectsScoped Objects For Apartment model objects, you For Apartment model objects, you

can only use the <OBJECT> tagcan only use the <OBJECT> tagin global.asain global.asa

Non-Both objects will lose security Non-Both objects will lose security and contextand context

Threading Models

Application Scoped Objects

Page 25: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Threading Models

Recommendation

Write components as Both

Page 26: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Writing ComponentsWriting ComponentsLanguage ChoicesLanguage Choices

Visual BasicVisual Basic®®

Default Thread Model is Default Thread Model is SingleSingle, can , can produce produce ApartmentApartment

C++C++ Can create Can create BothBoth model components model components

JavaJava™™

Produces Produces BothBoth components by defaultcomponents by default

Page 27: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Data Services LayerData Services Layer

Page 28: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Active Data Objects (ADO)Active Data Objects (ADO)

Business components use ADOBusiness components use ADO .asp files should not use ADO.asp files should not use ADO Better performance and reuseBetter performance and reuse

Mark ADO as both model Mark ADO as both model threadedthreaded MakeFre15.bat in the folder MakeFre15.bat in the folder

Program Files\Common Files\Program Files\Common Files\System\ADOSystem\ADO

Learn about the six commonlyLearn about the six commonlyused ADO objectsused ADO objects

Page 29: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Using ADOUsing ADO Using ADO from ActiveX ComponentsUsing ADO from ActiveX Components

ADO command object for ease of useADO command object for ease of use No “Select * From table”No “Select * From table”

.asp file using RecordSets.asp file using RecordSets ADO field object for performanceADO field object for performance

Set rsCustomers = Customers.ListSet rsCustomers = Customers.ListSet fldCustomerID = rsCustomers(“CustomerID”)Set fldCustomerID = rsCustomers(“CustomerID”)Set fldCustomerName = rsCustomers(“CustomerName”)Set fldCustomerName = rsCustomers(“CustomerName”)Do Until rsCustomers.EOFDo Until rsCustomers.EOF Response.Write fldCustomerID & “ -- “ & _Response.Write fldCustomerID & “ -- “ & _ fldCustomerName & “<BR>”fldCustomerName & “<BR>” rsCustomers.MoveNextrsCustomers.MoveNextLoopLoop

Page 30: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

SQL Server™ SQL Server™

Configure SQL ServerConfigure SQL Server Memory sizeMemory size

Protocol selectionProtocol selection Named pipes if on the Internet Information Named pipes if on the Internet Information

Server machineServer machine TCP Sockets if on a different machineTCP Sockets if on a different machine

Let SQL do the workLet SQL do the work Joins/sorting/groupingJoins/sorting/grouping

Connection poolingConnection pooling HKLM\SOFTWARE\ODBC\ODBCINST.INI\HKLM\SOFTWARE\ODBC\ODBCINST.INI\

SQL Server\CPTimeoutSQL Server\CPTimeout

Page 31: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

SQL Server™ SQL Server™

Maintain SQL ServerMaintain SQL Server Monitor logsMonitor logs

Use stored proceduresUse stored procedures Use show planUse show plan Use indexesUse indexes Update statisticsUpdate statistics

Page 32: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

ODBCODBC

SQL Server ODBC connection poolingSQL Server ODBC connection pooling On by default for SQL Server because On by default for SQL Server because

it is now set per driverit is now set per driver

ODBC performance monitor counters ODBC performance monitor counters from ODBC SDKfrom ODBC SDK

Page 33: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Testing and TuningTesting and Tuning

Page 34: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Testing for SuccessTesting for Success

Functional LevelFunctional Level Rate component throughput Rate component throughput Know the cost of external dependenciesKnow the cost of external dependencies

Page LevelPage Level Trace .asp execution for bottlenecks Trace .asp execution for bottlenecks Determine your 5 worst .asp filesDetermine your 5 worst .asp files

Application LevelApplication Level Simulate sessionsSimulate sessions Determine the number of machines neededDetermine the number of machines needed

Page 35: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Performance TuningPerformance Tuning

ToolsTools Profiling (Response.End)Profiling (Response.End) WebCatWebCat WebLoadWebLoad New ASP performance countersNew ASP performance counters

Page 36: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Call to ActionCall to Action

Install the Windows NT 5.0Install the Windows NT 5.0 Start building simple components in the Start building simple components in the

language of your choosinglanguage of your choosing

Begin a pilot Windows DNA Begin a pilot Windows DNA Application ProjectApplication Project Expense Reporting ApplicationExpense Reporting Application Internal Purchasing ApplicationInternal Purchasing Application

Write killer Windows DNA applicationsWrite killer Windows DNA applications

Page 37: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation

Other PDC TalksOther PDC Talks

Architecting Your Application For Architecting Your Application For IIS 5.0IIS 5.0

Debugging ASP Applications Debugging ASP Applications and Componentsand Components

Using the Microsoft XML Parser in the Using the Microsoft XML Parser in the Middle TierMiddle Tier

Page 38: Building High Performance, Robust Server Applications with Internet Information Server 5.0 Van Van IIS - Program Manager Microsoft Corporation