exp:expgraphqlbench
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.
Script bin/php/expgraphqlbench.php, code in kernel/private/classes/commands/expgraphqlbench.php. Run it from the installation root, as the user the web server runs as:
./console exp:expgraphqlbench --help
./console exp:graphql:bench --help
php bin/php/expgraphqlbench.php --helpHelp text
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 variableOptions
| Option | Value | Help |
|---|---|---|
--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 |
Read from the option definitions in the code (startup(), getOptions(), options() or ezcConsoleOption). Every script also takes the standard options of the script framework (--help, --siteaccess, --debug, --quiet, --allow-root-user ...).
Related
Generated by ./console exp:help:examples from bin/php/expgraphqlbench.php, kernel/private/classes/commands/expgraphqlbench.php. Do not edit this page: change the source and generate again (how). Free documentation: GFDL 1.3 or later.