building high performance, robust server applications with internet information server 5.0 van van...
TRANSCRIPT
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
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
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
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
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
Design For SuccessDesign For Success
Process IsolationProcess IsolationPerformance versus RobustnessPerformance versus Robustness
Flow ControlFlow ControlDesign Applications NOT PagesDesign Applications NOT Pages1 of 51 of 5
Normal ResponseNormal Response
Client
ASPA
ASPB
IIS
Request
Response
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
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
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
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
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
<%@ 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;}%>
Presentation LayerPresentation Layer
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
Business Logic LayerBusiness Logic Layer
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
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
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
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
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
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
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
Threading Models
Recommendation
Write components as Both
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
Data Services LayerData Services Layer
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
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
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
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
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
Testing and TuningTesting and Tuning
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
Performance TuningPerformance Tuning
ToolsTools Profiling (Response.End)Profiling (Response.End) WebCatWebCat WebLoadWebLoad New ASP performance countersNew ASP performance counters
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
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