Shiny app slow upon deployment but fine while running locally

Hi all,

I'm very new to writing Shiny apps and have written a relatively complex one (code hosted at https://github.com/crewalsh/mriqception/tree/master/shiny_app/mriqception_app). It runs perfectly fine on my local computer, but when I deploy it to shinyapps.io, it becomes incredibly slow. For example, I have a series of conditional panels that only are shown when a checkbox is selected. On my local computer, this works totally fine, but when I deploy it, the conditional panels are displayed for a time (more than 1m) and then the app renders the way I want it to. In addition, I have a file input that works immediately on my local computer, but takes a good deal of time to even start uploading a file when the app is deployed.

I've tried profiling my code using profvis to see if there's anything slowing it down, but I'm honestly not sure how to interpret the results (I'm not sure what would be considered slow enough to be slowing down my app), so I'm not sure what my next steps should be to help speed up my app. I also have seen some questions on StackOverflow that have suggested it might be a memory problem, but again, I'm not sure how to interpret/implement this suggestion, especially since the slowness seems to be around the UI when there is a reactive component involved.

Does anyone have any tips/resources to help speed up my app when it's deployed? Thanks so much in advance!!

Check out this chapter on Shiny optimization https://engineering-shiny.org/when-optimize.html

The book is about the {golem} package but this chapter specifically can apply to any Shiny application.

I had a similar problem and found this helpful.

In Chrome ctrl+Shift+J opens the developer console. Open your app on the shiny server and look at the messages popping up in the console as it loads.

This way I identified some underlying errors with leaflet that were slowing down my flexdashboard but were not apparent when running locally.

May be worth a try.