Does R-Server or Shiny Server Create a New R Process/Instance for Each User

Does R-Server or Shiny Server create a new R process/instance for each user?

Great questions. (Bias: I'm one of the developers behind Shiny Server.)

Regarding your second question, in the open source Shiny Server, one R process is created for every Shiny application you deploy, regardless of the number of concurrent users. We now offer Shiny Server Professional which offers, among other things, the ability to support an application with multiple R processes and configure exactly how you want this to scale.

Regarding your first question, Shiny Server certainly can do these things, but you'll find that the limitation is in your Shiny apps. We've seen the simplest apps seamlessly support hundreds of concurrent users on a single Shiny process (doable in the open source version). Most apps of substance, however, would require more processes to create a seamless experience once you get into hundreds or thousands of concurrent users. With Shiny Server Pro, you'll be able to scale that as far as your server's resources allow you to.

handling multiple users simulaneously in an R Shiny app

I think you're mistaken. Shiny, by default, creates one process per Shiny app, but can facilitate an unlimited number of sessions (i.e. "user connections") in a single app/process.

Checkout this chapter of the tutorial for more info on scoping: http://rstudio.github.io/shiny/tutorial/#scoping

Basically, anything defined inside of the shinyServer() expression is going to be private to a single user's session. Any variables you put outside of shinySever will be globally shared between all users. So you can just keep your variables (e.g. a counter of clicks) inside of shinyServer() if you don't want them to be shared across sessions.

How to create different dashboards for different users of a Shiny app? (on the same app code)

login1 <- c("user1", "pw1")
login2 <- c("user2", "pw2")

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

# Application title
uiOutput("ui")

# Sidebar with a slider input for number of bins
)

# Define server logic required to draw a histogram
server <- function(input, output) {

logged <- reactiveValues(logged = FALSE, user = NULL)

observeEvent(input$signin, {
if(input$name == "user1" & input$pw == "pw1") {
logged$logged <- TRUE
logged$user <- "user1"
} else if (input$name == "user2" & input$pw == "pw2") {
logged$logged <- TRUE
logged$user <- "user2"
} else {}
})

output$ui <- renderUI({

if(logged$logged == FALSE) {
return(
tagList(
textInput("name", "Name"),
passwordInput("pw", "Password"),
actionButton("signin", "Sign In")
)
)
} else if(logged$logged == TRUE & logged$user == "user1") {
return(
tagList(
titlePanel("This is user 1 Panel"),
tags$h1("User 1 is only able to see text, but no plots")
)
)
} else if(logged$logged == TRUE & logged$user == "user2") {
return(
tagList(
titlePanel("This is user 2 Panel for Executetives"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),

# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
)
)
} else {}
})

output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}

# Run the application
shinyApp(ui = ui, server = server)

This is a SIMPLE way to make it work. You get reactiveValues passed as conditional inputs to the renderUI function.

However, this is a very dangerous solution, since passwords and users are not encrypted. For professional deployment with R Shiny, think about Shiny-Server or my personal favorite ShinyProxy (https://www.shinyproxy.io/)

Understanding the scalability of RShiny apps hosted on ShinyServer

Canovice,

I'd recommend you take a look at the following RStudio / AWS support articles. To scale a shiny server you'll need to look at using a load balancer:

  • RStudio

    • https://shiny.rstudio.com/articles/scaling-and-tuning.html
    • https://support.rstudio.com/hc/en-us/articles/220546267-Scaling-and-Performance-Tuning-Applications-in-Shiny-Server-Pro
    • https://support.rstudio.com/hc/en-us/articles/217801438-Can-I-load-balance-across-multiple-nodes-running-Shiny-Server-Pro-
  • AWS

    • https://aws.amazon.com/blogs/big-data/running-r-on-aws/
  • Blog Article:

    • http://mgritts.github.io/2016/07/08/shiny-aws/

Shiny is a great platform, their support is fabulous. I'd recommend you ring them up - they'll be sure to help answer your questions.

That said if your plan is to create a scalable website that will support thousands or hundreds of thousands of people then my sense would be to recommend you also review and consider using D3.js in conjunction with react.js or Angular.js, not forgetting to mention node.js.

My sense is that you are looking at a backend database connected to a logic engine and visualisation front end. If you are looking for a good overview of usage take a look at the following web page and git repo [A little dated but useful]:

  • https://anmolkoul.wordpress.com/2015/06/05/interactive-data-visualization-using-d3-js-dc-js-nodejs-and-mongodb/
  • https://github.com/anmolkoul/node-dc-mongo

I hope the above points you in the right direction.



Related Topics



Leave a reply



Submit