yab

NAME
SYNOPSIS
DESCRIPTION
OPTIONS

NAME

yab − yet another benchmarker

SYNOPSIS

yab [<service> <method> <body>] [OPTIONS]

DESCRIPTION

yab is a benchmarking tool for TChannel and HTTP applications. It’s primarily intended for Thrift applications but supports other encodings like JSON and binary (raw). It can be used in a curl-like fashion when benchmarking features are disabled.

yab includes a full man page (man yab), which is also available online: http://yarpc.github.io/yab/man.html

Default options can be specified in a ~/.config/yab/defaults.ini file (or ~/Library/Preferences/yab/defaults.ini on Mac) with contents similar to this:

[request]
timeout = 2s

[transport]
peer-list = "/path/to/peer/list.json"

[benchmark]
warmup = 10

OPTIONS

Application Options

−v

Enable more detailed logging. Repeats increase the verbosity, ie. -vvv

−−version

Displays the application version

Request Options
Configures the request data and the encoding.

To make Thrift requests, specify a Thrift file and pass the Thrift service and procedure to the method argument (-m or --method) as Service::Method.

$ yab -p localhost:9787 kv -t kv.thrift -m KeyValue::Count -r ’{}’

You can also use positional arguments to specify the method and body:

$ yab -p localhost:9787 -t kv.thrift kv KeyValue::Count ’{}’

The TChannel health endpoint can be hit without specifying a Thrift file by passing --health.

Thrift requests can be specified as JSON or YAML. For example, for a method defined as:

void addUser(1: string name, 2: i32 age)

You can pass the request as JSON: {"name": "Prashant", age: 100} or as YAML:

name: Prashant
age: 100

The request body can be specified on the command line using -r or --request:

$ yab -p localhost:9787 -t kv.thrift kv \
KeyValue::Get -r ’{"key": "hello"}’

Or it can be loaded from a file using -f or --file:

$ yab -p localhost:9787 -t kv.thrift kv KeyValue::Get --file req.yaml

To make a proto requrest, specify a compiled FileDescriptorSet and pass the fully qualified service an method name as procedure.

$ yab -p localhost:5435 --file-descriptor-set-bin proto.bin \
service package.Service/Method -r ’{"key": "value"}’

A FileDescriptorSet can be generated using the --descriptor_set_out= flag in protoc.

Request options can also be specified in a YAML file, e.g., get.yab:

service: kv
peer: localhost:9787
method: KeyValue::get
thrift: kv.thrift
request:
key: hello

The above YAML file represents the same request as the command above, and can be run using yab -y get.yab.

You can make the request by directly executing the file (./get.yab) if you add a shebang and mark the file as executable:

#!/usr/bin/env yab

service: kv
peer: localhost:9787
method: KeyValue::get
thrift: kv.thrift
request:
key: hello

YAML templates can use arguments using ${ARGNAME:default_value} in the body, which can be specified on the command line using -A. If an argument is not specified on the command line, then the default value is used. For example, we can update the YAML template to take an argument for the key:

#!/usr/bin/env yab

service: kv
peer: localhost:9787
method: KeyValue::get
thrift: kv.thrift
request:
key: ${key:hello}

If no key is specified on the command line, the default value of "hello" is used as the key. However we can specify the key on the command line:

$ ./get.yab -A key:world

A YAML template may have multiple keys and multiple keys can be specified on the command line:

$ ./set.yab -A key:hello -A value:world

Binary data can be specified in one of many ways:

As a string or an array of bytes: "data" or [100, 97, 116, 97]

As base64: {"base64": "ZGF0YQ=="}

Loaded from a file: {"file": "data.bin"}

Examples:

$ yab -p localhost:9787 -t kv.thrift kv -m KeyValue::Set \
-r ’{"key": "hello", "value": [100, 97, 116, 97]}’

$ yab -p localhost:9787 -t kv.thrift kv KeyValue::Set \
-r ’{"key": "hello", "value": {"file": "data.bin"}}’

−e, −−encoding

The encoding of the data, options are: Thrift, proto, JSON, raw. Defaults to Thrift if the method contains ’::’ or a Thrift file is specified. Defaults to proto if the method contains ’/’ or a proto filedescriptorset is specified

