{"id":35,"date":"2015-07-13T09:09:36","date_gmt":"2015-07-13T09:09:36","guid":{"rendered":"http:\/\/loadfocus.com\/blog\/tech\/?p=35"},"modified":"2023-04-10T20:00:59","modified_gmt":"2023-04-10T20:00:59","slug":"how-to-measure-cpu-and-memory-while-running-a-load-test","status":"publish","type":"post","link":"https:\/\/loadfocus.com\/blog\/tech\/2015\/07\/how-to-measure-cpu-and-memory-while-running-a-load-test","title":{"rendered":"How to Measure CPU and Memory while Running a Load Test"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\"><\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes read<\/span><\/span><p class=\"lead\">In order to make\u00a0sure that your application will not break under a heavy load, a web application owner has to perform some basic performance tests.<\/p>\n<p>Here are\u00a04 simple steps how to achieve this with LoadFocus <a href=\"https:\/\/loadfocus.com\">load testing tool<\/a>:<\/p>\n<ol>\n<li>Log into your account on the LoadFocus platform<\/li>\n<li>Click on the \u201cNew Load Test\u201d menu<\/li>\n<li>Enter the details of your web application (the endpoint\/URL that you want to access, the number of clients per second and the number of seconds that the test will run) \u2013 check image attached for an example<\/li>\n<li>Before starting the test log into your server and use the script that we provide for monitoring the CPU and memory as below (the script is developed for Linux servers):\n<ol>\n<li>copy the script cpu_mem_stats.sh to the server where your application is installed: <a href=\"https:\/\/loadfocus.com\/blog\/wp-content\/uploads\/cpu_mem_stats.sh\" target=\"_blank\" rel=\"noopener noreferrer\">click here to download script.<\/a><\/li>\n<li>run the following command:\n<pre class=\"lang-java\"><code class=\"lang-java\">\nchmod 777 cpu_mem_stats.sh\n<\/code><\/pre>\n<\/li>\n<li>run the following command:\n<pre class=\"lang-java\"><code class=\"lang-java\">\n.\/cpu_mem_stats.sh -p node -t 200 -f \/home\/ubuntu\/log.txt -c true\n<\/code><\/pre>\n<\/li>\n<li>the meaning of the parameters is (please modify according to your needs):<\/li>\n<\/ol>\n<ul>\n<li><i>-p &#8211; The process name to look for<\/i><\/li>\n<li><i>-t &#8211; The time to monitor specified in seconds<\/i><\/li>\n<li><i>-f &#8211; path to the file to write the output (if not specified the output will be logged into the console)<\/i><\/li>\n<li><i>-c &#8211; if specified as true will output in CSV format<\/i><\/li>\n<\/ul>\n<ol start=\"5\">\n<li>Start your load test from LoadFocus.com<\/li>\n<li>The result of the response times will give you a graph like this:<\/li>\n<li>After the test ends get the result from the stats test on your server (in our example log.txt)<\/li>\n<li>For creating the graphs from the result files we recommend the following online solution: https:\/\/plot.ly\/ . From that you will get a graph similar to:<\/li>\n<li>Now by using the graphs from LoadFocus and the results from the <em>cpu_mem_stats.sh<\/em> you can correlate how you server is behaving under load, which will give you an idea if the machine needs to be upgraded or is enough to support the load your clients will generate.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\"><\/span> <span class=\"rt-time\"> 2<\/span> <span class=\"rt-label rt-postfix\">minutes read<\/span><\/span>In order to make\u00a0sure that your application will not break under a heavy load, a web application owner has to perform some basic performance tests. Here are\u00a04 simple steps how to achieve this with LoadFocus load testing tool: Log into your account on the LoadFocus platform Click on the \u201cNew Load Test\u201d menu Enter the&#8230;  <a href=\"https:\/\/loadfocus.com\/blog\/tech\/2015\/07\/how-to-measure-cpu-and-memory-while-running-a-load-test\" class=\"more-link\" title=\"Read How to Measure CPU and Memory while Running a Load Test\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/posts\/35"}],"collection":[{"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":11,"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":405,"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/posts\/35\/revisions\/405"}],"wp:attachment":[{"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/loadfocus.com\/blog\/tech\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}