{"id":505,"date":"2013-01-15T18:27:50","date_gmt":"2013-01-15T23:27:50","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2013\/01\/15\/determine-cause-of-server-usage-spike\/"},"modified":"2022-04-04T19:42:49","modified_gmt":"2022-04-04T23:42:49","slug":"determine-cause-of-server-usage-spike","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/","title":{"rendered":"How to Determine the cause of a Server Usage Spike"},"content":{"rendered":"\n<p>In this article we&#8217;ll review what steps you can take if your server&#8217;s load average is spiking, to help determine the root cause of the issues.<\/p>\n<p class=\"alert\">For these examples, you would need to be on a VPS (Virtual Private Server), or dedicated server so that you have SSH access to the server to run commands on the command line.<\/p>\n<h2>Determining the cause of Server Usage Spike<\/h2>\n<ol class=\"article_list\">\n<li><a href=\"\/support\/server\/ssh\/how-to-login-ssh\/\">Login to your server via SSH<\/a>.<\/li>\n<li>Check on the load average of your server over a minute with the following command:\n<code>sar -q 5 12<\/code><\/p>\n<code style=\"white-space: pre-wrap; margin-left: 20px;\">\n02:10:06 PM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15 \n02:10:11 PM         1       112      1.29      1.36      1.43 \n02:10:16 PM         3       109      1.27      1.35      1.43 \n02:10:21 PM         3       108      1.41      1.38      1.44 \n02:10:26 PM         4       118      1.62      1.42      1.45 \n02:10:31 PM         0       108      1.73      1.45      1.46 \n02:10:36 PM         4       119      1.67      1.44      1.46 \n02:10:41 PM         2       122      1.69      1.45      1.46 \n02:10:46 PM         0       113      1.64      1.44      1.46 \n02:10:51 PM         2       112      1.59      1.44      1.46 \n02:10:56 PM         0       103      1.46      1.41      1.45 \n02:11:01 PM         1       102      1.42      1.40      1.44 \n02:11:06 PM         0        97      1.31      1.38      1.44 \nAverage:            2       110      1.51      1.41      1.45 <\/code>\n<p>This will run the <strong>sar<\/strong> command with the <strong>-q<\/strong> flag that shows load averages.<\/p>\n<p>The <strong>5<\/strong> tells it to run a check every 5 seconds, and the <strong>12<\/strong> tells it to do it 12 times.<\/p>\n<p>If your <strong>ldavg-1<\/strong> column stays consistently high, or continues to rise during this load check, this is an indication that you could have something on the server spiking its usage.<\/p>\n<\/li>\n<li>Now we noticed from looking at our load averages that at <strong>2:10:11 PM<\/strong> the load was <strong>1.29<\/strong>, and it continued to spike up till <strong>02:10:31 PM<\/strong> where the load got as high as <strong>1.73<\/strong>.\n<p>It&#8217;s very common that websites being accessed, and having to run PHP scripts, or other server side code can cause these spikes in your usage. So you can check in your Apache access logs for what might have been going on around the time of the spike.<\/p>\n<p>Using the following code we are going to look at our website&#8217;s access log to see how many &#8220;hits&#8221; happened from <strong>2:09PM &#8211; 2:10PM (14:09 &#8211; 14:10)<\/strong>. This way we can see the requests leading up to the spike, as well as after:<\/p>\n<br><code>egrep \"15\/Jan\/2013:14:09|15\/Jan\/2013:14:10\" \/home\/userna5\/access-logs\/example.com | wc -l<\/code><br>\n<code>502<\/code>\n<p>So here we can see that there were <strong>502<\/strong> requests over those 2 minutes. We can take this a bit further even and break down how many requests happened per minute with this code:<\/p>\n<br><code style=\"white-space: pre-wrap; margin-left: 20px;\">egrep \"15\/Jan\/2013:14:09|15\/Jan\/2013:14:10\" example.com | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2\":\"$3}' | sort -nk1 -nk2 | uniq -c | sed 's\/[ ]*\/\/'<\/code><br><br>\n<code>164 14:09<br \/>338 14:10<\/code>\n<p>This right here is already a pretty telling sign, our load average started to spike at <strong>2:10 PM (14:10)<\/strong> and during that minute we had almost double the amount of requests to our site as the previous minute. So it would make sense that the server is having to work harder to serve more requests.<\/p>\n<\/li>\n<li>Now comes the part where we take an even deeper look at what was going on with the requests. Because the server can easily handle 100 or so image or plain HTML page requests with less of a usage spike than having to run PHP scripts for instance, it&#8217;s important to know exactly what is getting requested.\n<p>We can use the following command in order to see what duplicate requests have been happening:<\/p>\n<code style=\"white-space: pre-wrap; margin-left: 20px;\">egrep \"15\/Jan\/2013:14:09|15\/Jan\/2013:14:10\" example.com | cut -d\" -f2 | awk '{print $1 \" \" $2}' | cut -d? -f1 | sort | uniq -c | sort -n | sed 's\/[ ]*\/\/'<\/code>\n<code style=\"white-space: pre-wrap; margin-left: 20px;\">15 GET \/wp-content\/plugins\/s2member\/s2member-o.php<br><br \/>22 GET \/about-us\/<br \/>26 GET \/wp-content\/uploads\/2012\/06\/logo.png<\/code>\n<p>Here we can see that this happens to be a WordPress site, the highest duplicated request is a <strong>logo.png<\/strong> image so that&#8217;s probably not going to cause a load spike. However the <strong>22<\/strong> requests for <strong>\/about-us\/<\/strong>, and <strong>15<\/strong> for <strong>\/wp-content\/plugins\/s2member\/s2member-o.php<\/strong>\u00a0in a 2 minute period might have.<\/p>\n<p>\u00a0<\/p>\n<p>Taking a look at this WordPress site, I noticed that there is currently no form of caching enabled such as using the <a href=\"https:\/\/www.inmotionhosting.com\/support\/product-guides\/wordpress-hosting\/w3-total-cache\/\" target=\"_blank\" rel=\"noopener noreferrer\">W3 Total Cache plugin<\/a>. As such that means that each time the <strong>\/about-us\/<\/strong> page is getting requested, the server is going to have to re-process the PHP script, connect to the database, and retreive the page. So here we were able to determine within a few minutes of a server load spike that our possible culprit of that spike was a sudden influx in requests for a WordPress page that isn&#8217;t cached.<\/p>\n<\/li>\n<\/ol>\n<p>You should now have a basic understanding of how to track down the possible cause of a server load spike. Now you might also be interested in reading our articles about <a href=\"\/support\/server\/server-usage\/advanced-server-load-monitoring\/\" target=\"_blank\" rel=\"noopener noreferrer\">advanced server load monitoring<\/a>, or about<a href=\"\/support\/server\/server-usage\/create-server-load-monitoring-bash-script\/\" target=\"_blank\" rel=\"noopener noreferrer\"> how to create a server load monitoring bash script<\/a> to alert you via email when your server&#8217;s load is spiking.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article we&#8217;ll review what steps you can take if your server&#8217;s load average is spiking, to help determine the root cause of the issues. For these examples, you would need to be on a VPS (Virtual Private Server), or dedicated server so that you have SSH access to the server to run commands<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4364],"tags":[],"class_list":["post-505","post","type-post","status-publish","format-standard","hentry","category-server-usage"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Determine the cause of a Server Usage Spike | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this article we&#039;ll review what steps you can take if your server&#039;s load average is spiking, to help determine the root cause of the issues.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Determine the cause of a Server Usage Spike | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this article we&#039;ll review what steps you can take if your server&#039;s load average is spiking, to help determine the root cause of the issues.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2013-01-15T23:27:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-04T23:42:49+00:00\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\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\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"How to Determine the cause of a Server Usage Spike\",\"datePublished\":\"2013-01-15T23:27:50+00:00\",\"dateModified\":\"2022-04-04T23:42:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\"},\"wordCount\":643,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Server Usage\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\",\"name\":\"How to Determine the cause of a Server Usage Spike | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2013-01-15T23:27:50+00:00\",\"dateModified\":\"2022-04-04T23:42:49+00:00\",\"description\":\"In this article we'll review what steps you can take if your server's load average is spiking, to help determine the root cause of the issues.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Determine the cause of a Server Usage Spike\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Determine the cause of a Server Usage Spike | InMotion Hosting","description":"In this article we'll review what steps you can take if your server's load average is spiking, to help determine the root cause of the issues.","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:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/","og_locale":"en_US","og_type":"article","og_title":"How to Determine the cause of a Server Usage Spike | InMotion Hosting","og_description":"In this article we'll review what steps you can take if your server's load average is spiking, to help determine the root cause of the issues.","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2013-01-15T23:27:50+00:00","article_modified_time":"2022-04-04T23:42:49+00:00","author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"How to Determine the cause of a Server Usage Spike","datePublished":"2013-01-15T23:27:50+00:00","dateModified":"2022-04-04T23:42:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/"},"wordCount":643,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Server Usage"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/","name":"How to Determine the cause of a Server Usage Spike | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2013-01-15T23:27:50+00:00","dateModified":"2022-04-04T23:42:49+00:00","description":"In this article we'll review what steps you can take if your server's load average is spiking, to help determine the root cause of the issues.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/server-usage\/determine-cause-of-server-usage-spike\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Determine the cause of a Server Usage Spike"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=505"}],"version-history":[{"count":6,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/505\/revisions"}],"predecessor-version":[{"id":95644,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/505\/revisions\/95644"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}