−t, −−thrift

Path of the .thrift file

−F, −−file-descriptor-set-bin

A binary file containing a compiled protobuf FileDescriptorSet.

−−procedure

The full method name to invoke (Thrift: Svc::Method, Proto: package.Service/Method).

−m, −−method

Alias for procedure

−r, −−request

The request body, in JSON or YAML format

−f, −−file

Path of a file containing the request body in JSON or YAML

−H, −−header

Individual application header as a key:value pair per flag

−−headers

The headers in JSON or YAML format

−−headers-file

Path of a file containing the headers in JSON or YAML

−B, −−baggage

Individual context baggage header as a key:value pair per flag

−−health

Hit the health endpoint, Meta::health

−−timeout

The timeout for each request. E.g., 100ms, 0.5s, 1s. If no unit is specified, milliseconds are assumed.

−y, −−yaml-template

Send a tchannel request specified by a YAML template

−A, −−arg

A list of key-value template arguments, specified as -A foo:bar -A user:me

−−disable-thrift-envelope

Disables Thrift envelopes (disabled by default for TChannel and gRPC)

−−multiplexed-thrift

Enables the Thrift TMultiplexedProtocol used by services that host multiple Thrift services on a single endpoint.

Transport Options
Configures the network transport used to make requests.

yab can target both TChannel and HTTP endpoints. To specify a TChannel endpoint, specify the peer’s host and port:

$ yab -p localhost:9787 [options]

or

$ yab -p tchannel://localhost:9787 [options]

For HTTP endpoints, specify the URL as the peer,

$ yab -p http://localhost:8080/thrift [options]

The Thrift-encoded body will be POSTed to the specified URL.

Multiple peers can be specified using a peer list using -P or --peer-list. When making a single request, a single peer from this list is selected randomly. When benchmarking, connections will be established in a round-robin fashion, starting with a random peer.

$ yab --peer-list hosts.json [options]

−s, −−service

The TChannel/Hyperbahn service name

−p, −−peer

The host:port of the service to call

−P, −−peer-list

Path or URL of a JSON, YAML, or flat file containing a list of host:ports. -P? for supported protocols.

−−caller

Caller will override the default caller name (which is yab-$USER).

−−rk

The routing key overrides the service name traffic group for proxies.

−−rd

The routing delegate overrides the routing key traffic group for proxies.

−−sk

The shard key is a transport header that clues where to send a request within a clustered traffic group.

−−jaeger

Use the Jaeger tracing client to send Uber style traces and baggage headers

−T, −−topt

Transport options for TChannel, protocol headers for HTTP

−−http-method

The HTTP method to use

Benchmark Options
Configures benchmarking, which is disabled by default.

By default, yab will only make a single request. To enable benchmarking, specify the maximum duration for the benchmark by passing -d or --max-duration.

yab will make requests until either the maximum requests (-n or --max-requests) or the maximum duration is reached.

You can control the rate at which yab makes requests using the --rps flag.

An example benchmark command might be:

$ yab -p localhost:9787 moe --health -n 100000 -d 10s --rps 1000

This would make requests at 1000 RPS until either the maximum number of requests (100,000) or the maximum duration (10 seconds) is reached.

By default, yab will create multiple connections (defaulting to the number of CPUs on the machine), but will only have one concurrent call per connection. The number of connections and concurrent calls per connection can be controlled using --connections and --concurrency.
−n
, −−max-requests <default: "0">

The maximum number of requests to make. 0 implies no limit.

−d, −−max-duration <default: "0s">

The maximum amount of time to run the benchmark for. 0 implies no duration limit.

−−cpus

The number of OS threads

−−connections

The number of TCP connections to use

−−warmup <default: "10">

The number of requests to make to warmup each connection

−−concurrency <default: "1">

The number of concurrent calls per connection

−−rps <default: "0">

Limit on the number of requests per second. The default (0) is no limit.

−−statsd

Optional host:port of a StatsD server to report metrics

−−per-peer-stats

Whether to emit stats by peer rather than aggregated

Help Options
−h
, −−help

Show this help message