-
Notifications
You must be signed in to change notification settings - Fork 35
/
doc.go
185 lines (131 loc) · 6.2 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// Copyright (c) 2016 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// 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.
//
// For usage information, check out the man page:
// http://yarpc.github.io/yab/man.html
package main
const _reqOptsDesc = `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"}}'
`
const _transportOptsDesc = `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]
`
const _benchmarkOptsDesc = `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.
`
/* vim: set tabstop=8:softtabstop=8:shiftwidth=8:noexpandtab */