Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

IIS Always-On Services


Published on

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.

Published in: Technology
  • Be the first to comment

IIS Always-On Services

  1. 1. Hosting Windows Services in IIS<br />Take advantage of the IIS platform for hosting your Always-On services.<br />Brian Ritchie<br />Chief ArchitectPayformance Corporation<br />Email:<br />Blog:<br />Web:<br />
  2. 2. Who am I?<br />Brian Ritchie<br />Chief Architect at Payformance Corporation<br />Nearly 20 years of development experience<br />Developing on .NET since 1.0 Beta 1<br />Contributed to Mono and other open source projects<br />
  3. 3. Why build Windows Services?<br />When you need always-on functionality<br />Examples:<br />File Watching & Processing<br />Scheduled tasks<br />Long-running tasks<br />Queued processing<br />
  4. 4. Why build Windows Services?<br />Windows Services have been around forever, why change now?<br />
  5. 5. Sometimes change is good<br />
  6. 6. Reasons for change<br />Windows Services have no User Interface making them hard to monitor, manage, and debug.<br />Windows Services are harder to deploy & can’t use Web Deploy.<br />
  7. 7. Who can save us from these problems?<br />I’m IIS & I’m here to help!<br />
  8. 8. Did you say IIS?<br />More than just a web server, IIS is an application server platform.<br />Web Applications: ASP.NET, PHP, and more<br />Web Services: ASMX, WCF<br />Multiple Protocols: HTTP, HTTPS, TCP, Named Pipes<br />And now…<br />Always-On Services: Auto-start & Always Running<br />
  9. 9. What makes IIS better?<br />
  10. 10. IIS7: Your Single Hosting Framework<br />
  11. 11. Monitoring via the IIS Manager<br />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: <br />
  12. 12. Monitoring via Process Explorer<br />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.<br />
  13. 13. Deployments…made easy<br />Web Deploy 2.1 <br />Deploy<br />Package<br />Build/Deploy Server<br />Build Server<br />(using MSBuild)<br />Deployment<br />Package<br />IIS<br />Server<br />IIS MMC – Export Application<br />IIS MMC – Import Application<br />
  14. 14. Look Mom…I have a UI now!<br />No longer “invisible”, your service can publish its own monitoring & management capability<br />
  15. 15. OK…I’m sold! <br />How can I take this beauty home today?<br />
  16. 16. Getting Started<br />First off…Install the pre-reqs:<br />IIS 7.5 (Windows 2008 R2 or Windows 7)<br />Windows Server AppFabric<br />.NET Framework 4.0<br />Next…Configure IIS:<br />Set Application Pool to “Always Running”<br />Configure Site with Net.Pipe Binding<br />Set Application to “Auto Start”<br />
  17. 17. Walk Thru: Configuring IIS<br />
  18. 18. Building a service<br />
  19. 19. Building a service<br />What are some fundamental differences between a standard Web Service and a Windows Service?<br />Request-Response vs. Event-based <br />State-less vs. State-full<br />Transparent threading vs. Thread Management<br />DLL vs. EXE<br />All of the Above<br />
  20. 20. Building a Service:Differences in Process Models<br />Windows Service Process Model<br />Service Controller<br />Service<br />(EXE)<br />MMC<br />
  21. 21. Building a Service:Differences in Process Models<br />Windows Service Process Model<br />IIS Worker Process Model<br />Service Controller<br />Service<br />(EXE)<br />MMC<br />W3WP<br />WWW Publishing Service<br />svchost.exe -k iissvcs<br />AppDomain<br />Service<br />(DLL)<br />IIS Manager<br />AppDomain<br />
  22. 22. Building a service<br />Where does the service perform it’s startup?<br />Application_Startin Global.asax<br />AppInitialize in AppStart.cs<br />AppStartup in the session controller<br />
  23. 23. Building a service<br />What is the scope of a static variables?<br />Class<br />Thread<br />AppDomain<br />Process<br />Machine<br />
  24. 24. Visualizing the stack<br />Machine<br />Process<br />AppDomain<br />Your service runs here<br />Thread<br />Thread<br />Static<br />Scope<br />Either you manage threads directly or use a Thread Pool or TPL<br />
  25. 25. Walk Thru: Building a service<br />
  26. 26. Twitter: @brian_ritchie<br />Blog:<br />Thanks for coming!<br />