Movatterモバイル変換


[0]ホーム

URL:


Load Testing ShinyApplications

R-CMD-check

Theshinyloadtestpackage and the accompanyingshinycannoncommand line tool make it possible toload testdeployed Shiny apps. Load testing helps developers and administratorsestimate how many users their application can support. If an applicationrequires tuning, load testing and load test result analysis can be usedto identify performance bottlenecks and to guide changes toinfrastructure, configuration, or code.

Scientific load testing helps put to rest the common misconceptionthat “Shiny doesn’t scale”. As rstudio::conf(2018) Sean Lopp presentedonScalingShiny which shows how to to horizontally scale an app to handle tensof thousands of users.

Installation

To perform a load test you’ll need two pieces of software:

Quick Start

The process for load testing a Shiny application consists of threesteps:

  1. Record a typical user session for the app.
  2. Replay the session in parallel, simulating manysimultaneous users accessing the app.
  3. Analyze the results of the load test and determineif the app performed well enough.

Rinse and repeat as necessary. Each step is described below.

Step 1: Recording

Record a session usingshinyloadtest::record_session(),which takes the URL of thedeployed application as anargument:

shinyloadtest::record_session("https://shinyapp.example.com/")

Running the function will open a browser displaying the app. Onceopen, interact with the application as a typical user might then closethe browser. After closing the app, a file (recording.logby default) will be created that contains a recording of the session.This recording will serve as the basis for the load test.

If your application requires authentication, consult theauthenticationarticle. Also be aware thatcertainShiny features are not compatible with shinyloadtest.

Step 2: Run the Load Test

With the recording in hand, we’re ready to run the load test. Theactual test is conducted outside of R using theshinycannoncommand-line tool. You can run it using your system’s terminal orconsole program, or you can run it from the RStudio IDE’s terminal tab.A typical run looks like 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.)

Seetheshinycannon article for details.

Step 3: Analyze the Results

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 test logs.

Analysis Example

[8]ページ先頭

©2009-2025 Movatter.jp