exp:expgraphqlbench
Available since Exponential 6.0.15 (in development, not in a release yet).
Summary
Measure the speed of the GraphQL API against decision 18: cached GET, 304, cached POST, a cached answer through the kernel and an uncached query, N requests each, with median, p95 and max
Usage
./console exp:expgraphqlbench [options] php bin/php/expgraphqlbench.php [options] ./console exp:graphql:bench [options]
Aliases
exp:graphql:bench
Help
The output of ./console help exp:expgraphqlbench (the script run with --help), without the standard options:
Notice: This script uses 'use-extensions' => false, meaning extension settings are not loaded!
Usage: bin/php/expgraphqlbench.php [OPTION]...
Measure the speed of the GraphQL API against decision 18
Sends the requests of each row one after the other to an end point, --requests times each
(after two that warm it up), --runs times, and prints the median, p95 and max of every row:
get a cached persisted query, GET ?id= (answered before the kernel starts)
304 the same with If-None-Match
post a cached persisted query, POST JSON {id} (answered before the kernel starts)
kernel a cached persisted query as a form POST, which starts the kernel (what the first
request of new credentials costs)
uncached the text of --query-file as an ad-hoc POST (never cached)
Every cached answer must come within 33 ms (the hard limit, on every request); the targets are
20 ms, then 13 ms, for the median and the p95. Uncached answers are measured, without a limit.
A time runs from the request being sent to the last byte of the answer (one connection for all,
so the TLS handshake is not in it). An OAuth token or a personal API key is read from the
environment variable GRAPHQL_BENCH_TOKEN (sent as Authorization: Bearer).
./console exp:graphql:bench --url=https://example.com/api/graphql --id=articles
./console exp:graphql:bench --url=https://example.com/api/graphql --id=articles \
--variables='{"limit":50}' --query-file=queries/articles.graphql --requests=200 --runs=3
./console exp:graphql:bench --url=http://127.0.0.1:8080/api/graphql --id=articles --rows=get,post --format=json
Exit code: 0 every cached row within the hard limit; 1 a cached row over it, or not answered from
the cache; 3 the end point does not answer; 2 wrong options.
Options:
--url=VALUE the end point, e.g. https://example.com/api/graphql
--id=VALUE the name or SHA-256 of the persisted query to measure
--variables=VALUE the variables of the query, as JSON
--query-file=VALUE a .graphql file with the text of the query, for the uncached row
--requests=VALUE requests per row and run (default 200)
--runs=VALUE how often every row runs (default 3)
--rows=VALUE the rows to run, comma separated: get,304,post,kernel,uncached (default all)
--siteaccess-header=VALUE send X-Siteaccess with this siteaccess
--insecure do not check the TLS certificate (a test server of your own)
--format=VALUE text (the default) or jsonOptions
| Option | Value | Description |
|---|---|---|
| --url | required | the end point, e.g. https://example.com/api/graphql |
| --id | required | the name or SHA-256 of the persisted query to measure |
| --variables | required | the variables of the query, as JSON |
| --query-file | required | a .graphql file with the text of the query, for the uncached row |
| --requests | required | requests per row and run (default 200) |
| --runs | required | how often every row runs (default 3) |
| --rows | required | the rows to run, comma separated: get,304,post,kernel,uncached (default all) |
| --siteaccess-header | required | send X-Siteaccess with this siteaccess |
| --insecure | - | do not check the TLS certificate (a test server of your own) |
| --format | required | text (the default) or json |
Standard options
Every script also takes the standard options of the script framework: --help, --quiet, --siteaccess, --debug, --colors, --no-colors, --logfiles, --no-logfiles, --verbose and --allow-root-user.
Source
bin/php/expgraphqlbench.php, kernel/private/classes/commands/expgraphqlbench.php
See also
Generated example: exp:expgraphqlbench
Added to the reference for Exponential 6.0.15.
Contributors
- Graham Brookins Updated
Comments
Add a comment