300 likes | 521 Views
Getting the Most Out of IIS. Ido Flatow Senior Architect Microsoft ASP.NET/IIS MVP SELA Group @ idoflatow. About Me. Senior Architect, Sela Group Co-author of courses and books Microsoft ASP.NET/IIS MVP Focus on server, web, cloud, and DevOps Manager of the Israeli WebDev User Group.
E N D
Getting the Most Out of IIS Ido Flatow Senior Architect Microsoft ASP.NET/IIS MVP SELA Group @idoflatow #devconnections
About Me • Senior Architect, Sela Group • Co-author of courses and books • Microsoft ASP.NET/IIS MVP • Focus on server, web, cloud, and DevOps • Manager of the Israeli WebDev User Group
It’s pronounced Ay AyEs • Web application hosting • Comes in two flavors • Full IIS (or simply IIS) • IIS Express • Provides • Reliability • Manageability • Security • Performance • Scalability
History in Screenshots IIS 5.1 IIS 7.5 IIS 8 IIS 8.5 IIS 5 IIS 6 IIS 7 Win 8 WS2012 Win 8.1 WS2012 R2 Vista WS2K8 Win 7 WS2K8 R2 W2K Win XP WS2K3
IIS Management Your Computer Application Pool Web Site Web Applications Physical Directory Virtual Directory Remote Computers
IIS Configuration ASP.NET Settings Configuration Hierarchy Site machine.config Web.config root Web.config Application Web.config VirtualDirectory Web.config applicationHost.config
The Integrated pipeline Basic Anon Authentication Forms Authorization Windows ResolveCache ASPX / MVC … Static File ExecuteHandler Trace … Native … UpdateCache Managed SendResponse Compress Log
HTTP Request Processing in IIS Widows Process Activation Service (WAS) ApplicationHost.config HTTP protocol stack W3WP.exe Client WWW Service .NET CLR AppDomain … AppDomain
HTTP.SYS, What’s That? • It’s the thing that listens to HTTP on your computer • It’s a kernel-mode device driver • Ever since Windows Server 2003 (IIS 6) • Responsible for: • Routing requests to registered applications • Managing request queues • Kernel-mode SSL (as of Windows Server 2008) • Response caching in kernel mode • QoS, such as connection limits and timeouts • Want to know more? netsh http show
The IIS Application Pool • Groups applications to worker processes • Each app is hosted in a .NET AppDomain • App pool defines: • .NET version • Bitness (32/64) • Security identity • And a lot more
App Pool Configuration • Startup mode • CPU usage limits • Process timeouts • Idle • Ping • Shutdown / Startup • Web garden • Rapid-Fail protection • Process orphaning • Auto recycling
Compressing Responses So turn it on, is that it? Almost!
Rewriting URLs • Great tool for manipulating URLs • Can change incoming and outgoing URLs • URL transformation, redirection, or forwarding • RegEx and wildcards for pattern matching • Pre-conditions based on HTTP headers, URL fragments, and server variables • And it has a UI !!!!!
Common Rewriting Scenarios • Enforce lower-cased URLs • Add/remove trailing slash • Canonical hostnames • Prevent hotlinking • Resource versioning • HTTPS redirection • Reverse proxy
Application Initialization • Initial load of an application takes time • Dynamic compilation • Assembly loading • Execute Application_Start event • Application initialization to the rescue • Loads the AppDomain after W3WP loads • Can internally call an initialization URL
Configure Initialization Application Pool Web Application Web.config <system.webServer> <applicationInitializationremapManagedRequestsTo=“Loading.htm" skipManagedModules="true" ><add initializationPage="/init.ashx" /></applicationInitialization> </system.webServer>
Cool Features of Initialization • Remaps requests while initializing • Overlapped recycling completes after initialization is done • Granular control over remaps with URL Rewrite • {APP_WARMING_UP} server variable • Still using IIS 7.5? Get the extension! • http://bit.ly/iis-application-initialization
IIS Features Demo
Logging Advanced Logging • IIS logging is not enough! • Use the Advanced Logging module • http://bit.ly/iis-advanced-logging • Create a separate log file per application • Log HTTP headers, performance counters, and server variables • Filter requests you don't want to log • Creates the same IIS Log file structure (almost) • Use your existing analysis tools
Failed Request Tracing • Investigate failed requests • What is a bad request? • Resulted in a 4xx or 5xx response • Took too long to process • Caused a warning or error trace message • You can set different traces for different URLs • Use the System.Web.IisTraceListener trace listener for custom traces • Beware of overuse! • Investigate bad requests
IIS 8.5 • Released with Windows Server 2012 R2 • Some new cool features • Logging with ETW • Enhanced logging • Worker process timeout suspension • Dynamic site configuration loading • Auto-binding of renewed certificates
Resources Everything About IIS www.iis.net Extensions and Apps www.iis.net/downloads/microsoft/advanced-logging www.lizard-labs.net/log_parser_lizard.aspx gallery.technet.microsoft.com/office/Log-Parser-Studio-cd458765 www.iis.net/downloads/community/2008/03/iis-70-trace-viewer idof@sela.co.il @idoflatow http://bit.ly/flatow-blog This presentation: http://1drv.ms/1A4VGk9
Rate with Mobile App: Rate This Session Now! Tell Us What You Thought of This Session Select the session from the Agenda or Speakers menus Select the Actions tab Click Rate Session Be Entered to WIN Prizes! Rate Using Our Website: Register at www.devconnections.com/logintoratesession Go to www.devconnections.com/ratesession Select this session from the list and rate it