Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

handling multiple users simulaneously in an R Shiny app

Tags:

I have a simple shiny app that keeps track of the number of times the user has pushed a certain action button (actionButton()), and this total is reported back to the user along with other information.

Now I know that Shiny R creates one R session per app, so if multiple users are accessing the same app simultaneously, they are all working with the same R session. Hence the reported number of action-button presses for user X ends up being the sum of the action-button presses for all users who have accessed the app during the current R session.

I would like to keep the users separate, in a sense creating virtual instances of the app within a single R session.

I understand that when the function shinyserver() is run with the session argument, then a session object is created, and that information about the client's computer is store d in session$clientdata.

Is there some known way to leverage the contents of this object so as to set up and manage files that keep track of the status of the various users who are accessing the app at any given time?

like image 830
Homer White Avatar asked Mar 25 '14 20:03

Homer White


People also ask

Is Shiny multithreaded?

So the answer is yes shiny server open source is capable of multithreading, it simply wont automatically create new R processes to serve concurrent users' sessions (ie automatic load balancing).

Is R Shiny difficult?

Along with Shiny elements, you can use HTML elements to stylize your content in your application. In my opinion, R Shiny is very easy to learn despite how powerful the tool is. If you're working on a side project or looking to add something to your portfolio, I highly recommend trying it out.

Can you run Shiny app without R?

You can create a standalone shiny app, that runs on computers WITHOUT needing to install R nor any library.


1 Answers

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.

like image 147
Jeff Allen Avatar answered Sep 18 '22 15:09

Jeff Allen