iis always-on services
DESCRIPTION
Simplify your enterprise by standardizing on the IIS application server for both Web & Windows Services. Learn more about the IIS hosting model & how to take advantage of the new Always-On service capabilities.Given at JAXDUG on 10/5/2011.http://www.jaxdug.com/TRANSCRIPT
![Page 1: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/1.jpg)
Hosting Windows Services in IIS
Brian RitchieChief ArchitectPayformance Corporation
Email: [email protected]: http://weblog.asp.net/britchieWeb: http://www.dotnetpowered.com
Take advantage of the IIS platform for hosting your Always-On services.
![Page 2: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/2.jpg)
Who am I?
» Chief Architect at Payformance Corporation» Nearly 20 years of development experience» Developing on .NET since 1.0 Beta 1» Contributed to Mono and other
open source projects
Brian Ritchie
![Page 3: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/3.jpg)
Why build Windows Services?
» When you need always-on functionality
» Examples:˃ File Watching & Processing
˃ Scheduled tasks
˃ Long-running tasks
˃ Queued processing
![Page 4: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/4.jpg)
Windows Services have been around forever, why
change now?
Why build Windows Services?
![Page 5: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/5.jpg)
Sometimes change is good
![Page 6: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/6.jpg)
Reasons for change
» Windows Services have no User Interface
making them hard to monitor, manage, and
debug.
» Windows Services are harder to deploy & can’t
use Web Deploy.
![Page 7: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/7.jpg)
Who can save us from these problems?
I’m IIS & I’m here to help!
![Page 8: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/8.jpg)
Did you say IIS?
» More than just a web server, IIS is an application server platform.˃ Web Applications: ASP.NET, PHP, and more˃ Web Services: ASMX, WCF˃ Multiple Protocols: HTTP, HTTPS, TCP, Named PipesAnd now…˃ Always-On Services: Auto-start & Always Running
![Page 9: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/9.jpg)
What makes IIS better?
Single hosting framework for all application components. Web sites, services, and long running services can be hosted using the same framework & management tools.
Improved deployment capabilities. XCOPY deployment is now possible or use the new Web Deploy functionality. Web Deploy is enough of a reason by itself!
Provide self-hosted management or monitoring web pages. You can easily add web pages to services to provide status on their work load.
Utilize IIS automatic management features. Optionally configure your service to recycle on a given interval or based on memory usage, just like any other IIS hosted service.
![Page 10: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/10.jpg)
IIS7: Your Single Hosting Framework
IIS7
Windows Activation Service (WAS)
Protocol Adapters
WWW Service(W3WC)
HTTP
HTTPS
NET PIPE
TCP
App Pools
Worker Process (W3WP)
ASP.NET
ASP
PHP
WCF
Always-On
Management Service
Admin Service
![Page 11: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/11.jpg)
Monitoring via the IIS Manager
» Since all services will be hosted under the w3wp.exe process name, you can see the Worker Process associated with your application pool within the IIS manager:
![Page 12: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/12.jpg)
Monitoring via Process Explorer
» Another approach is to use the SysInternals Process Explorer free from Microsoft. Add the “Command Line” column to the grid, and the application pool name will be listed after the –ap switch.
![Page 13: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/13.jpg)
Deployments…made easy
Build/Deploy Server
Deploy
IISServer
IIS MMC – Import Application
Package
Build Server(using MSBuild)
DeploymentPackage
IIS MMC – Export Application
» Web Deploy 2.1
![Page 14: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/14.jpg)
Look Mom…I have a UI now!
» No longer “invisible”, your service can publish its own monitoring & management capability
![Page 15: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/15.jpg)
OK…I’m sold!
How can I take this beauty home today?
![Page 16: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/16.jpg)
Getting Started
» First off…Install the pre-reqs:˃ IIS 7.5 (Windows 2008 R2 or Windows 7)˃ Windows Server AppFabric˃ .NET Framework 4.0
» Next…Configure IIS:˃ Set Application Pool to “Always Running”˃ Configure Site with Net.Pipe Binding˃ Set Application to “Auto Start”
![Page 17: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/17.jpg)
Walk Thru: Configuring IIS
![Page 18: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/18.jpg)
Building a service
![Page 19: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/19.jpg)
Building a service
» What are some fundamental differences between a standard Web Service and a Windows Service?A. Request-Response vs. Event-based B. State-less vs. State-fullC. Transparent threading vs. Thread ManagementD. DLL vs. EXEE. All of the Above
![Page 20: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/20.jpg)
Building a Service:Differences in Process
Models
» Windows Service Process Model Service
(EXE)Service
ControllerMMC
![Page 21: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/21.jpg)
Building a Service:Differences in Process
Models
» Windows Service Process Model
» IIS Worker Process Model
Service(EXE)
Service Controller
W3WP
WWW Publishing
Service
svchost.exe -k iissvcs
MMC
IIS Manager
AppDomain
AppDomain
Service(DLL)
![Page 22: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/22.jpg)
Building a service
» Where does the service perform it’s startup?A. Application_Start in Global.asaxB. AppInitialize in AppStart.csC. AppStartup in the session controller
![Page 23: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/23.jpg)
Building a service
» What is the scope of a static variables?A. ClassB. ThreadC. AppDomainD. ProcessE. Machine
![Page 24: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/24.jpg)
Visualizing the stack
Machine
Process
AppDomain
Thre
ad
Thre
ad
StaticScope
Your service runs here
Either you manage threads directly or use a Thread Pool or TPL
![Page 25: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/25.jpg)
Walk Thru: Building a service
![Page 26: IIS Always-On Services](https://reader033.vdocuments.net/reader033/viewer/2022061209/548cc58cb4795996278b4841/html5/thumbnails/26.jpg)
Thanks for coming!» Twitter: @brian_ritchie» Blog: http://weblogs.asp.net/britchie