-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyab.1
More file actions
487 lines (482 loc) · 10.1 KB
/
yab.1
File metadata and controls
487 lines (482 loc) · 10.1 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
.TH yab 1 "5 September 2019"
.SH NAME
yab \- yet another benchmarker
.SH SYNOPSIS
\fByab\fP [<service> <method> <body>] [OPTIONS]
.SH 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.
.PP
yab includes a full man page (man yab), which is also available online: http://yarpc.github.io/yab/man.html
.PP
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:
.PP
.nf
.RS
[request]
.RE
.fi
.nf
.RS
timeout = 2s
.RE
.fi
.PP
.nf
.RS
[transport]
.RE
.fi
.nf
.RS
peer-list = "/path/to/peer/list.json"
.RE
.fi
.PP
.nf
.RS
[benchmark]
.RE
.fi
.nf
.RS
warmup = 10
.RE
.fi
.SH OPTIONS
.SS Application Options
.TP
\fB\fB\-v\fR\fP
Enable more detailed logging. Repeats increase the verbosity, ie. -vvv
.TP
\fB\fB\-\-version\fR\fP
Displays the application version
.SS Request Options
Configures the request data and the encoding.
.PP
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.
.PP
.nf
.RS
$ yab -p localhost:9787 kv -t kv.thrift -m KeyValue::Count -r '{}'
.RE
.fi
.PP
You can also use positional arguments to specify the method and body:
.PP
.nf
.RS
$ yab -p localhost:9787 -t kv.thrift kv KeyValue::Count '{}'
.RE
.fi
.PP
The TChannel health endpoint can be hit without specifying a Thrift file
by passing --health.
.PP
Thrift requests can be specified as JSON or YAML. For example, for a method
defined as:
.PP
.nf
.RS
void addUser(1: string name, 2: i32 age)
.RE
.fi
.PP
You can pass the request as JSON: {"name": "Prashant", age: 100}
or as YAML:
.PP
.nf
.RS
name: Prashant
.RE
.fi
.nf
.RS
age: 100
.RE
.fi
.PP
The request body can be specified on the command line using -r or --request:
.PP
.nf
.RS
$ yab -p localhost:9787 -t kv.thrift kv \\
.RE
.fi
.nf
.RS
KeyValue::Get -r '{"key": "hello"}'
.RE
.fi
.PP
Or it can be loaded from a file using -f or --file:
.PP
.nf
.RS
$ yab -p localhost:9787 -t kv.thrift kv KeyValue::Get --file req.yaml
.RE
.fi
.PP
To make a proto requrest, specify a compiled FileDescriptorSet and pass the
fully qualified service an method name as procedure.
.PP
.nf
.RS
$ yab -p localhost:5435 --file-descriptor-set-bin proto.bin \\
.RE
.fi
.nf
.RS
service package.Service/Method -r '{"key": "value"}'
.RE
.fi
.PP
A FileDescriptorSet can be generated using the --descriptor_set_out= flag
in protoc.
.PP
Request options can also be specified in a YAML file, e.g., get.yab:
.PP
.nf
.RS
service: kv
.RE
.fi
.nf
.RS
peer: localhost:9787
.RE
.fi
.nf
.RS
method: KeyValue::get
.RE
.fi
.nf
.RS
thrift: kv.thrift
.RE
.fi
.nf
.RS
request:
.RE
.fi
.nf
.RS
key: hello
.RE
.fi
.PP
The above YAML file represents the same request as the command above, and can
be run using yab -y get.yab.
.PP
You can make the request by directly executing the file (./get.yab) if you
add a shebang and mark the file as executable:
.PP
.nf
.RS
#!/usr/bin/env yab
.RE
.fi
.PP
.nf
.RS
service: kv
.RE
.fi
.nf
.RS
peer: localhost:9787
.RE
.fi
.nf
.RS
method: KeyValue::get
.RE
.fi
.nf
.RS
thrift: kv.thrift
.RE
.fi
.nf
.RS
request:
.RE
.fi
.nf
.RS
key: hello
.RE
.fi
.PP
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:
.PP
.nf
.RS
#!/usr/bin/env yab
.RE
.fi
.PP
.nf
.RS
service: kv
.RE
.fi
.nf
.RS
peer: localhost:9787
.RE
.fi
.nf
.RS
method: KeyValue::get
.RE
.fi
.nf
.RS
thrift: kv.thrift
.RE
.fi
.nf
.RS
request:
.RE
.fi
.nf
.RS
key: ${key:hello}
.RE
.fi
.PP
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:
.PP
.nf
.RS
$ ./get.yab -A key:world
.RE
.fi
.PP
A YAML template may have multiple keys and multiple keys can be specified on
the command line:
.PP
.nf
.RS
$ ./set.yab -A key:hello -A value:world
.RE
.fi
.PP
Binary data can be specified in one of many ways:
.IP \\[bu]
As a string or an array of bytes: "data" or [100, 97, 116, 97]
.IP \\[bu]
As base64: {"base64": "ZGF0YQ=="}
.IP \\[bu]
Loaded from a file: {"file": "data.bin"}
.PP
Examples:
.PP
.nf
.RS
$ yab -p localhost:9787 -t kv.thrift kv -m KeyValue::Set \\
.RE
.fi
.nf
.RS
-r '{"key": "hello", "value": [100, 97, 116, 97]}'
.RE
.fi
.PP
.nf
.RS
$ yab -p localhost:9787 -t kv.thrift kv KeyValue::Set \\
.RE
.fi
.nf
.RS
-r '{"key": "hello", "value": {"file": "data.bin"}}'
.RE
.fi
.TP
\fB\fB\-e\fR, \fB\-\-encoding\fR\fP
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
.TP
\fB\fB\-t\fR, \fB\-\-thrift\fR\fP
Path of the .thrift file
.TP
\fB\fB\-F\fR, \fB\-\-file-descriptor-set-bin\fR\fP
A binary file containing a compiled protobuf FileDescriptorSet.
.TP
\fB\fB\-\-procedure\fR\fP
The full method name to invoke (Thrift: Svc::Method, Proto: package.Service/Method).
.TP
\fB\fB\-m\fR, \fB\-\-method\fR\fP
Alias for procedure
.TP
\fB\fB\-r\fR, \fB\-\-request\fR\fP
The request body, in JSON or YAML format
.TP
\fB\fB\-f\fR, \fB\-\-file\fR\fP
Path of a file containing the request body in JSON or YAML
.TP
\fB\fB\-H\fR, \fB\-\-header\fR\fP
Individual application header as a key:value pair per flag
.TP
\fB\fB\-\-headers\fR\fP
The headers in JSON or YAML format
.TP
\fB\fB\-\-headers-file\fR\fP
Path of a file containing the headers in JSON or YAML
.TP
\fB\fB\-B\fR, \fB\-\-baggage\fR\fP
Individual context baggage header as a key:value pair per flag
.TP
\fB\fB\-\-health\fR\fP
Hit the health endpoint, Meta::health
.TP
\fB\fB\-\-timeout\fR\fP
The timeout for each request. E.g., 100ms, 0.5s, 1s. If no unit is specified, milliseconds are assumed.
.TP
\fB\fB\-y\fR, \fB\-\-yaml-template\fR\fP
Send a tchannel request specified by a YAML template
.TP
\fB\fB\-A\fR, \fB\-\-arg\fR\fP
A list of key-value template arguments, specified as -A foo:bar -A user:me
.TP
\fB\fB\-\-disable-thrift-envelope\fR\fP
Disables Thrift envelopes (disabled by default for TChannel and gRPC)
.TP
\fB\fB\-\-multiplexed-thrift\fR\fP
Enables the Thrift TMultiplexedProtocol used by services that host multiple Thrift services on a single endpoint.
.SS Transport Options
Configures the network transport used to make requests.
.PP
yab can target both TChannel and HTTP endpoints. To specify a TChannel endpoint,
specify the peer's host and port:
.PP
.nf
.RS
$ yab -p localhost:9787 [options]
.RE
.fi
.PP
or
.PP
.nf
.RS
$ yab -p tchannel://localhost:9787 [options]
.RE
.fi
.PP
For HTTP endpoints, specify the URL as the peer,
.PP
.nf
.RS
$ yab -p http://localhost:8080/thrift [options]
.RE
.fi
.PP
The Thrift-encoded body will be POSTed to the specified URL.
.PP
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.
.PP
.nf
.RS
$ yab --peer-list hosts.json [options]
.RE
.fi
.TP
\fB\fB\-s\fR, \fB\-\-service\fR\fP
The TChannel/Hyperbahn service name
.TP
\fB\fB\-p\fR, \fB\-\-peer\fR\fP
The host:port of the service to call
.TP
\fB\fB\-P\fR, \fB\-\-peer-list\fR\fP
Path or URL of a JSON, YAML, or flat file containing a list of host:ports. -P? for supported protocols.
.TP
\fB\fB\-\-caller\fR\fP
Caller will override the default caller name (which is yab-$USER).
.TP
\fB\fB\-\-rk\fR\fP
The routing key overrides the service name traffic group for proxies.
.TP
\fB\fB\-\-rd\fR\fP
The routing delegate overrides the routing key traffic group for proxies.
.TP
\fB\fB\-\-sk\fR\fP
The shard key is a transport header that clues where to send a request within a clustered traffic group.
.TP
\fB\fB\-\-jaeger\fR\fP
Use the Jaeger tracing client to send Uber style traces and baggage headers
.TP
\fB\fB\-T\fR, \fB\-\-topt\fR\fP
Transport options for TChannel, protocol headers for HTTP
.TP
\fB\fB\-\-http-method\fR\fP
The HTTP method to use
.SS Benchmark Options
Configures benchmarking, which is disabled by default.
.PP
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.
.PP
yab will make requests until either the maximum requests (-n or --max-requests)
or the maximum duration is reached.
.PP
You can control the rate at which yab makes requests using the --rps flag.
.PP
An example benchmark command might be:
.PP
.nf
.RS
$ yab -p localhost:9787 moe --health -n 100000 -d 10s --rps 1000
.RE
.fi
.PP
This would make requests at 1000 RPS until either the maximum number of
requests (100,000) or the maximum duration (10 seconds) is reached.
.PP
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.
.TP
\fB\fB\-n\fR, \fB\-\-max-requests\fR <default: \fI"0"\fR>\fP
The maximum number of requests to make. 0 implies no limit.
.TP
\fB\fB\-d\fR, \fB\-\-max-duration\fR <default: \fI"0s"\fR>\fP
The maximum amount of time to run the benchmark for. 0 implies no duration limit.
.TP
\fB\fB\-\-cpus\fR\fP
The number of OS threads
.TP
\fB\fB\-\-connections\fR\fP
The number of TCP connections to use
.TP
\fB\fB\-\-warmup\fR <default: \fI"10"\fR>\fP
The number of requests to make to warmup each connection
.TP
\fB\fB\-\-concurrency\fR <default: \fI"1"\fR>\fP
The number of concurrent calls per connection
.TP
\fB\fB\-\-rps\fR <default: \fI"0"\fR>\fP
Limit on the number of requests per second. The default (0) is no limit.
.TP
\fB\fB\-\-statsd\fR\fP
Optional host:port of a StatsD server to report metrics
.TP
\fB\fB\-\-per-peer-stats\fR\fP
Whether to emit stats by peer rather than aggregated
.SS Help Options
.TP
\fB\fB\-h\fR, \fB\-\-help\fR\fP
Show this help message