Docker Container Runs in 5 Seconds with `docker run` and 15 Seconds with ShinyProxy

Hi all,

We are running ShinyProxy with docker swarm and our dashboards run okay. The only problem is that it takes longer than normal to show an individual dashboard. We tested an individual dashboard, it took 5 seconds to open with docker run and 15 seconds on ShinyProxy.

We tried to do docker inspect and saw the followings:

{"log":"2023-07-12 13:33:32.693  INFO 1 --- [           main] e.o.c.util.StartupEventListener          : Started ShinyProxy 3.0.2-SNAPSHOT (ContainerProxy 1.0.2-SNAPSHOT)\n","stream":"stdout","time":"2023-07-12T13:33:32.694252384Z"}
{"log":"2023-07-12 13:33:32.694  INFO 1 --- [           main] e.o.c.service.AppRecoveryService         : Recovery of running apps disabled\n","stream":"stdout","time":"2023-07-12T13:33:32.694627944Z"}
{"log":"2023-07-12 13:33:34.161  INFO 1 --- [  XNIO-1 task-1] io.undertow.servlet                      : Initializing Spring DispatcherServlet 'dispatcherServlet'\n","stream":"stdout","time":"2023-07-12T13:33:34.161646637Z"}
{"log":"2023-07-12 13:33:34.162  INFO 1 --- [  XNIO-1 task-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'\n","stream":"stdout","time":"2023-07-12T13:33:34.162514192Z"}
{"log":"2023-07-12 13:33:34.164  INFO 1 --- [  XNIO-1 task-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 2 ms\n","stream":"stdout","time":"2023-07-12T13:33:34.165031827Z"}
{"log":"2023-07-12 13:33:34.183  INFO 1 --- [  XNIO-1 task-1] e.o.containerproxy.service.UserService   : Anonymous user logged in [user: ebfcfeea81dd37b7f1b54ea9dd3d8c5103854b92c0c02c5a08292eca268656f]\n","stream":"stdout","time":"2023-07-12T13:33:34.183475629Z"}
{"log":"2023-07-12 13:33:38.319  INFO 1 --- [pool-2-thread-1] e.o.containerproxy.service.ProxyService  : [user=ebfcfeea81dd37b7f1b54ea9dd3d8c5103854b92c0c02c5a08292eca268656f proxyId=cab46b61-b1db-476c-a396-3564df4dd763 specId=iraq-state-budget] Starting
proxy\n","stream":"stdout","time":"2023-07-12T13:33:38.3204036Z"}
{"log":"2023-07-12 13:33:43.829  WARN 1 --- [pool-2-thread-1] e.o.shinyproxy.ShinyProxyTestStrategy    : [user=ebfcfeea81dd37b7f1b54ea9dd3d8c5103854b92c0c02c5a08292eca268656f proxyId=cab46b61-b1db-476c-a396-3564df4dd763 specId=iraq-state-budget] Container unresponsive, trying again (11/20): http://fb3bc4657b3e:3838\n","stream":"stdout","time":"2023-07-12T13:33:43.829375118Z"}
{"log":"2023-07-12 13:33:45.830  WARN 1 --- [pool-2-thread-1] e.o.shinyproxy.ShinyProxyTestStrategy    : [user=ebfcfeea81dd37b7f1b54ea9dd3d8c5103854b92c0c02c5a08292eca268656f proxyId=cab46b61-b1db-476c-a396-3564df4dd763 specId=iraq-state-budget] Container unresponsive, trying again (12/20): http://fb3bc4657b3e:3838\n","stream":"stdout","time":"2023-07-12T13:33:45.830410778Z"}
{"log":"2023-07-12 13:33:47.831  WARN 1 --- [pool-2-thread-1] e.o.shinyproxy.ShinyProxyTestStrategy    : [user=ebfcfeea81dd37b7f1b54ea9dd3d8c5103854b92c0c02c5a08292eca268656f proxyId=cab46b61-b1db-476c-a396-3564df4dd763 specId=iraq-state-budget] Container unresponsive, trying again (13/20): http://fb3bc4657b3e:3838\n","stream":"stdout","time":"2023-07-12T13:33:47.83180459Z"}
{"log":"2023-07-12 13:33:51.944  INFO 1 --- [pool-2-thread-1] e.o.shinyproxy.ShinyProxyTestStrategy    : [user=ebfcfeea81dd37b7f1b54ea9dd3d8c5103854b92c0c02c5a08292eca268656f proxyId=cab46b61-b1db-476c-a396-3564df4dd763 specId=iraq-state-budget] Container responsive\n","stream":"stdout","time":"2023-07-12T13:33:51.944986132Z"}
{"log":"2023-07-12 13:33:51.974  INFO 1 --- [pool-2-thread-1] e.o.containerproxy.service.ProxyService  : [user=ebfcfeea81dd37b7f1b54ea9dd3d8c5103854b92c0c02c5a08292eca268656f proxyId=cab46b61-b1db-476c-a396-3564df4dd763 specId=iraq-state-budget] Proxy activated\n","stream":"stdout","time":"2023-07-12T13:33:51.975067949Z"}

As you can see shinyproxy.ShinyProxyTestStrategy is raising warnings of Container unresponsive, trying again until it opens on the 13th try.

Anyone has any thoughts on load time and the logs warnings ?

Thank you,
Riyadh

A similar unanswered inquiry can be found here.

Hi

When you open an app, ShinyProxy first tells Docker to run and start the container. This may take a bit of time (usually a few seconds). Thereafter, ShinyProxy starts checking whether the web server inside the container is responding to requests. Typically, when you start an R process it takes again a few seconds before it actually starts responding to web requests.

There should not be a big difference between these timings when running locally and when using ShinyProxy. However, when you test locally, you have to take into account the time it takes for the R process and webserver to startup. That means the time it takes for docker run to start the container and the time it takes for you to be able to open the app and use the app.

I hope this explains the warnings.

Thank you @tdekoninck. The explanation makes sense.

If I understood correctly:
The time to run the image locally through docker run + the time to be able to use the shiny app through http://172.17.0.2:3838/ will equal to the time of accessing the same image in ShinyProxy ?

I tested this, I’m able to use the app locally in ~6 in contrast to ~15 in ShinyProxy. Am I getting you wrong?

Thanks again!
Riyadh

I have similar issues. I think it is mostly a docker routing mesh issue in my case, because I am using a swarm backend. This isn’t very performant, because the network is simulated in software, rather than on distributed dedicated hardware. I have been able to put messages in my container during startup, and the container is actually up and running when launched from ShinyProxy. In my case it takes fractions of second to start the container. Once the WebSockets are initialized everything works fine.

I don’t know if there is any way around it, except to use something like host networking and have ShinyProxy assign ports, currently not supported.