Giter Club home page Giter Club logo

boom's Introduction

ATTENTION Boom is going to be replaced by Boom2 and then deprecated

Follow the progress and join the party here: https://github.com/tarekziade/boom2

ATTENTION

Boom! is a simple command line tool to send some load to a web app.

Boom! is a script you can use to quickly smoke-test your web app deployment. If you need a more complex tool, I'd suggest looking at Funkload or Locust.

Boom! was specifically written to replace my Apache Bench usage, to provide a few missing features and fix a few annoyances I had with AB.

I have no special ambitions for this tool, and since I have not found any tool like this in the Python-land, I wrote this one.

There are a lot of other tools out there, like Siege which seems very popular.

However, Boom! is a good choice because it works on any platform and is able to simulate thousands of users by using greenlets.

Installation

Boom! requires Gevent and Requests. If you are under Windows I strongly recommend installing Gevent with the xxx-win32-py2.7.exe installer you will find at: https://github.com/surfly/gevent/downloads

Boom! should work with the latest versions.

If you are under Linux, installing the source version is usually a better idea. You will need libev for Gevent.

Example under Ubuntu:

$ sudo apt-get install libev libev-dev python-dev

Then:

$ pip install boom

Basic usage

Basic usage example: 100 queries with a maximum concurrency of 10 users:

$ boom http://localhost:80 -c 10 -n 100
Server Software: nginx/1.2.2
Running 100 queries - concurrency: 10.
Starting the load [===================================] Done

-------- Results --------
Successful calls        100
Total time              0.3260 s
Average                 0.0192 s
Fastest                 0.0094 s
Slowest                 0.0285 s
Amplitude               0.0191 s
RPS                     306
BSI                     Pretty good

-------- Legend --------
RPS: Request Per Second
BSI: Boom Speed Index

Boom! has more options:

$ boom --help
usage: boom [-h] [--version] [-m {GET,POST,DELETE,PUT,HEAD,OPTIONS}]
            [--content-type CONTENT_TYPE] [-D DATA] [-c CONCURRENCY] [-a AUTH]
            [--header HEADER] [--pre-hook PRE_HOOK] [--post-hook POST_HOOK]
            [--json-output] [-n REQUESTS | -d DURATION]
            [url]

Simple HTTP Load runner.

positional arguments:
  url                   URL to hit

optional arguments:
  -h, --help            show this help message and exit
  --version             Displays version and exits.
  -m {GET,POST,DELETE,PUT,HEAD,OPTIONS}, --method {GET,POST,DELETE,PUT,HEAD,OPTIONS}
                        HTTP Method
  --content-type CONTENT_TYPE
                        Content-Type
  -D DATA, --data DATA  Data. Prefixed by "py:" to point a python callable.
  -c CONCURRENCY, --concurrency CONCURRENCY
                        Concurrency
  -a AUTH, --auth AUTH  Basic authentication user:password
  --header HEADER       Custom header. name:value
  --pre-hook PRE_HOOK   Python module path (eg: mymodule.pre_hook) to a
                        callable which will be executed before doing a request
                        for example: pre_hook(method, url, options). It must
                        return a tupple of parameters given in function
                        definition
  --post-hook POST_HOOK
                        Python module path (eg: mymodule.post_hook) to a
                        callable which will be executed after a request is
                        done for example: eg. post_hook(response). It must
                        return a given response parameter or raise an
                        `boom.boom.RequestException` for failed request.
  --json-output         Prints the results in JSON instead of the default
                        format
  -n REQUESTS, --requests REQUESTS
                        Number of requests
  -d DURATION, --duration DURATION
                        Duration in seconds

Calling from Python code

You can trigger load testing from Python code by importing the function boom.boom.load directly, as follows:

from boom.boom import load
result = load('http://example.com/', 1, 1, 0, 'GET', None, 'text/plain', None, quiet=True)

Design

Boom uses greenlets through Gevent to create virtual users, and uses Requests to do the queries.

Using greenlets allows Boom to spawn large amounts of virtual users with very little resources. It's not a problem to spawn 1000 users and hammer a web application with them.

If you are interested in this project, you are welcome to join the fun at https://github.com/tarekziade/boom

Make sure to add yourself to the contributors list if your PR gets merged. And make sure it's in alphabetical order!

boom's People

Contributors

tarekziade avatar hanleyhansen avatar rbas avatar andreacrotti avatar acdha avatar lukaszb avatar soasme avatar charlesthomas avatar pearkes avatar ralphbean avatar tinche avatar tomashanacek avatar vstoykov avatar fitoria avatar marcinkuzminski avatar vbabiy avatar jwg4 avatar suzaku avatar

