Multiple R processes in one app - RStudio Connect

Hi,

I am trying to help one of my customers. They purchased RStudio Connect (not yet installed probably) and they want to develop the shiny app. They are wondering if it is possible to have multiple R processes in one app. For example if the app provide the solution to calculate something and it will take few seconds / minutes and in the same time two users will run the calculations, what will happen then? The processes will run simultaneously or sequentially?

As far as I know, free version of R allow only for a single process per app. Does it change anything if they have RStudio Connect?

1 Like

Hi @Bofedojo! This is a very interesting question with a nuanced answer:

  • RStudio Connect does scale the number of processes associated with content in response to increased demand. This is very important for multi-tenancy as there is a point for any application where the number of concurrent users cannot be served by a single R thread. On the other hand, in order to efficiently use resources, every user should not have their own process. Connect uses the below configuration (load factor, max connections per process, etc.) to decide when to spawn new processes for an application

  • However, this direction of scaling is mostly to handle many concurrent users and the problems that come from many users on the same R process (even doing minuscule operations). It is not meant to offload heavy computations onto separate threads. For this pattern, which I believe is your primary aim, you are looking for "async programming." There is a good (but a bit dated) talk with a demo on the subject here:

It is also discussed in this article:

https://shiny.rstudio.com/articles/async.html

For a talk on general practices for "Shiny in Production"

And for a fun experiment on how to deploy a Shiny application to 10,000 concurrent users

I hope those resources are helpful!!

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