0
votes

I have deployed a shinyapp which uses a .Rdata file of ~700Mb.

The Rdata file is loaded in server-inputdata.R file and the server.R file looks like as shown below:

options(shiny.maxRequestSize = 100*1024^2)

source("helpers.R")
print(sessionInfo())

shinyServer(function(input, output,session) {
  source("server-inputdata.R",local = TRUE)
  source("server2.R",local = TRUE)
  source("server3.R",local = TRUE) 
})

Here, server2.R and server3.R has visualization code which uses the data loaded from .Rdata file in server-inputdata.R

Whenever the app is loaded, the Rdata file is getting loaded for each user. Could someone help how to load the data only once and provide immediate access to the users. Checked a similar thread here https://stackguides.com/questions/31557428/r-load-only-once-a-rdata-in-a-deployed-shinyapp which did not help to solve my issue.

Here is the code in server-inputdata.R

inputDataReactive <- reactive({
    load('04.Rdata')
    return(list("data"=data_results,
                "data_results_table"=data_results_table))
    print("uploaded data")
})
2
If your deployment is containerised, eg on shinyapps.io, then this simply isn't possible: each user has their own instance of the app. If this is possible in other configurations, and if so, how to do it, I do not know. I suspect the solution will be installation-specific.Limey

2 Answers

0
votes

Try putting your source line : source("server-inputdata.R",local = TRUE) outside of your server function, as in :

options(shiny.maxRequestSize = 100*1024^2)

source("helpers.R")
source("server-inputdata.R",local = TRUE)  # loaded once per session
print(sessionInfo())

shinyServer(function(input, output,session) {
  source("server2.R",local = TRUE)
  source("server3.R",local = TRUE) 
})
0
votes

Removing the reactive function did the trick.

options(shiny.maxRequestSize = 100*1024^2)
source("helpers.R")
load('04.Rdata')
data<-list("data"=data_results,"data_results_table"=data_results_table)
shinyServer(function(input, output,session) {
source("server2.R",local = TRUE)
source("server3.R",local = TRUE) 
})

And loading the data o