I have an app deployed here (https://psycho-metrics.shinyapps.io/metrics/) and am experiencing a problem with computational speed when the app is deployed at shinyio compared to how quickly the app runs on a local machine. I'll describe the problem conceptually rather than with reproducible code to see if it's possible to learn how to resolve the issue.
This app has a component of highly optimized code, some of the code is Rcpp, that runs an optimization procedure using nlminb. When I run the code locally (now tested on two different windows 10 machines), the procedure runs extremely fast (around 30 seconds on my local machines with a certain data set).
Now, when I run this same procedure on the live app using the same data that is deployed over at shinyio the process runs very slowly, finishing in around 3 minutes, although it produces the exact same results as when I run it locally. This is an important point. The results of the code are the same no matter what machine is used to run it. The difference is only in the runtime in that shinyapp.io is very slow and local machines used for testing are extremely fast.
When things run locally, I can profile the code using something like profvis() or other tools and step through code and see which code chunk is slow. When the app is live, I do not believe such diagnostics exist.
I believe what I'm experiencing should be theoretically impossible given that shinyio deploys to AWS servers that should in principle be more powerful than my small laptops. My code is well-tested and runs correctly. I have checked the logs at shinyio to see if this triggers anything unusual and there is nothing. I have restarted my app at shinyio.
I pay for the "basic" plan, there is no other traffic on the app, there is no parallel processing, it's seemingly a very strange problem that my app would run so quickly on a local (small) laptop and so slowly on a more powerful machine. I can also run my app locally on multiple laptops and desktops (all windows) and again it always runs in approximately the same time.
I do not believe there are any tools at my disposal that can be used to understand how/why the app runs so slow when deployed but runs so quickly on local machines.
Has anyone experienced such an issue before or know of any tools that can be used to understand the behavior of apps when deployed live? If this were on a server I was hosting, I can imagine being able to monitor all the things (e.g., CPU usage, memory and such). Some of those metrics are available in the shinyio dashboard but none of them indicate topping out in any meaningful way.