Shiny app dropping offline while running long process

Hi, I'm writing to seek help on the issues in R shiny in relation to long running process. My codes involve running several simulations which takes about 1 min to run. It runs well in R console, however, when i run it in the Shiny app, the app just keeps dropping offline at about 20 seconds of running and asks to reload the page. Here is the app that we developed:https://glasgowhehta.shinyapps.io/MetaInsight_continuous_Bayesian/

(Apologies, due to the nature of the issue we could not think how to give a simple example.)

If you click the ‘Data analysis’ tab - ‘3. Bayesian network meta-analysis’ tab - ‘3d. Nodesplit model’ tab, then click the button ‘Click here to run the main analysis for all studies’, it will drop the app offline before generating results (but this will take nowhere near as long as it would take for the server to disconnect due to user inactivity). The programme behind this button is a series of simulation evaluations using JAGS (which uses Gibbs Sampling and is computationally intensive and can produce a lot of data https://en.wikipedia.org/wiki/Just_another_Gibbs_sampler).

When only a small number of simulations are required, results could be rendered, however, when a larger number of simulations are required, the app will drop offline. You could test this by ticking some studies out from the sidebar, say ticking all the studies from ‘Kuo 2006’ down until ‘Derosa 2005’, which will result in only a small proportion of the data entering the ‘nodesplitting analysis with studies excluded’. After ticking these studies out, click the button on the right hand side, ‘Click here to run the nodesplitting analysis with studies excluded’, then the results should be rendered.

So our questions are:

  1. Why does the app drop offline when the background computations are more extensive (i.e. is it a memory or a time issue or another altogether)?

  2. What can be done to get round this problem (we have tinkered with the server settings but without success)?

We would be very grateful for any advice.

What the logs for your app say?

Thanks for your reply. Log is here:

2019-04-10T16:17:27.661983+00:00 shinyapps[796451]: Initializing model
2019-04-10T16:17:33.373507+00:00 shinyapps[796451]: Allocating nodes
2019-04-10T16:17:33.373508+00:00 shinyapps[796451]: Graph information:
2019-04-10T16:17:33.373503+00:00 shinyapps[796451]: Compiling model graph
2019-04-10T16:17:33.373511+00:00 shinyapps[796451]: Total graph size: 806
2019-04-10T16:17:33.373506+00:00 shinyapps[796451]: Resolving undeclared variables
2019-04-10T16:17:33.373509+00:00 shinyapps[796451]: Observed stochastic nodes: 53
2019-04-10T16:17:33.373510+00:00 shinyapps[796451]: Unobserved stochastic nodes: 60
2019-04-10T16:17:33.376126+00:00 shinyapps[796451]: Initializing model
2019-04-10T16:17:33.373512+00:00 shinyapps[796451]:
2019-04-10T16:17:33.376128+00:00 shinyapps[796451]:
2019-04-10T16:17:39.568632+00:00 shinyapps[796451]: Compiling model graph
2019-04-10T16:17:39.568635+00:00 shinyapps[796451]: Resolving undeclared variables
2019-04-10T16:17:39.568636+00:00 shinyapps[796451]: Allocating nodes
2019-04-10T16:17:39.568637+00:00 shinyapps[796451]: Graph information:
2019-04-10T16:17:39.568638+00:00 shinyapps[796451]: Observed stochastic nodes: 53
2019-04-10T16:17:39.568638+00:00 shinyapps[796451]: Unobserved stochastic nodes: 60
2019-04-10T16:17:39.568639+00:00 shinyapps[796451]: Total graph size: 806
2019-04-10T16:17:39.568640+00:00 shinyapps[796451]:
2019-04-10T16:17:39.571085+00:00 shinyapps[796451]: Initializing model
2019-04-10T16:17:39.571087+00:00 shinyapps[796451]:

Then it dropped offline.

It is not clear here but I suspect that you could be running out of memmory, there is a 1GB limit for free accounts on shinyapps.io

1 Like

Thanks andresrcs.

Do you know how can i check how much memory it requires to run this process?

Unfortunately I don't know how to do that on shinyapps.io, hopefully RStudio people will chime-in here to help.

We were able to resolve this on a support ticket - the solution was, as @andresrcs suggested, to increase the memory available on the application instances.

We don't have anything built into shinyapps.io to check how much memory a process needs, but it's possible through a number of different methods, such as using profiling.