basho / basho_bench

A load-generation and testing tool for basically whatever you can write a returning Erlang function for.
Apache License 2.0
311 stars 197 forks source link

** Quick Start

You must have [[http://erlang.org/download.html][Erlang/OTP R16]] or later to build and run Basho Bench, and [[http://www.r-project.org/][R]] to generate graphs of your benchmarks. A sane GNU-style build system is also required if you want to use =make= to build the project.

+BEGIN_SRC shell

git clone git://github.com/basho/basho_bench.git cd basho_bench make all

+END_SRC

This will build an executable script, =basho_bench=, which you can use to run one of the existing benchmark configurations from the =examples/= directory. You will likely have to make some minor directory changes to the configs in order to get the examples running (see, e.g., the source of the bitcask and innostore benchmark config files for direction).

+BEGIN_SRC shell

$ ./basho_bench examples/riakc_pb.config INFO: Est. data size: 95.37 MB INFO: Using target ip {127,0,0,1} for worker 1 INFO: Starting max worker: <0.55.0>

+END_SRC

At the end of the benchmark, results will be available in CSV format in the =tests/current/= directory. Now you can generate a graph:

+BEGIN_SRC shell

$ make results priv/summary.r -i tests/current Loading required package: proto Loading required package: reshape Loading required package: plyr Loading required package: digest null device 1 $ open tests/current/summary.png

+END_SRC

** Troubleshooting Graph Generation

If make results fails with the error =/usr/bin/env: Rscript --vanilla: No such file or directory= please edit priv/summary.r and replace the first line with the full path to the Rscript binary on your system

If you receive the error message =Warning: unable to access index for repository http://lib.stat.cmu.edu/R/CRAN/src/contrib= it means the default R repo for installing additional packages is broken, you can change it as follows:

+BEGIN_SRC shell

$ R

chooseCRANmirror() Selection: 69 quit() make results

+END_SRC

** Customizing your Benchmark Basho Bench has many drivers, each with its own configuration, and a number of key and value generators that you can use to customize your benchmark. It is also straightforward -- with less than 200 lines of Erlang code -- to create custom drivers that can exercise other systems or perform custom operations. These are covered more in detail in the [[http://docs.basho.com/riak/latest/ops/building/benchmarking/][documentation]].

** Benchmarking with riak-java-client The [[https://github.com/basho/riak-java-client][riak-java-client]] can be used to benchmark a Riak cluster. There is an example configuration in =examples/riakc_java.config=. You will need the [[https://github.com/basho/bench_shim][bench_shim]] project. You will also need to uncomment and edit the following line in basho_bench's =rebar.config=, adding your own erlang cookie value:

+BEGIN_SRC shell

%% {escript_emu_args, "%%! -name bb@127.0.0.1 -setcookie YOUR_ERLANG_COOKIE\n"}.

+END_SRC

** Alternative Graph Generation by gnuplot You can generate graphs using gnuplot.

+BEGIN_SRC shell

$ ./priv/gp_throughput.sh

+END_SRC

+BEGIN_SRC shell

$ ./priv/gp_latencies.sh

+END_SRC

By passing =-h= option to each script, help messages are shown.

Some of options for these scripts are:

** Benchmarking Erlang cluster

A typical benchmark scenario is that Basho Bench spawn Erlang VM and executes the driver inside. However, there is needs to catch performance metrics from an application executed remotely within dedicated environment (e.g. probe performance from live system; benchmark an application inside C or Java node, etc). Bash Bench implements a generic =basho_bench_driver_cluster= that acts as proxy. It uses Erlang distribution to delegate benchmark responsibility to remote actor, which is randomly selected from configured pool.

Basho Bench do not define how the actors are spawned within SUT. It only defined a communication protocol. The actor is responsible to handle the message:

={pid(), atom(), key(), val()}=

+BEGIN_SRC shell

./basho_bench -C nocookie -N bb@127.0.0.1 -J erlang@127.0.0.1 examples/cluster.config

+END_SRC

** Contributing We encourage contributions to Basho Bench from the community.

1) Fork the =basho_bench= repository on [[https://github.com/basho/basho_bench][Github]].

2) Clone your fork or add the remote if you already have a clone of the repository.

  #+BEGIN_SRC shell
  git clone git@github.com:yourusername/basho_bench.git
  # or
  git remote add mine git@github.com:yourusername/basho_bench.git
  #+END_SRC

3) Create a topic branch for your change.

  #+BEGIN_SRC shell
  git checkout -b some-topic-branch
  #+END_SRC

4) Make your change and commit. Use a clear and descriptive commit message, spanning multiple lines if detailed explanation is needed.

5) Push to your fork of the repository and then send a pull-request through Github.

  #+BEGIN_SRC shell
  git push mine some-topic-branch
  #+END_SRC

6) A Basho engineer or community maintainer will review your patch and merge it into the main repository or send you feedback.