{"id":1811,"date":"2009-04-30T07:16:56","date_gmt":"2009-04-30T07:16:56","guid":{"rendered":"http:\/\/justthesam.com\/2009\/04\/apache-bench-notes\/"},"modified":"2009-04-30T07:16:56","modified_gmt":"2009-04-30T07:16:56","slug":"apache-bench-notes","status":"publish","type":"post","link":"https:\/\/justthesam.com\/?p=1811","title":{"rendered":"Apache Bench Notes"},"content":{"rendered":"<div>Many people don&#39;t know about Apache Bench, even though it may be installed on their system. For instance it&#39;s installed on Mac OS X by default. It&#39;s a very simple command line utility to perform basic stress\/performance testing of websites. It can request a given URL repeatedly, then report back statistics. I generally use it in this form:<\/div>\n<p><\/p>\n<div><span style=\"font-family: Courier;\">&gt; ab -n 100 -c 4 http:\/\/www.somewebsite.com\/test\/page.htm<\/span><\/div>\n<p><\/p>\n<div>Dissecting that command:<\/div>\n<div>\n<ul>\n<li>ab is the Apache Bench executable itself (found in \/usr\/sbin on my machine)<\/li>\n<li><span>-n 100 tells it to send the request 100 times<\/span>&#0160;<\/li>\n<li><span>-c 4 tells it to use 4 concurrent threads to do so<\/span><\/li>\n<li><span>finally we have the URL itself.<\/span>&#0160;<\/li>\n<\/ul>\n<p>Even though it&#39;s simple, there are some important gotchas worth knowing about:<\/p><\/div>\n<div>\n<ul>\n<li>Remember to put the URL in single quotes if it contains characters that would otherwise be interpreted by the shell. This is often the case for any URL with a query string, as the &amp; characters will mess things up otherwise.&#0160;<\/li>\n<li><span>If using a base URL for a site (just host name), you must use a trailing slash. http:\/\/foo.com doesn&#39;t work, but http:\/\/foo.com\/ does work.<\/span>&#0160;<\/li>\n<li><span>Quite often you may see in the statistics &quot;Failed requests: 5&quot; or similar, followed by a list of the types of failure: &quot;(Connect: 0, Receive: 0, Length: 5, Exceptions: 0)&quot;. If the only type of failure that actually occurred is &#39;Length&#39; then don&#39;t be alarmed. This simply means that each request (for the same URL) returned a different length response, which ab regards as suspicious. However it&#39;s perfectly normal for dynamic webpages, especially if they include the time or other very dynamic data on the page.<\/span>&#0160;<\/li>\n<li><span>I find on one of my machines that it just doesn&#39;t like localhost as a hostname, so I have to use 127.0.0.1 instead. I have no idea why, as localhost works fine in other contexts on the same machine.<\/span>&#0160;<\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Many people don&#39;t know about Apache Bench, even though it may be installed on their system. For instance it&#39;s installed on Mac OS X by default. It&#39;s a very simple command line utility to perform basic stress\/performance testing of websites. It can request a given URL repeatedly, then report back statistics. I generally use it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,22,33],"tags":[],"class_list":["post-1811","post","type-post","status-publish","format-standard","hentry","category-mac","category-programming","category-webtech"],"_links":{"self":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts\/1811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1811"}],"version-history":[{"count":0,"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts\/1811\/revisions"}],"wp:attachment":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}