Multiple shiny sessions per one R session

Minimal reproducible example:


ui <- fluidPage(
  actionButton("button1", "Run 1"),
  actionButton("button2", "Run 2")

server <- function(session, input, output) {
  cat("session starts\n")
  observeEvent(input$button1, {
    cat("1 starts\n")
    cat("1 stops\n")

  observeEvent(input$button2, {
    cat("2 starts\n")
    cat("2 stops\n")

shinyApp(ui = ui, server = server)

Each button simulates running some long cpu-intensive algorithm.

  1. Run the app and open a session on one browser tab.
  2. Open another browser tab with another session for the running app.
  3. Start Run 1 in the first tab. Go to the second browser tab and start the Run 2.

The problem:
The second button observer does not start independently. It waits until the first run is finished in the first session. I thought that shiny sessions are independent. How does shiny handle multiple shiny sessions per single R session? What if multiple users want to connect to the application at the same time?

How does one handle multiple users running the same app at the same time?

On the open source version, Shiny sessions are independent in terms of their working environment accordingly with the scoping rules but not in terms of their resources, all app sessions run under the same R session sharing computational resources. There are some alternatives to overcome this problem like using docker containers by your own or with tools like shinyproxy

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.