Stargazers

Matt Melquiond avatar

Watchers

Saïdina MOHAMED ALI avatar

Forkers

mattllvw

boom's Issues

With insecure ssl connections on python 3.6+: Max recursion error

Traceback (most recent call last):
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
  File "/home/lpl/projects/perso/boom/boom/boom.py", line 393, in onecall
    res = post_hook(method(url, **options))
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/urllib3/connection.py", line 314, in connect
    cert_reqs=resolve_cert_reqs(self.cert_reqs),
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 269, in create_urllib3_context
    context.options |= options
  File "/home/lpl/.pyenv/versions/3.6.3/lib/python3.6/ssl.py", line 465, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  File "/home/lpl/.pyenv/versions/3.6.3/lib/python3.6/ssl.py", line 465, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  File "/home/lpl/.pyenv/versions/3.6.3/lib/python3.6/ssl.py", line 465, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  [Previous line repeated 317 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/hub.py", line 846, in switch
    switch(value)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/greenlet.py", line 536, in run
    self._report_error(sys.exc_info())
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/greenlet.py", line 518, in _report_error
    self._exc_info = exc_info[0], exc_info[1], dump_traceback(exc_info[2])
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/_tblib.py", line 243, in g
    return f(a)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/_tblib.py", line 298, in dump_traceback
    return dumps(tb)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/_tblib.py", line 217, in pickle_traceback
    return unpickle_traceback, (Frame(tb.tb_frame), tb.tb_lineno, tb.tb_next and Traceback(tb.tb_next))
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/_tblib.py", line 156, in __init__
    self.tb_next = Traceback(tb.tb_next)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/_tblib.py", line 156, in __init__
    self.tb_next = Traceback(tb.tb_next)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/_tblib.py", line 156, in __init__
    self.tb_next = Traceback(tb.tb_next)
  [Previous line repeated 238 more times]
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/_tblib.py", line 151, in __init__
    self.tb_frame = Frame(tb.tb_frame)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/_tblib.py", line 146, in __init__
    self.f_code = Code(frame.f_code)
RecursionError: maximum recursion depth exceeded while calling a Python object
<built-in method switch of Greenlet object at 0x7ff6dc8d8898> failed with RecursionError

 Done
Traceback (most recent call last):
  File "/home/lpl/.pyenv/versions/badaboom/bin/boom", line 11, in <module>
    load_entry_point('boom', 'console_scripts', 'boom')()
  File "/home/lpl/projects/perso/boom/boom/boom.py", line 703, in main
    data_file=scenario.get('data_file', None)
  File "/home/lpl/projects/perso/boom/boom/boom.py", line 536, in load
    insecure=insecure
  File "/home/lpl/projects/perso/boom/boom/boom.py", line 446, in run
    pool.join()
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/pool.py", line 527, in join
    self._empty_event.wait(timeout=timeout)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/event.py", line 207, in wait
    return self._wait(timeout)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/event.py", line 117, in _wait
    gotit = self._wait_core(timeout)
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/event.py", line 95, in _wait_core
    result = self.hub.switch()
  File "/home/lpl/.pyenv/versions/3.6.3/envs/badaboom/lib/python3.6/site-packages/gevent/hub.py", line 609, in switch
    return greenlet.switch(self)
gevent.hub.LoopExit: ('This operation would block forever', <Hub at 0x7ff6dc8d8800 epoll default pending=0 ref=0 fileno=4 resolver=<gevent.resolver_thread.Resolver at 0x7ff6dc6828d0 pool=<ThreadPool at 0x7ff6dc682940 0/1/10>> threadpool=<ThreadPool at 0x7ff6dc682940 0/1/10>>)

Color option on most important results and status

It would be nice to have a --color option on most important results and status return.

-------- Scenario: 100 clients. --------

Target            		https://exemple.com:80/test_url  # THIS
Content-Type      		application/json; charset=utf-8
Method            		POST
Payload           		4
Concurrency       		100
Requests          		100
Insecure          		yes

Server Software: nginx
Running POST https://exemple.com:80/test_url
	...
	Content-Type: application/json; charset=utf-8
Running 100 queries - concurrency 100
[=================================================================>] 100% Done

-------- Results --------

Successful calls		100  # THIS
Total time        		8.7553 s  
Average           		4.6214 s  
Fastest           		0.6589 s  
Slowest           		8.5439 s  
Amplitude         		7.8850 s  
Standard deviation		2.315576
RPS               		11
BSI              		:(

-------- Status --------
Code 200          		100 times.  # THIS
Percentage of Success		100.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.