NT Services - Center

Download Report

Transcript NT Services - Center

CTS405
Connected Applications
Choosing A Hosting Model
Lance Olson
Lead Program Manager
Microsoft
Connected Systems Track
Mon 10:45
CTS200 Service Orientation and the Windows/.NET Developer
Mon 1:30
CTS300 Prescriptive Guidance-Juggling Web Services, WSE, .NET Remoting,
System.EnterpriseServices, and MSMQ
Mon 3:15
CTS308 Applied Web Services in Hewlett Packard's Core eCommerce Solutions
Mon 5:00
CTS404 Best Practices for Dealing With State at Multiple Layers Within Your
.NET Applications
Tue 1:30
DEVC27 Service Orientation Overview
Tue 3:15
CTS301 Managed Programming for Win32 Developers
Wed 2:00
CTS302 Using Web Services Enhancements v2.0 (WSE) to Secure Web Services
Wed 10:15
CTS400 Using Web Services Enhancements v2.0 for Messaging Over Multiple
Machines and Networks
Wed 5:30
CTS303 Applied Web Services at the Ohio State University Medical Center
Thur 8:30
CTS403 Handling Errors with Transactions
Thur 8:30
DEVC35 Web Services Interoperability
Thur 1:30
CTS406 Versioning of Connected .NET Applications
Thur 1:30
DEVC16
Thur 5:00
CTS304 Availability and Reliability - Failure Is Not An Option
Fri 10:45
CTS405 Choosing a Hosting Model - Dealing with Threads, AppDomains,
and Processes
Fri 1:00
CTS306 Deployment and Management
Fri 2:45
CTS307 Using Service Orientation to Drive Business Processes
Fri 9:00
DEVC40 Versioning Panel
Distributed Applications Performance Panel
Scope Of This Talk
In scope…Application execution
Application execution “hosting” as
defined by the process model, threading,
and inherent application services
NOT in scope…Online “hosting”
business
“Hosting” as in application hosting via
online sites, co-location, etc.
Agenda
Running managed code
Hosting environments
Relating the connected technologies
Choosing the right model
Running Managed Code
Managed Code Basics
All managed code runs in an
Operating System process
Application Domains are
the principal managed runtime
environment
Types are loaded per-Application
Domain
Object references are scoped
to domain
Security policy is per domain
An Operating System process may
host multiple Application Domains
There is one default Application
Domain per process
Process
Application Domain
Application Domain
Application Domain
Type Type Type
Type Type Type
Type Type Type
Before The 1st AppDomain…
The CLR is initialized from unmanaged code
via a calls into mscoree.dll
_CorExeMain for managed EXEs
_CorDllMain for managed DLLs loaded
via LoadLibrary
DllGetClassObject for REGASM’ed DLLs
CorBindToRuntimeEx et al for “explicit” hosts
At most one instance of the CLR per process
Only one version (e.g., 1.0, 1.1, Whidbey)
Server (MP) versus Workstation (UP)
Concurrent GC process-wide
Loader optimization settings
The App Domain Lifecycle
Each App Domain gets initialized with
the following
Application Domain
.config XML doc (may be in memory)
Auxiliary properties (e.g., APPBASE,
shadow copy, search path)
Security evidence for top-of-stack
CAS
Assemblies get loaded and code gets
run using cross-domain remoting
App Domain unloads and takes down
assemblies with it
Properties
Security Evidence
Config Settings
Assembly A
Assembly B
Hosting Environments
Hosting Overview
What does your host do for you?
Some things are clear
Process management
Threading
Application domains
But the details are not always obvious
Should I use IIS, an NT service, or
Enterprise Services?
Differences range from subtle to dramatic
Some hosts couple process model with
environment and application services
Hosting Environments
Manual process creation
Managed Console executable
Windows Forms
Automatic process creation
Managed Windows NT Service
Enterprise Services
IIS/ASP.NET
Hosting In The Console
Basic usage
Common simple test environment
Great for basic
batch-style execution
Free threaded environment
Loaded by Windows Loader
Code runs in the default
application domain
Tips
Extremely simple –
No major surprises
Batch-file level management and
deployment
Be aware of differences when using
the console to test your application
App1.exe
Default App Domain
Type
Type
Type
Hosting In Windows Forms
Basic usage
Rich local Windows UI
Front end to a multi-tiered
application
Loaded by Windows Loader
Code runs in the default
application domain
Tips
Be aware of the UI thread
Use control.BeginInvoke to
marshal from IO threads to main
Management and deployment
significantly improved
by ClickOnce
See DEV364 presentation
App1.exe
Default App Domain
Type
Type
Type
Inspecting A
Managed .EXE
Hosting Environments
Manual process creation
Managed Console executable
Windows Forms
Automatic process creation
Windows NT Service
Enterprise Services
IIS/ASP.NET
What Do They Do?
Activation / startup
Process identity
Pooling
Management
Debugging
Shutdown
Recycling
Starting The Application
Enterprise Services
On demand
or automatic
In process – Library
Out of proc – Server
(Dllhost.exe)
Process instance or
NT service
Dllhost.exe loads CLR
Code runs in default
application domain
DllHost.exe
App Domain
DCOM/RPC
Starting The Application
ASP.NET / IIS 6.0
Commonly the
virtual directory
http://server.com/myapp1
W3SVC
W3WP.exe
App
Domain
kernel
On demand start up
W3svc manages
processes
Application runs in
w3wp.exe instance
One app domain
per application
HTTP.SYS
Starting The Application
NT Services
Automatic start up
Application runs
in service
process instance
Manual, Auto, Disabled
startup state
Specify service
dependencies
Default app domain
Multiple services
per process
MyService.exe
App Domain
Service Control Manager
Process Identity
Generally the same feature set
across all three
Run under specified account
Mark account as interactive
Commonly used for debugging
ASP.NET and Enterprise Services also
support caller impersonation
Pooling Processes
Process Pooling
Process Pinning
Enterprise
Services
Yes
ASP.NET / IIS 6.0
Yes
NT Services
No
CoCreateInstance
picks a process
then sticks until
the client calls
release
First request gets
round robin, then
sticks based on
the connection
n/a
Pooling Application Domains
Enterprise Services
One app domain per COM+ application
One COM+ application per process
ASP.NET / IIS 6.0
One application domain per IIS application
Many applications per process
Get more applications running on the box
Be aware that applications in the same process must
“play well” together
NT Services
One application domain per process
Services share the same application domain
Pooling Threads
Enterprise Services
Operating System completion port
thread pool
Limited only by contention
ASP.NET / IIS 6.0
Managed CLR thread pool
Limited to 20 completion port and 20
worker threads per CPU by default
NT Services
N/A
Request Queuing
Enterprise Services
Satisfy all requests eventually
Requests aren’t queued unless you’re
explicitly using a queuing technology
Geared towards short and long-lived
application operations
STA components change everything
E.g. VB 6 code
Request Queuing
ASP.NET / IIS 6.0
Satisfy the majority of requests as quickly as
possible
Requests are given a time limit to complete work
Requests are queued once the thread pool limit is
reached
Once queue limit is reached requests are rejected
Geared towards serving up application UI
NT Services
None provided by the environment
Managing Processes
Health
Command and
Control
Inspection
Enterprise
Services
Through COM+ System Start, stop, pause,
Application
resume, enable, disable
Process dump
Enumerate
running processes,
classes,
transactions
ASP.NET
IIS 6.0
Process and app
domain level “ping”
Failure triggers
Start, stop, pause,
resume
View running
processes
NT
Services
Failure triggers
Start, stop, pause,
continue
Execute custom
commands
Enumerate
services
Debugging Processes
Enterprise Services
Memory dump
On failure or on demand
Launch in debugger on failure
ASP.NET / IIS 6.0
Put process in “orphan” mode on failure
for debugging
NT Services
Attach directly to debug
Recycling
Enterprise
Services
ASP.NET
IIS 6.0
NT
Services
Time
Memory Req.
Idle
Lapsed
Based
Activation
Count
Scheduled
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
N/A
Inspecting Automatic
Process Creation
Environments
Relating Connected
Technologies
Does The Host Care?
Some care about the host
Exposing Web Services in .ASMX
WSE 1.0
Others don’t
System.Net
System.Messaging
Does The Host Care?
Others Vary
.NET Remoting
In your process, an NT Service, or in IIS
Enterprise Services
In your process, an NT Service, or Dllhost
WSE 2.0
HTTP requires ASP.NET
TCP in your process or an NT Service
Most Common Issues
Long-lived operations in
ASP.NET / IIS 6.0
Consider using queues
Database
Enterprise Services
System.Messaging
ASP.NET services coupled
with hosting
Mixing the technologies
“Don’t give me multiple models!”
Choosing The Right Model
Hosting With ASP.NET / IIS 7
Componentization
Protocol independent activation
Decouple services from hosting model
Enhancing the loader
Better support for
Enterprise Services scenarios
Hosting With Indigo
Uses ASP.NET / IIS 6 for HTTP
activation
Uses ASP.NET / IIS 7 for HTTP
activation plus other protocols
E.g. SOAP over TCP, IPC
Expect to see better support for
Enterprise Services class of scenarios
Choosing The Right model
Richard Turner’s roadmap talk CTS300
Build services using ASMX
Components should stay WITHIN
your Services
Use Enterprise Services if you need it’s
rich services
Use .NET Remoting X-AppDomain
Use System.Messaging for async
queued messaging
Recommendations
Does Your Application…
Need to serve up Web content?
Use ASP.NET / IIS 6.0
Also need to perform long-lived tasks?
I.e. order/inventory request processing
Use ASP.NET / IIS 6.0 on the front end
Use queued Enterprise Services in an NT
service to perform the long-lived work
Need to start at boot time and always
be running?
Use NT Services
Conclusion
Decide how your application needs to
behave, then use the roadmap guidance
and the hosting model guidance to drive
your architecture
Attend a free chat or web cast
http://www.microsoft.com/communities/chats/default.mspx
http://www.microsoft.com/usa/webcasts/default.asp
List of newsgroups
http://communities2.microsoft.com/
communities/newsgroups/en-us/default.aspx
Microsoft Community Sites
http://www.microsoft.com/communities/default.mspx
Locate Local User Groups
http://www.microsoft.com/communities/usergroups/default.mspx
Community sites
http://www.microsoft.com/communities/related/default.mspx
Please fill out a session evaluation on CommNet
Q1: Overall satisfaction with the session
Q2: Usefulness of the information
Q3: Presenter’s knowledge of the subject
Q4: Presenter’s presentation skills
Q5: Effectiveness of the presentation
Connected Systems Track
Mon 10:45
CTS200 Service Orientation and the Windows/.NET Developer
Mon 1:30
CTS300 Prescriptive Guidance-Juggling Web Services, WSE, .NET Remoting,
System.EnterpriseServices, and MSMQ
Mon 3:15
CTS308 Applied Web Services in Hewlett Packard's Core eCommerce Solutions
Mon 5:00
CTS404 Best Practices for Dealing With State at Multiple Layers Within Your
.NET Applications
Tue 1:30
DEVC27 Service Orientation Overview
Tue 3:15
CTS301 Managed Programming for Win32 Developers
Wed 2:00
CTS302 Using Web Services Enhancements v2.0 (WSE) to Secure Web Services
Wed 10:15
CTS400 Using Web Services Enhancements v2.0 for Messaging Over Multiple
Machines and Networks
Wed 5:30
CTS303 Applied Web Services at the Ohio State University Medical Center
Thur 8:30
CTS403 Handling Errors with Transactions
Thur 8:30
DEVC35 Web Services Interoperability
Thur 1:30
CTS406 Versioning of Connected .NET Applications
Thur 1:30
DEVC16
Thur 5:00
CTS304 Availability and Reliability - Failure Is Not An Option
Fri 10:45
CTS405 Choosing a Hosting Model - Dealing with Threads, AppDomains,
and Processes
Fri 1:00
CTS306 Deployment and Management
Fri 2:45
CTS307 Using Service Orientation to Drive Business Processes
Fri 9:00
DEVC40 Versioning Panel
Distributed Applications Performance Panel
© 2004 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.