Time what a viewer of a QWC2 webmap waits for, from outside the server: the
configuration files and viewer bundle, the first complete render of each map
theme in headless Chrome (cold and warm), a WMS GetMap at fixed views, and a
GetFeatureInfo at a fixed point. Each measurement is repeated n times and
reported as a median and 90th percentile, so runs with the same inputs can be
compared over time. Budgets for what counts as too slow belong to each
deployment, not to rfp.
Usage
rfp_qwc_probe(
url,
theme = NULL,
map_themes = NULL,
layers = NULL,
views,
point = NULL,
query_layers = NULL,
gfi_allow_empty = FALSE,
n = 5,
size = c(800, 600),
dpr = 1,
background = FALSE,
render = TRUE,
idle = 1,
timeout = 120
)Arguments
- url
Character. The webmap's address, e.g.
"https://qgis.a11s.one/".- theme
Character. The QWC2 theme id (the
tURL parameter).NULLtakesthemes.json'sdefaultTheme, or the only theme.- map_themes
Character. Map themes (visibility presets) to render and GetMap.
NULLtakes every preset the theme carries, or the theme's default layer visibility when it carries none. Ignored whenlayersis given.- layers
Character. Explicit WMS layer names to measure instead of map themes; reported with
target = "layers".- views
Data frame with columns
name,x,y(map CRS) andscale, one row per view.- point
Data frame with one row and columns
x,yandscale, the GetFeatureInfo location.NULLskips GetFeatureInfo.- query_layers
Character. Layers to query at
point; each must be queryable inthemes.json.- gfi_allow_empty
Logical. Accept a GetFeatureInfo answer with zero features. Default
FALSE, because a query that hits nothing is usually a mistake inpoint.- n
Integer. Timed repetitions per measurement. Default 5.
- size
Integer vector of length 2. Viewport width and height in CSS pixels, also the GetMap size at
dpr = 1.- dpr
Numeric. Device pixel ratio for the browser. The GetMap size is
size * dpr, and its DPI is 96 at a ratio of 1 and90 * dprotherwise, as the viewer sends.- background
Logical. Load the viewer's background layer. Default
FALSE(bl=), so a third party's tile server is not in the measure.- render
Logical. Run the headless-browser render rows. Needs the chromote package and Chrome.
- idle
Numeric. Seconds with no request open on the map's origin after which a load counts as finished.
- timeout
Numeric, at least 1. Seconds before a request or a load is abandoned and reported as an error.
What is measured
Each row is one measurement, keyed by kind, target, view, scale and
cache:
configindex.html,config.json,themes.jsonand every scriptindex.htmlloads (the viewer bundle is usually the largest download). A VM-sidemapViewerConfig.jsonis not served, so it cannot be measured from outside.renderTime from the viewer's document request to the last successful image GetMap on the theme's WMS path, with none still open, read from the browser's own network events. A canceled GetMap does not count.
coldis a fresh browser session with its cache cleared;warmis the same navigation again in that session. QWC2 refetchesthemes.jsonand every GetMap on a warm load, so warm still waits for the WMS.render_idleTime to the end of the last request to the map's own origin, in the same loads. Requests to other hosts, such as a third party's tiles, are excluded.
getmapThe GetMap the viewer would send at that view, sent directly: same layers, order, styles, opacities, size, DPI and format.
getfeatureinfoA GetFeatureInfo to the theme's
featureInfoUrl(what the viewer waits for) at the centre ofpoint.
Columns: median_s, p90_s and ttfb_median_s (time to first byte) in
seconds; bytes as wire bytes (what crosses the network) and
bytes_decoded beside it; features for GetFeatureInfo; layers (the WMS
layers, comma-separated) and request_hash so two runs can be checked for
asking the same thing; server_timing (a Server-Timing header, where the
server sends one); and times, every repetition. The call's time (UTC),
rfp version and arguments are attributes of the result.
Each config, GetMap and GetFeatureInfo target gets one unrecorded warm-up request before its timed repetitions, so a server's first-request cost (QGIS Server loading the project) does not sit in the median. Render repetitions run after the direct requests for the same reason.
The 90th percentile is stats::quantile(type = 7). At small n it is mostly
the slowest repetition: at n = 3 it sits 80% of the way from the second to
the third value.
Map themes and views
A QWC2 theme (theme, the viewer's t) carries QGIS map themes as
visibilityPresets. QWC2 has no URL parameter that selects one, so a render
loads the theme with the preset's layers in l=, which reproduces it. A
layer draws when its preset key and every ancestor group's key are present.
A view is a centre and a scale. The viewer snaps a scale to the theme's scales without saying so, so a scale that is not one of them is refused.
Every WMS answer is checked rather than trusted: QGIS Server answers a GetMap
for an unknown layer with HTTP 200 and an XML ServiceException, and the
featureInfoUrl answers an unknown or non-queryable layer with HTTP 200 and
an empty response. Both are errors here, as is a render that never finishes
by timeout. Each GetMap the browser sends is held to the direct GetMap for
the same view (layers and their order, styles, size, DPI, CRS and extent),
so the render and getmap rows always time the same map; the size and DPI
follow config.json's wmsHidpi and wmsDpi, as the viewer's do.
Requests start from wherever url redirects to, so a viewer and the probe
land on the same address. Each render repetition runs in a Chrome process of
its own, so a cold load pays connection setup as a first visit does.
See also
Other qgs:
rfp_qgs_form_add(),
rfp_qgs_layer_rm(),
rfp_qgs_postgres_add(),
rfp_qgs_preview_set(),
rfp_qgs_raster_add(),
rfp_qgs_service_add(),
rfp_qgs_service_rm(),
rfp_qgs_services(),
rfp_qgs_style_export(),
rfp_qgs_style_set(),
rfp_qgs_subset_get(),
rfp_qgs_subset_set(),
rfp_qgs_theme_add(),
rfp_qgs_theme_lookup(),
rfp_qgs_theme_names(),
rfp_qgs_theme_rename(),
rfp_qgs_theme_rm(),
rfp_qgs_theme_set(),
rfp_qgs_theme_unbury(),
rfp_qgs_themes(),
rfp_qgs_vector_add(),
rfp_qwc_config_create(),
rfp_raster_style_path(),
rfp_raster_styles()
Examples
if (FALSE) { # \dontrun{
# Needs a live QWC2 server, and Chrome for the render rows.
res <- rfp_qwc_probe(
"https://qgis.a11s.one/",
views = data.frame(name = c("reach", "site"),
x = c(970000, 969000), y = c(1050000, 1050500),
scale = c(20000, 4000)),
point = data.frame(x = 974137, y = 1052142, scale = 20000),
query_layers = "floodplain \u2014 co_ff04",
n = 3
)
res[, c("kind", "target", "view", "cache", "median_s", "p90_s", "bytes")]
} # }
