{"id":3897,"date":"2016-05-22T01:04:59","date_gmt":"2016-05-22T05:04:59","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=3897"},"modified":"2016-07-09T06:18:19","modified_gmt":"2016-07-09T10:18:19","slug":"setup-locust-python-windows","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/setup-locust-python-windows\/","title":{"rendered":"Setup Locust (Python\/load testing) on Windows"},"content":{"rendered":"<p>I recently used <a href=\"http:\/\/locust.io\/\">Locust<\/a>, a load testing tool that lets you write intuitive looking Python code to load test your web applications. I did not follow Locust&#8217;s install guide and instead just tried a &#8216;pip install locustio&#8217;. I ended up running into some issues that were not easy to Google about. So I thought I would document the problems I faced along with there solution over here.<\/p>\n<hr>\n<h3>Getting setup with Locust on Windows<\/h3>\n<p>If you have not already tried installing Locust, follow this short and handy guide. It will help you avoid the problems I faced.<\/p>\n<p>1. Use Python 2.7.x where x >=4. I upgraded my Python to 2.7.11.<br \/>\n2. <code>pip install pyzmq<\/code><br \/>\n3. <code>pip install locustio<\/code><br \/>\n4. Test your installation by opening up a command prompt and typing <code>locust.--help<\/code> You should see no errors or warning &#8211; only the usage and help should be printed out on your console.<\/p>\n<hr>\n<h3>Locust install issues and solutions<\/h3>\n<p>When I installed Locust for the first time, I missed steps 1 and 2 in the section above. So I ran into a couple of errors.<\/p>\n<p>1. <strong>ImportError: DLL load failed<\/strong><\/p>\n<blockquote><p>from gevent.hub import get_hub, iwait, wait, PYPY<br \/>\nFile &#8220;c:\\python27\\lib\\site-packages\\gevent\\hub.py&#8221;, line 11, in <module><br \/>\nfrom greenlet import greenlet, getcurrent, GreenletExit<br \/>\nImportError: DLL load failed: The specified procedure could not be found.\n<\/p><\/blockquote>\n<p>I got this error because I had Python 2.7.2 (python &#8211;version) and Locust needs at least Python 2.7.4. To solve this issue, upgrade your Python version. I ended up installing Python 2.7.11.<\/p>\n<p>2. <strong>UserWarning: WARNING: Using pure Python socket RPC implementation instead of zmq<\/strong><\/p>\n<blockquote><p>c:\\python27\\lib\\site-packages\\locust\\rpc__init__.py:6: UserWarning: WARNING: Using pure Python socket RPC implementation instead of zmq.<\/p><\/blockquote>\n<p>I got this warning when running the command &#8216;locust &#8211;help&#8217; to test my setup. The warning comes with a helpful recommendation to install pyzmq. I installed pyzmq (<code>pip install pyzmq<\/code>) and the error went away. <\/p>\n<p>3. <strong>pip install locustio gives error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).<br \/>\n<\/strong><\/p>\n<p>I got the below error when install locust using <em>pip install locustio<\/em><\/p>\n<blockquote><p>building &#8216;gevent.corecext&#8217; extension<br \/>\nerror: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat).<\/p><\/blockquote>\n<p>I tried installing &#8220;gevent&#8221; alone using <em>pip install gevent<\/em>, but got the same error<\/p>\n<p>After bit of searching i installed &#8220;gevent&#8221; from <a href=\"http:\/\/www.lfd.uci.edu\/~gohlke\/pythonlibs\/#gevent\">unofficial windows Binaries<\/a> for Python Extension Packages.<br \/>\nDownload the whl file as per your os combination. I downloaded gevent-1.1.1-cp27-cp27m-win32.whl file.<br \/>\nopen command prompt in the directory where you have downloaded whl file and run the below command. <\/p>\n<pre lang='python'>python -m pip install gevent-1.1.1-cp27-cp27m-win32.whl<\/pre>\n<p>After that i was able to install locust successfully.<\/p>\n<hr>\n<h3>My thoughts on Locust as of May, 2016<\/h3>\n<p>A random collection of my thoughts having explored Locust for a little bit.<\/p>\n<p>1. This tool is worth exploring deeper. This is the first load testing tool that I found intuitive.<br \/>\n2. Locust lets me reuse the API checks that I anyway write as part of testing a web application<br \/>\n3. I liked Locust&#8217;s documentation. I found the documentation very, ummm, Pythonic! Clearly they have put in effort into making the documentation useful.<br \/>\n4. I got a useful, working prototype for a real world problem in less than a weekend<br \/>\n5. I don&#8217;t know how powerful their http client (the one you use to make requests) is &#8230; so we may trip up at login for some clients.<br \/>\n6. I hated the way they do not have an automatic &#8216;end&#8217; to any test &#8211; but that is a minor complaint<br \/>\n7. With respect to the resources (memory, CPU) on the client machine, locust swarms scale so much better than Qxf2&#8217;s <a href=\"https:\/\/qxf2.com\/blog\/run-your-api-tests-in-parallel-mapreducepython\/\">map-reduce solution<\/a> (think 25:1)<br \/>\n8. There is a limit of 1024 locusts per swarm that maps to the maximum number of files that can be open on Windows. But their documentation warns you about this beforehand. You can increase this number, if needed, on your OS.<br \/>\n9. Their reporting is not persistent or stored<\/p>\n<hr>\n<p>Qxf2 will be exploring this tool over the coming months. I want to try more complex login scenarios, nested tasks and distributed swarms. <\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>I recently used Locust, a load testing tool that lets you write intuitive looking Python code to load test your web applications. I did not follow Locust&#8217;s install guide and instead just tried a &#8216;pip install locustio&#8217;. I ended up running into some issues that were not easy to Google about. So I thought I would document the problems I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[106,88,18],"tags":[],"class_list":["post-3897","post","type-post","status-publish","format-standard","hentry","category-locust","category-performance-testing","category-python"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/3897","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=3897"}],"version-history":[{"count":11,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/3897\/revisions"}],"predecessor-version":[{"id":4105,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/3897\/revisions\/4105"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=3897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=3897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=3897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}