Shiny Performance Bottle Necks

I am trying to improve app launching. Currently, my apps take 20-15 seconds to start. I have isolated the issue. Here I have printed out the timings when I start the container manually with docker run:

From this I have isolated that the container itself launches fine. In other tests,

I have isolated the data load is not taking all that long. However, there appears to be an independent process, that takes a majority of the loading time eg it takes at least ten seconds for the “Listening on…” message to appear. I say it is independent, because I can move the data processing code into “server-start” contexts which alleviates maybe second or two of startup time. Is this a networking/authentication issue or something?


1 Like

I don’t have a precise timing metric. However, it seems that if I create a service manually with docker service create for example the openanalytics rbase image.

I observe the delay. Is this a docker swarm issue. One thing that is confusing to us is why ShinyProxy creates a service per user, rather than one service that multiple users use with independent containers.

Not to bump the thread, however I was able to launch one of the apps via the stack service and end to end the service was created almost instantaneously. Though I wasn’t able to test the web socket. Is it the WebSocket initialization that is that slow?

One thing I have noticed though is that the from the docker client launching a service via docker service create vs. docker stack create seems to function very differently, possibly slower to create an independent service than a stack.

The standalone service took 6-7 seconds to deploy as compared to the stack that deployed very quickly.

I’m not familiar enough with Swarm to comment, apart from this. I abandoned Swarm as start-up time for even the demo apps is ~ 10 seconds. I get ~4 seconds without Swarm.

Did you solve your issue, and have you stuck with Swarm?

No, the issue is inherent to the Docker Swarm routing mesh being a software simulation of a distributed hardware network. OpenAnalytics sent out a newsletter. They are going to implement a preloaded container system, sometime soon.

1 Like

Hi, we usually don’t experience this delay with Docker swarm, I’ll try to look into reproducing this.

Regarding:

One thing that is confusing to us is why ShinyProxy creates a service per user, rather than one service that multiple users use with independent containers.

There are multiple reasons for this. For example, this allows to customize the container for every user, run containers on-demand (e.g. using a lot of different container images etc), and provides complete isolation per user. In addition, depending on the exact purpose of the app, R and Shiny do not always support a lot of concurrent users.

That being said, I’m happy to announce that the next release of ShinyProxy will be able to pre-initialize containers and to host multiple users on a single container. See https://github.com/openanalytics/shinyproxy/issues/322#issuecomment-1873703511 for more information.