- Notifications
You must be signed in to change notification settings - Fork21
Tools for load testing Shiny applications
rstudio/shinyloadtest
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Theshinyloadtest packageand the accompanyingshinycannon command linetool make it possible toload test deployed Shiny apps. Load testinghelps developers and administrators estimate how many users theirapplication can support. If an application requires tuning, load testingand load test result analysis can be used to identify performancebottlenecks and to guide changes to infrastructure, configuration, orcode.
Scientific load testing helps put to rest the common misconception that“Shiny doesn’t scale”. As rstudio::conf(2018) Sean Lopp presented onScaling Shiny whichshows how to to horizontally scale an app to handle tens of thousands ofusers.
To perform a load test you’ll need two pieces of software:
shinyloadtestis an R package used to generate recordings andanalyze results. You should install it on your development machinewithinstall.packages("shinyloadtest").shinycannonis a command-line used to replay recordings in parallel.You can install it on your development machine for testing, but forbest results we recommend installing it on a server, and preferablynot the one the application under test is also on. Seeinstallationinstructionsfor operating specific install instructions..
The process for load testing a Shiny application consists of threesteps:
- Record a typical user session for the app.
- Replay the session in parallel, simulating many simultaneoususers accessing the app.
- Analyze the results of the load test and determine if the appperformed well enough.
Rinse and repeat as necessary. Each step is described below.
Record a session usingshinyloadtest::record_session(), which takesthe URL of thedeployed application as an argument:
shinyloadtest::record_session("https://shinyapp.example.com/")
Running the function will open a browser displaying the app. Once open,interact with the application as a typical user might then close thebrowser. After closing the app, a file (recording.log by default) willbe created that contains a recording of the session. This recording willserve as the basis for the load test.
If your application requires authentication, consult theauthenticationarticle.Also be aware thatcertain Shinyfeaturesare not compatible with shinyloadtest.
With the recording in hand, we’re ready to run the load test. The actualtest is conducted outside of R using theshinycannon command-linetool. You can run it using your system’s terminal or console program, oryou can run it from the RStudio IDE’s terminal tab. A typical run lookslike this:
shinycannon recording.log https://shinyapp.example.com/ --workers 5 --loaded-duration-minutes 2 --output-dir run1(On Windows, you will need to replace “shinycannon” withjava -jar shinycannon-VERSION.jar.)
Seethe shinycannonarticlefor details.
Now we can analyse our results by reading the data intoshinyloadtest::load_runs() and create a report withshinyloadtest_report():
df<-shinyloadtest::load_runs("run1")shinyloadtest::shinyloadtest_report(df,"run1.html")
This self contained html report will be opened in your browser forinspection. For further analysis explanation, please visitAnalysingload testlogs.
Analysis ExampleAbout
Tools for load testing Shiny applications
Resources
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors12
Uh oh!
There was an error while loading.Please reload this page.
