{"id":741,"date":"2015-12-14T23:43:31","date_gmt":"2015-12-15T05:43:31","guid":{"rendered":"http:\/\/www.crccheck.com\/blog\/?p=741"},"modified":"2015-12-14T23:45:01","modified_gmt":"2015-12-15T05:45:01","slug":"apache-bench","status":"publish","type":"post","link":"https:\/\/www.crccheck.com\/blog\/apache-bench\/","title":{"rendered":"Apache Bench"},"content":{"rendered":"<p>For years, my tool for simple load tests of HTTP sites has been ApacheBench.<\/p>\n<p>For years, my reference for how to visualize ApacheBench results has been Gnuplot<\/p>\n<p>For years, my reference for how to use Gnuplot has been http:\/\/www.bradlanders.com\/2013\/04\/15\/apache-bench-and-gnuplot-youre-probably-doing-it-wrong\/<\/p>\n<p>But do you really want to be writing Gnuplot syntax? It turns out that Pandas will give you great graphs pretty much for free:<\/p>\n<pre><span class=\"n\">df<\/span> <span class=\"o\">=<\/span> <span class=\"n\">pd<\/span><span class=\"o\">.<\/span><span class=\"n\">read_table<\/span><span class=\"p\">(<\/span><span class=\"s\">'..\/gaussian.tsv'<\/span><span class=\"p\">)\r\n# The raw data as a scatterplot\r\n<\/span><span class=\"n\">df<\/span><span class=\"o\">.<\/span><span class=\"n\">plot<\/span><span class=\"p\">(<\/span><span class=\"n\">x<\/span><span class=\"o\">=<\/span><span class=\"s\">'seconds'<\/span><span class=\"p\">,<\/span> <span class=\"n\">y<\/span><span class=\"o\">=<\/span><span class=\"s\">'wait'<\/span><span class=\"p\">,<\/span> <span class=\"n\">kind<\/span><span class=\"o\">=<\/span><span class=\"s\">'scatter'<\/span><span class=\"p\">)\r\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-782\" src=\"http:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/scatter-300x203.png\" alt=\"scatter\" width=\"300\" height=\"203\" srcset=\"https:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/scatter-300x203.png 300w, https:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/scatter.png 400w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>\r\n# The traditional Gnuplot plot\r\n<\/span><span class=\"n\">df<\/span><span class=\"o\">.<\/span><span class=\"n\">plot<\/span><span class=\"p\">(<\/span><span class=\"n\">y<\/span><span class=\"o\">=<\/span><span class=\"s\">'wait'<\/span><span class=\"p\">)\r\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-781\" src=\"http:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/wait-300x198.png\" alt=\"wait\" width=\"300\" height=\"198\" srcset=\"https:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/wait-300x198.png 300w, https:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/wait.png 388w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>\r\n# Histogram\r\n<\/span><span class=\"n\">df<\/span><span class=\"o\">.<\/span><span class=\"n\">wait<\/span><span class=\"o\">.<\/span><span class=\"n\">hist<\/span><span class=\"p\">(<\/span><span class=\"n\">bins<\/span><span class=\"o\">=<\/span><span class=\"mi\">20<\/span><span class=\"p\">)<\/span><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-780\" src=\"http:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/distribution-300x201.png\" alt=\"distribution\" width=\"300\" height=\"201\" srcset=\"https:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/distribution-300x201.png 300w, https:\/\/www.crccheck.com\/blog\/wp-content\/uploads\/2015\/12\/distribution.png 382w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>You can see the full source code at <a href=\"https:\/\/github.com\/crccheck\/abba\/blob\/master\/notebooks\/tsv_processing.ipynb\" target=\"_blank\">tsv_processing.ipynb<\/a><\/p>\n<p>And re-recreate these yourself by checking out the parent repo: <a href=\"https:\/\/github.com\/crccheck\/abba\" target=\"_blank\">github\/crccheck\/abba<\/a><\/p>\n<p>So now you might be thinking: How do you get a web server that outputs a normal distribution of lag? Well, I wrote one! I made a tiny Express.js server that just waits a random amount, packaged it in a Docker image, and and you can see exactly how I ran these tests by checking out my <a href=\"https:\/\/github.com\/crccheck\/abba\/blob\/master\/Makefile\" target=\"_blank\">Makefile<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For years, my tool for simple load tests of HTTP sites has been ApacheBench. For years, my reference for how to visualize ApacheBench results has been Gnuplot For years, my reference for how to use Gnuplot has been http:\/\/www.bradlanders.com\/2013\/04\/15\/apache-bench-and-gnuplot-youre-probably-doing-it-wrong\/ But do you really want to be writing Gnuplot syntax? It turns out that Pandas will&hellip;<\/p>\n <a href=\"https:\/\/www.crccheck.com\/blog\/apache-bench\/\" title=\"Apache Bench\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">Apache Bench<\/span><\/a>","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[5,4],"tags":[70,81,48],"class_list":["entry","author-showmewhatyougot","post-741","post","type-post","status-publish","format-standard","category-drafts","category-technical","tag-docker","tag-pandas","tag-python"],"_links":{"self":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/comments?post=741"}],"version-history":[{"count":6,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/741\/revisions"}],"predecessor-version":[{"id":786,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/posts\/741\/revisions\/786"}],"wp:attachment":[{"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/media?parent=741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/categories?post=741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.crccheck.com\/blog\/wp-json\/wp\/v2\/tags?post=741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}