{"id":3269,"date":"2020-11-21T21:54:17","date_gmt":"2020-11-21T16:24:17","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/blog\/?p=3269"},"modified":"2020-11-21T21:59:02","modified_gmt":"2020-11-21T16:29:02","slug":"load-testing-web-servers-with-apache-benchmark-tool","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/","title":{"rendered":"Load Testing Web Servers with apache benchmark tool"},"content":{"rendered":"\n<p>Command to run the\u00a0Apache benchmark tool (ab)\u00a0with\u00a0<strong>200<\/strong>\u00a0simultaneous requests until\u00a0<strong>2000<\/strong>\u00a0requests are completed:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># ab -k -c 100 -n 2000 localhost\/checkiffileexists.php\n<\/pre>\n\n\n\n<p>Let\u2019s run the test and compare the results. Pay attention to the performance statistics:<\/p>\n\n\n\n<figure class=\"wp-block-image\" id=\"attachment_17263\"><a href=\"https:\/\/i0.wp.com\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png?ssl=1\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png?w=640&#038;ssl=1\" alt=\"Apache Performance Load Testing\" class=\"wp-image-17263\" data-recalc-dims=\"1\"\/><\/a><figcaption>Apache Performance Load Testing<\/figcaption><\/figure>\n\n\n\n<p>As you can see, the performance of the server with the event is highly superior to its\u00a0<strong>prefork<\/strong>\u00a0counterpart in every aspect of this test.<\/p>\n\n\n\n<p>This is the php code that I\u2019ve saved into a file named&nbsp;<code>checkiffileexists.php<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;?php\n$filename = 'test.php';\n\nif (file_exists($filename)) {\n    echo \"The file $filename exists\";\n} else {\n    echo \"The file $filename does not exist\";\n}\n?&gt;<\/pre>\n\n\n\n<p>Suppose you wanted to test multiple URL&#8217;s concurrently as well? You can do this by creating a shell script, with multiple ab calls. At the end of each line place, this makes the command run in the background and lets the next command start execution. You will also want to redirect the output to a file for each URL using\u00a0<code>> filename<\/code>\u00a0For example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/sh\n\nab -n 100 -c 10 http:\/\/127.0.0.1:8300\/test.cfm &gt; test1.txt &amp;\nab -n 100 -c 10 http:\/\/127.0.0.1:8300\/scribble.cfm &gt; test2.txt &amp;\n<\/pre>\n\n\n\n<p>The usage info from the&nbsp;<code>ab<\/code>&nbsp;version installed on my Mac (v2.3) is listed below. As you can see there are many useful options for outputting results, and sending additional data in the request.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Usage: ab [options] [http[s]:\/\/]hostname[:port]\/path\nOptions are:\n&nbsp;&nbsp;&nbsp;&nbsp;-n requests     Number of requests to perform\n&nbsp;&nbsp;&nbsp;&nbsp;-c concurrency  Number of multiple requests to make\n&nbsp;&nbsp;&nbsp;&nbsp;-t timelimit    Seconds to max. wait for responses\n&nbsp;&nbsp;&nbsp;&nbsp;-b windowsize   Size of TCP send\/receive buffer, in bytes\n&nbsp;&nbsp;&nbsp;&nbsp;-p postfile     File containing data to POST. Remember also to set -T\n&nbsp;&nbsp;&nbsp;&nbsp;-T content-type Content-type header for POSTing, eg.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'application\/x-www-form-urlencoded'\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default is 'text\/plain'\n&nbsp;&nbsp;&nbsp;&nbsp;-v verbosity    How much troubleshooting info to print\n&nbsp;&nbsp;&nbsp;&nbsp;-w              Print out results in HTML tables\n&nbsp;&nbsp;&nbsp;&nbsp;-i              Use HEAD instead of GET\n&nbsp;&nbsp;&nbsp;&nbsp;-x attributes   String to insert as table attributes\n&nbsp;&nbsp;&nbsp;&nbsp;-y attributes   String to insert as tr attributes\n&nbsp;&nbsp;&nbsp;&nbsp;-z attributes   String to insert as td or th attributes\n&nbsp;&nbsp;&nbsp;&nbsp;-C attribute    Add cookie, eg. 'Apache=1234. (repeatable)\n&nbsp;&nbsp;&nbsp;&nbsp;-H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inserted after all normal header lines. (repeatable)\n&nbsp;&nbsp;&nbsp;&nbsp;-A attribute    Add Basic WWW Authentication, the attributes\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;are a colon separated username and password.\n&nbsp;&nbsp;&nbsp;&nbsp;-P attribute    Add Basic Proxy Authentication, the attributes\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;are a colon separated username and password.\n&nbsp;&nbsp;&nbsp;&nbsp;-X proxy:port   Proxyserver and port number to use\n&nbsp;&nbsp;&nbsp;&nbsp;-V              Print version number and exit\n&nbsp;&nbsp;&nbsp;&nbsp;-k              Use HTTP KeepAlive feature\n&nbsp;&nbsp;&nbsp;&nbsp;-d              Do not show percentiles served table.\n&nbsp;&nbsp;&nbsp;&nbsp;-S              Do not show confidence estimators and warnings.\n&nbsp;&nbsp;&nbsp;&nbsp;-g filename     Output collected data to gnuplot format file.\n&nbsp;&nbsp;&nbsp;&nbsp;-e filename     Output CSV file with percentages served\n&nbsp;&nbsp;&nbsp;&nbsp;-r              Don't exit on socket receive errors.\n&nbsp;&nbsp;&nbsp;&nbsp;-h              Display usage information (this message)\n&nbsp;&nbsp;&nbsp;&nbsp;-Z ciphersuite  Specify SSL\/TLS cipher suite (See openssl ciphers)\n&nbsp;&nbsp;&nbsp;&nbsp;-f protocol     Specify SSL\/TLS protocol (SSL2, SSL3, TLS1, or ALL)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Command to run the\u00a0Apache benchmark tool (ab)\u00a0with\u00a0200\u00a0simultaneous requests until\u00a02000\u00a0requests are completed: # ab -k -c 100 -n 2000 localhost\/checkiffileexists.php Let\u2019s run the test and compare the results. Pay attention to the performance statistics: As you can see, the performance of the server with the event is highly superior to its\u00a0prefork\u00a0counterpart in every aspect of this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[139,30,34],"tags":[119,31,340],"class_list":["post-3269","post","type-post","status-publish","format-standard","hentry","category-apache","category-centos","category-linux","tag-apache","tag-centos","tag-load-test"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Load Testing Web Servers with apache benchmark tool | 24x7serversupport Blog<\/title>\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.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Load Testing Web Servers with apache benchmark tool | 24x7serversupport Blog\" \/>\n<meta property=\"og:description\" content=\"Command to run the\u00a0Apache benchmark tool (ab)\u00a0with\u00a0200\u00a0simultaneous requests until\u00a02000\u00a0requests are completed: # ab -k -c 100 -n 2000 localhost\/checkiffileexists.php Let\u2019s run the test and compare the results. Pay attention to the performance statistics: As you can see, the performance of the server with the event is highly superior to its\u00a0prefork\u00a0counterpart in every aspect of this [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-21T16:24:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-21T16:29:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/\",\"name\":\"Load Testing Web Servers with apache benchmark tool | 24x7serversupport Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png\",\"datePublished\":\"2020-11-21T16:24:17+00:00\",\"dateModified\":\"2020-11-21T16:29:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#primaryimage\",\"url\":\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png\",\"contentUrl\":\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Load Testing Web Servers with apache benchmark tool\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Load Testing Web Servers with apache benchmark tool | 24x7serversupport Blog","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.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/","og_locale":"en_US","og_type":"article","og_title":"Load Testing Web Servers with apache benchmark tool | 24x7serversupport Blog","og_description":"Command to run the\u00a0Apache benchmark tool (ab)\u00a0with\u00a0200\u00a0simultaneous requests until\u00a02000\u00a0requests are completed: # ab -k -c 100 -n 2000 localhost\/checkiffileexists.php Let\u2019s run the test and compare the results. Pay attention to the performance statistics: As you can see, the performance of the server with the event is highly superior to its\u00a0prefork\u00a0counterpart in every aspect of this [&hellip;]","og_url":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/","og_site_name":"24x7serversupport Blog","article_published_time":"2020-11-21T16:24:17+00:00","article_modified_time":"2020-11-21T16:29:02+00:00","og_image":[{"url":"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png"}],"author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/","url":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/","name":"Load Testing Web Servers with apache benchmark tool | 24x7serversupport Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#primaryimage"},"thumbnailUrl":"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png","datePublished":"2020-11-21T16:24:17+00:00","dateModified":"2020-11-21T16:29:02+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#primaryimage","url":"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png","contentUrl":"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/11\/Apache-Performance-Load-Testing.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/load-testing-web-servers-with-apache-benchmark-tool\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Load Testing Web Servers with apache benchmark tool"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=3269"}],"version-history":[{"count":3,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3269\/revisions"}],"predecessor-version":[{"id":3273,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3269\/revisions\/3273"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=3269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=3269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=3269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}