{"id":602,"date":"2019-06-03T14:36:16","date_gmt":"2019-06-03T18:36:16","guid":{"rendered":"https:\/\/crossan007.dev\/blog\/?p=602"},"modified":"2019-06-03T16:42:53","modified_gmt":"2019-06-03T20:42:53","slug":"intermittently-slow-iis-web-site","status":"publish","type":"post","link":"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/","title":{"rendered":"Intermittently Slow IIS web site"},"content":{"rendered":"\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=crossan007\" class=\"twitter-share-button\">Tweet<\/a><\/div>\n\n<blockquote class=\"wp-block-quote\"><p>TL;DR: <\/p><p>An issue in the Windows Management Instrumentation (WMI) performance counter collection process caused periodic system-wide performance degradation.<\/p><p><br>This issue became visible when our infrastructure monitoring software invoked specific WMI queries.<\/p><p><br>We disabled the specific WMI query set which was causing the performance issues, and the problem went away.<\/p><\/blockquote>\n\n\n\n<p>A few days ago one of our clients began reporting performance issues on one of their web sites.  This site is an IIS web application responsible for rendering visualizations of very large data sets (hundreds of gigabytes).  As such, the application pool consumes a corresponding amount of RAM (which is physically available on the server).<\/p>\n\n\n\n<p>Normally, these sites (I manage a few hundred instances) are fast, with most queries returning in under 300ms; however, this one instance proved difficult.  To make matters worse, the performance issues were intermittent:  most of the time, the site was blazing fast, but sometimes the site would hang for <strong>minutes<\/strong>. <\/p>\n\n\n\n<p>Given a few hours of observation, one of my team members noticed a correlation between the performance issues of the site and a seemingly unrelated process on the host: <code>WmiPrvSe.exe<\/code><\/p>\n\n\n\n<p>I began digging in, and was able to corroborate this correlation by looking at the process&#8217;s CPU usage over time (using ELK \/ MetricBeat to watch windows processes).   Sure enough, there&#8217;s a direct correlation between <code>WmiPrvSe.exe<\/code> using ~3-4% CPU, and IIS logs indicating a <code>timeTaken<\/code> of greater than 90 seconds. This correlation also established an interval between instances of the issue: 20 minutes.<\/p>\n\n\n\n<p>I fired up Sysinternals&#8217; ProcMon.exe to get a better handle on what exactly <code>WmiPrvSe.exe<\/code> was doing during these so-called &#8220;spikes&#8221;.  I observed an <strong>obscene<\/strong> count of Registry queries to things looking like Performance counters (<code>RegQueryValue<\/code>, <code>RegCloseKey<\/code>, <code>RegEnumKey<\/code>, <code>RegOpenKey<\/code>).  Note that there are multiple instances of <code>WmiPrvSe.exe<\/code> running on the sytsem, but only one instance was &#8220;misbehaving:&#8221;  the one running as <code>NT AUTHORITY\\SYTSEM<\/code> (which also happens to have the lowest PID). The instances running as <code>NT AUTHORITY\\NETWORK SERVICE<\/code> and as <code>NT AUTHORITY\\LOCAL SERVICE<\/code> did not seem to be misbehaving.<\/p>\n\n\n\n<p>Almost all of the registry keys in question contained the string <code>Performance<\/code> or <code>PERFLIB<\/code>; many (but not all) queries were against keys within <code>HKLM\\System\\CurrentControlSet\\Services.<\/code><\/p>\n\n\n\n<p>I know that I have the Elastic Co.&#8217;s &#8220;Beats&#8221; agents installed on this host; could <code>Metricbeat<\/code>, or one of my other monitoring tools be the culprit?  So, I tried disabling all of the &#8220;beats&#8221; agents (filebeat, metricbeat, winlogbeat, etc), but was still seeing these intermittent spikes in <code>WmiPrvSe.exe<\/code> CPU usage correlating with slow page loads from IIS.<\/p>\n\n\n\n<p>Stumped, I searched for how to capture WMI application logs, and found this article: <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/wmisdk\/tracing-wmi-activity\">https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/wmisdk\/tracing-wmi-activity<\/a>.<\/p>\n\n\n\n<p>I ran the suggested command (<code>Wevtutil.exe sl Microsoft-Windows-WMI-Activity\/Trace \/e:true<\/code>) and fired up Event Veiwer (as admin) to the above path.  Bingo.  <\/p>\n\n\n\n<p>Log hits in<code>Microsoft-Windows-WMI-Activity\/Trace<\/code> included mostly checks against the networking devices:<code>select __RELPATH, Name, BytesReceivedPersec, BytesSentPersec, BytesTotalPersec from Win32_PerfRawData_Tcpip_NetworkInterface<\/code><\/p>\n\n\n\n<p>These WMI queries were  executed by the <code>ClientProcessId<\/code> owned by <code>nscp.exe.<\/code><\/p>\n\n\n\n<p>I perused the source code for NSCP a bit, and discovered that the Network queries for NSCP are executed through WMI( <br><a href=\"https:\/\/github.com\/mickem\/nscp\/blob\/master\/modules\/CheckSystem\/check_network.cpp#L105\">https:\/\/github.com\/mickem\/nscp\/blob\/master\/modules\/CheckSystem\/check_network.cpp#L105<\/a> ); while the standard performance counter queries were executed through PDH (<a href=\"https:\/\/github.com\/mickem\/nscp\/blob\/master\/modules\/CheckSystem\/pdh_thread.cpp#L132\">https:\/\/github.com\/mickem\/nscp\/blob\/master\/modules\/CheckSystem\/pdh_thread.cpp#L132<\/a>):<br><\/p>\n\n\n\n<p>Something else I noticed was that the <code>Microsoft-Windows-WMI-Activity\/Operational<\/code> log contained events directly corresponding to the issue at hand: <code>WMIProv provider started with result code 0x0. HostProcess = wmiprvse.exe; ProcessID = 3296; ProviderPath = %systemroot%\\system32\\wbem\\wmiprov.dll<\/code><\/p>\n\n\n\n<p>Some more creative google searches yielded me an interesting issue in a GitHub repo for a <strong>different project:<\/strong>   <a href=\"https:\/\/github.com\/martinlindhe\/wmi_exporter\/issues\/89#\">CPU collector blocks every ~17 minutes on call to wmi.Query<\/a>   #89 .  <\/p>\n\n\n\n<p>Sounds about right.<\/p>\n\n\n\n<p>Skimming through the issue I see this; which sets off the &#8220;ah-ha&#8221; moment: <\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Perfmon uses the PDH library, not WMI. I did not test with Perfmon, but PDH is not affected. <\/p><cite><br><strong> <a href=\"https:\/\/github.com\/leoluk\">leoluk<\/a>        <\/strong>     commented       <a href=\"https:\/\/github.com\/martinlindhe\/wmi_exporter\/issues\/89#issuecomment-366195581\">on Feb 16, 2018<\/a>  (<a href=\"https:\/\/github.com\/martinlindhe\/wmi_exporter\/issues\/89#issuecomment-366195581\">https:\/\/github.com\/martinlindhe\/wmi_exporter\/issues\/89#issuecomment-366195581<\/a>)<\/cite><\/blockquote>\n\n\n\n<p>Now knowing that only NSCP&#8217;s <code>check_network<\/code> uses WMI, I found the documentation to disable the network routine in nscp&#8217;s <code>CheckSystem<\/code> module: <a href=\"https:\/\/docs.nsclient.org\/reference\/windows\/CheckSystem\/#disable-automatic-checks\">https:\/\/docs.nsclient.org\/reference\/windows\/CheckSystem\/#disable-automatic-checks<\/a><\/p>\n\n\n\n<p>I added the bits to my <code>nsclient.ini<\/code> config to disable automatic network checks, restarted NSCP, and confirmed the performance issue was gone:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&#91;\/settings\/system\/windows]\n# Disable automatic checks\ndisable=network\n\n<\/pre><\/div>\n\n\n<p>I&#8217;ve opened an issue on NSCP&#8217;s GitHub page for this problem: <a href=\"https:\/\/github.com\/mickem\/nscp\/issues\/619\">https:\/\/github.com\/mickem\/nscp\/issues\/619<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Related Reading:<\/p>\n\n\n\n<ul><li> <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/PerfCtrs\/about-performance-counters\">https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/PerfCtrs\/about-performance-counters<\/a><\/li><li><a href=\"https:\/\/randomascii.wordpress.com\/2012\/05\/05\/xperf-wait-analysisfinding-idle-time\/\">https:\/\/randomascii.wordpress.com\/2012\/05\/05\/xperf-wait-analysisfinding-idle-time\/<\/a><\/li><li><a href=\"https:\/\/docs.nsclient.org\/faq\/\">https:\/\/docs.nsclient.org\/faq\/<\/a><\/li><li><a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/wmisdk\/tracing-wmi-activity\">https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/wmisdk\/tracing-wmi-activity<\/a><\/li><li><a href=\"http:\/\/pleasework.robbievance.net\/howto-determine-what-wmiprvse-exe-is-actually-doing-aka-troubleshoot-wmi\/\">http:\/\/pleasework.robbievance.net\/howto-determine-what-wmiprvse-exe-is-actually-doing-aka-troubleshoot-wmi\/<\/a><\/li><li><a href=\"https:\/\/support.microsoft.com\/en-us\/help\/4038774\/windows-81-update-kb4038774\">https:\/\/support.microsoft.com\/en-us\/help\/4038774\/windows-81-update-kb4038774<\/a> (Not exactly related; was probably a red-herring)<\/li><li><a href=\"https:\/\/randomascii.wordpress.com\/2015\/04\/14\/uiforetw-windows-performance-made-easier\/\">https:\/\/randomascii.wordpress.com\/2015\/04\/14\/uiforetw-windows-performance-made-easier\/<\/a><\/li><li><a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/tn-archive\/bb687493(v=technet.10)\">https:\/\/docs.microsoft.com\/en-us\/previous-versions\/tn-archive\/bb687493(v=technet.10)<\/a><\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR: An issue in the Windows Management Instrumentation (WMI) performance counter collection process caused periodic system-wide performance degradation. This issue became visible when our infrastructure monitoring software invoked specific WMI queries. We disabled the specific WMI query set which was causing the performance issues, and the problem went away. A few days ago one of &hellip; <a href=\"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Intermittently Slow IIS web site<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[186],"tags":[34,238,247,248,249],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Intermittently Slow IIS web site - Charles&#039; Blog\" \/>\n<meta property=\"og:description\" content=\"TL;DR: An issue in the Windows Management Instrumentation (WMI) performance counter collection process caused periodic system-wide performance degradation. This issue became visible when our infrastructure monitoring software invoked specific WMI queries. We disabled the specific WMI query set which was causing the performance issues, and the problem went away. A few days ago one of &hellip; Continue reading Intermittently Slow IIS web site &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/\" \/>\n<meta property=\"og:site_name\" content=\"Charles&#039; Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-03T18:36:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-06-03T20:42:53+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"crossan007\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/crossan007.dev\/blog\/#website\",\"url\":\"https:\/\/crossan007.dev\/blog\/\",\"name\":\"Charles&#039; Blog\",\"description\":\"SharePoint | PowerShell | Exchange | SCCM | Ubuntu | PHP | JavaScript | A\/V Live Production | More...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/crossan007.dev\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/#webpage\",\"url\":\"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/\",\"name\":\"Intermittently Slow IIS web site - Charles&#039; Blog\",\"isPartOf\":{\"@id\":\"https:\/\/crossan007.dev\/blog\/#website\"},\"datePublished\":\"2019-06-03T18:36:16+00:00\",\"dateModified\":\"2019-06-03T20:42:53+00:00\",\"author\":{\"@id\":\"https:\/\/crossan007.dev\/blog\/#\/schema\/person\/bd99569cd81332c8fd866d023848b979\"},\"breadcrumb\":{\"@id\":\"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/crossan007.dev\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Intermittently Slow IIS web site\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/crossan007.dev\/blog\/#\/schema\/person\/bd99569cd81332c8fd866d023848b979\",\"name\":\"crossan007\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/crossan007.dev\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fff72c74fb6a0da29accf0db83ad4b4b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fff72c74fb6a0da29accf0db83ad4b4b?s=96&d=mm&r=g\",\"caption\":\"crossan007\"},\"url\":\"https:\/\/crossan007.dev\/blog\/author\/crossan007\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/","og_locale":"en_US","og_type":"article","og_title":"Intermittently Slow IIS web site - Charles&#039; Blog","og_description":"TL;DR: An issue in the Windows Management Instrumentation (WMI) performance counter collection process caused periodic system-wide performance degradation. This issue became visible when our infrastructure monitoring software invoked specific WMI queries. We disabled the specific WMI query set which was causing the performance issues, and the problem went away. A few days ago one of &hellip; Continue reading Intermittently Slow IIS web site &rarr;","og_url":"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/","og_site_name":"Charles&#039; Blog","article_published_time":"2019-06-03T18:36:16+00:00","article_modified_time":"2019-06-03T20:42:53+00:00","twitter_misc":{"Written by":"crossan007","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/crossan007.dev\/blog\/#website","url":"https:\/\/crossan007.dev\/blog\/","name":"Charles&#039; Blog","description":"SharePoint | PowerShell | Exchange | SCCM | Ubuntu | PHP | JavaScript | A\/V Live Production | More...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/crossan007.dev\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/#webpage","url":"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/","name":"Intermittently Slow IIS web site - Charles&#039; Blog","isPartOf":{"@id":"https:\/\/crossan007.dev\/blog\/#website"},"datePublished":"2019-06-03T18:36:16+00:00","dateModified":"2019-06-03T20:42:53+00:00","author":{"@id":"https:\/\/crossan007.dev\/blog\/#\/schema\/person\/bd99569cd81332c8fd866d023848b979"},"breadcrumb":{"@id":"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/crossan007.dev\/blog\/windows-server\/intermittently-slow-iis-web-site\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/crossan007.dev\/blog\/"},{"@type":"ListItem","position":2,"name":"Intermittently Slow IIS web site"}]},{"@type":"Person","@id":"https:\/\/crossan007.dev\/blog\/#\/schema\/person\/bd99569cd81332c8fd866d023848b979","name":"crossan007","image":{"@type":"ImageObject","@id":"https:\/\/crossan007.dev\/blog\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/fff72c74fb6a0da29accf0db83ad4b4b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fff72c74fb6a0da29accf0db83ad4b4b?s=96&d=mm&r=g","caption":"crossan007"},"url":"https:\/\/crossan007.dev\/blog\/author\/crossan007\/"}]}},"_links":{"self":[{"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/posts\/602"}],"collection":[{"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/comments?post=602"}],"version-history":[{"count":9,"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/posts\/602\/revisions"}],"predecessor-version":[{"id":612,"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/posts\/602\/revisions\/612"}],"wp:attachment":[{"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/media?parent=602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/categories?post=602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/crossan007.dev\/blog\/wp-json\/wp\/v2\/tags?post=602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}