# Benchmarks

The Aerospike C client benchmark source code [repository](https://github.com/aerospike/aerospike-benchmark) allows you to:

-   Read and write data into the database at a particular read/write ratio.
-   Change the number of client threads to simulate client concurrency.
-   Examine latency distribution from the client side.

## Linux/macOS

### Build

To build the benchmark tool on Linux/macOS, install the following dependencies:

-   [Aerospike C client and its dependencies](https://github.com/aerospike/aerospike-client-c)
-   OpenSSL libssl and OpenSSL libcrypto (ie: apt-get install libssl-dev)
-   libyaml-devel (ie: apt-get install libyaml-dev)
-   libev, libuv, or libevent (if an event library is used)

The [Aerospike Benchmark](https://github.com/aerospike/aerospike-benchmark) project uses git submodules, so you will need to initialize and update submodules before building this project.

Terminal window

```bash
$ git submodule update --init
```

Set the environment variable `CLIENTREPO` to point to the directory containing the built C client.

Terminal window

```bash
export CLIENTREPO=<Path to your C Client built>
```

and run the `make` command.

Example:

Terminal window

```bash
$ git clone https://github.com/aerospike/aerospike-client-c.git

$ cd aerospike-client-c

$ git submodule update --init

$ make

$ export CLIENTREPO=$(pwd)

$ cd ..

$ git clone https://github.com/aerospike/aerospike-benchmark

$ cd aerospike-benchmark/

$ git submodule update --init

$ make
```

### Start the Benchmark Tool

Start the benchmark tool:

Terminal window

```bash
$ make run
```

This places a default workload on the localhost cluster:

Terminal window

```bash
$ ./target/benchmark -h 127.0.0.1 -p 3000

hosts:                  127.0.0.1

port:                   3000

user:                   (null)

services-alternate:     false

namespace:              test

set:                    testset

start-key:              1

keys/records:           1000000

object spec:            I4

- duration: 10

  desc: default config (specify your own with --workload-stages)

  tps: 0

  key-start: 1

  key-end: 1000001

  pause: 0

  batch-size: 1

  async: false

  random: false

  workload: RU,50%

  stage: 1

  object-spec: I4

  read-bins: (null)

  write-bins: (null)

threads:                16

enable compression:     false

compression ratio:      1.000000

read socket timeout:    30000 ms

write socket timeout:   30000 ms

read total timeout:     1000 ms

write total timeout:    1000 ms

max retries:            1

debug:                  false

latency:                false

latency histogram:      false

cumulative HDR hist:    false

shared memory:          false

read replica:           sequence

read mode AP:           one

read mode SC:           session

write commit level:     all

conn pools per node:    1

async max commands:     50

event loops:            1

auth mode:              INTERNAL

2021-09-07 22:49:51.165 INFO Add node BB9020011AC4202 127.0.0.1:3000

2021-09-07 22:49:51.167 INFO Start 16 transaction threads

Stage 1: default config (specify your own with --workload-stages)

2021-09-07 22:49:52.168 INFO write(tps=6500 timeouts=0 errors=0) read(tps=6450 timeouts=0 errors=0) total(tps=12950 timeouts=0 errors=0)

2021-09-07 22:49:53.168 INFO write(tps=6687 timeouts=0 errors=0) read(tps=6686 timeouts=0 errors=0) total(tps=13373 timeouts=0 errors=0)

2021-09-07 22:49:54.168 INFO write(tps=6637 timeouts=0 errors=0) read(tps=6716 timeouts=0 errors=0) total(tps=13353 timeouts=0 errors=0)

2021-09-07 22:49:55.171 INFO write(tps=6011 timeouts=0 errors=0) read(tps=6078 timeouts=0 errors=0) total(tps=12089 timeouts=0 errors=0)

2021-09-07 22:49:56.170 INFO write(tps=6644 timeouts=0 errors=0) read(tps=6559 timeouts=0 errors=0) total(tps=13203 timeouts=0 errors=0)

2021-09-07 22:49:57.170 INFO write(tps=6533 timeouts=0 errors=0) read(tps=6468 timeouts=0 errors=0) total(tps=13001 timeouts=0 errors=0)

2021-09-07 22:49:58.169 INFO write(tps=6512 timeouts=0 errors=0) read(tps=6436 timeouts=0 errors=0) total(tps=12948 timeouts=0 errors=0)

2021-09-07 22:49:59.169 INFO write(tps=6616 timeouts=0 errors=0) read(tps=6632 timeouts=0 errors=0) total(tps=13248 timeouts=0 errors=0)
```

In this example:

-   The number of keys randomly read/updated are 1000000.
-   50% of the requests are reads; 50% of requests are writes.

Call the following for details on the attributes of the benchmark tool:

Terminal window

```bash
$ ./target/benchmark --help
```

### Benchmark Examples

#### Example 1

This example:

-   Connects to 127.0.0.1:3000 using the namespace _test_.
-   Uses 100 million keys (integer key value in the range 1 to 100000000) and 50 character string values as the bin value in _testbin_.
-   Reads 90% and writes 10% of the time using 20 concurrent threads.

Terminal window

```bash
$ ./target/benchmark -h 127.0.0.1 -p 3000 -n test -k 100000000 -o S50 -w RU,90 -z 20
```

#### Example 2

This example:

-   Connects to 127.0.0.1:3000 using the namespace _test_ in set _demoset_.
-   Uses 1 million keys and 1400 character string values.
-   Reads 80% and writes 20% of the time using 8 concurrent threads.
-   Restricts transactions per second to 2500.
-   Times out reads and writes after 50ms.
-   Shows client-side latency percentages in the <=1ms, >1ms, >8ms, >64ms buckets.

Terminal window

```bash
$ ./target/benchmark -h 127.0.0.1 -p 3000 -n test -s demoset -k 1000000 -o S1400 -g 2500 -w RU,80 -z 8 -L 4,3
```