knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(shinyloadtest)
shinycannon
requires custom installation that differs from platform to platform.
Depending on your distribution, shinycannon
can be installed using one of the following packages.
library(readr) library(magrittr) library(dplyr) library(knitr) # Release urls are updated in Rituals GHA shinycannon_files <- read_csv( "RELEASE_URLS.csv", comment = "#", col_types = list(.default = col_character()) ) %>% mutate(`Download Link` = sprintf("<a href='%s'>%s</a>", url, file)) package_types <- tribble( ~platform, ~Distribution, ~command_str, "deb", "Ubuntu/Debian", "<code>sudo dpkg -i %s</code>", "rpm_rh", "Redhat/Fedora/CentOS", "<code>sudo yum install -y %s</code>", "rpm_suse", "SUSE", "<code>zypper ----no-gpg-checks install -y %s</code>" ) linux_packages <- shinycannon_files %>% right_join(package_types, by = "platform") %>% mutate(`Install Command` = sprintf(command_str, file)) %>% select(`Distribution`, `Download Link`, `Install Command`) shinycannon_sh <- shinycannon_files %>% filter(platform == "sh") %>% unlist() shinycannon_jar <- shinycannon_files %>% filter(platform == "jar") %>% unlist()
kable(linux_packages)
r shinycannon_sh[["Download Link"]]
sudo cp
r shinycannon_sh[["file"]]/usr/local/bin/shinycannon; sudo chmod +x /usr/local/bin/shinycannon
shinycannon -h
to see help output, or shinycannon [RECORDING-PATH] [APP-URL]
to generate load.r shinycannon_jar[["Download Link"]]
to the directory you wish to run it injava -jar
r shinycannon_jar[["file"]]-h
to see help output, or java -jar
r shinycannon_jar[["file"]][RECORDING-PATH] [APP-URL]
to generate load.shinycannon
accepts two required positional arguments:
shinyloadtest::record_session
In addition to these two required arguments, shinycannon
accepts a number of optional arguments that can be specified with flags.
Of these, the most interesting are:
--workers
: The number of concurrent users to simulate. shinycannon
uses threads to represent each user. It defaults to 1.--loaded-duration-minutes
: The duration of the load test, in minutes. This does not include "warmup time", which is the time shinycannon spends gradually increasing the number of workers, or "cooldown time", which is the time spent decreasing the number of workers. It defaults to 0, meaning that after all workers have "warmed up", they will immediately begin to "cool down". Generally, you'll want to set this to a duration greater than 0. shinycannon
will re-run the recording as necessary to fill the time.--output-dir
: Name of the directory to create and store timing information in.As an example, to run a load test simulating 5 concurrent users for at least 2 minutes, outputting to the directory run1
:
$ shinycannon recording.log https://shinyapp.example.com/ --workers 5 --loaded-duration-minutes 2 --output-dir run1 2018-08-29 15:06:14.191 INFO [progress] - Running: 0, Failed: 0, Done: 0 2018-08-29 15:06:14.193 INFO [thread01] - Warming up 2018-08-29 15:06:14.195 INFO [thread00] - Waiting for warmup to complete 2018-08-29 15:06:19.193 INFO [progress] - Running: 1, Failed: 0, Done: 0 2018-08-29 15:06:24.194 INFO [progress] - Running: 1, Failed: 0, Done: 0 2018-08-29 15:06:29.083 INFO [thread02] - Warming up 2018-08-29 15:06:29.195 INFO [progress] - Running: 1, Failed: 0, Done: 0 2018-08-29 15:06:34.195 INFO [progress] - Running: 2, Failed: 0, Done: 0 2018-08-29 15:06:39.196 INFO [progress] - Running: 2, Failed: 0, Done: 0 2018-08-29 15:06:43.973 INFO [thread03] - Warming up 2018-08-29 15:06:44.196 INFO [progress] - Running: 2, Failed: 0, Done: 0 2018-08-29 15:06:49.196 INFO [progress] - Running: 3, Failed: 0, Done: 0 2018-08-29 15:06:54.201 INFO [progress] - Running: 3, Failed: 0, Done: 0 2018-08-29 15:06:58.862 INFO [thread04] - Warming up 2018-08-29 15:06:59.201 INFO [progress] - Running: 3, Failed: 0, Done: 0 2018-08-29 15:07:04.201 INFO [progress] - Running: 4, Failed: 0, Done: 0 2018-08-29 15:07:09.202 INFO [progress] - Running: 4, Failed: 0, Done: 0 2018-08-29 15:07:13.751 INFO [thread05] - Warming up 2018-08-29 15:07:13.752 INFO [thread00] - Maintaining for 2 minutes (120000 ms) 2018-08-29 15:07:14.202 INFO [progress] - Running: 4, Failed: 0, Done: 0 2018-08-29 15:07:19.202 INFO [progress] - Running: 5, Failed: 0, Done: 0 2018-08-29 15:07:24.202 INFO [progress] - Running: 5, Failed: 0, Done: 0 ...
shinycannon
includes detailed help documentation explaining the other arguments:
shinycannon -h
During the test, shinycannon
reports the progress and number of simulated users.
The result of the test is an output directory (run1
in the example above) which includes timing information for each session.
Inside that directory you'll find:
recording.log
: a copy of the original recording used.detail.log
: log output, to help debug errors../sessions/*.csv
: one file for each simulated user session.Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.