handling multiple users simulaneously in an R Shiny app

15,317

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.

Share:
15,317

Related videos on Youtube

Homer White
Author by

Homer White

Mathematics professor at Georgetown College in Kentucky, USA.

Updated on October 14, 2022

Comments

  • Homer White
    Homer White over 1 year

    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?