shinyproxy icon indicating copy to clipboard operation
shinyproxy copied to clipboard

High CPU Usage in ShinyProxy Containers Leading to Application Inaccessibility

Open zhaohongxin0 opened this issue 10 months ago • 2 comments

Dear ShinyProxy Team,

I have been using ShinyProxy for some time, and it has generally been stable. However, as my Shiny applications have grown larger and the number of users has increased, I have encountered performance issues. Specifically, the Docker container running ShinyProxy often experiences CPU usage spikes exceeding 100%, sometimes even surpassing 200%. When CPU usage reaches 100%, accessing Shiny applications becomes slower, and when it exceeds 200%, the applications become completely unresponsive. This issue occurs regardless of whether I am using a single server with Docker or multiple servers with Docker Swarm.

To address this, I attempted to deploy multiple ShinyProxy replicas using Docker Swarm to distribute the load. I executed the following command:

sudo docker service create
--name sp-test-service
--replicas 3
--mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock
--publish 8080:8080
--network sp-example-net
--group $(getent group docker | cut -d: -f3)
myrep/shinyproxy

After deploying the three replicas, the CPU usage of the ShinyProxy containers immediately spiked above 400%, rendering the applications inaccessible. This leads me to question whether ShinyProxy supports the --replicas option in Docker Swarm.

Could you please advise on the following:

Is ShinyProxy compatible with Docker Swarm's --replicas option? If not, are there alternative methods to scale ShinyProxy to handle increased load?

What are the recommended practices for distributing the load across multiple ShinyProxy instances to prevent high CPU usage and ensure application responsiveness?

zhaohongxin0 avatar Feb 16 '25 21:02 zhaohongxin0

It's important to note that the server's CPU and memory resources are more than sufficient and are far from being fully utilized; the problem is isolated to the ShinyProxy container itself.

zhaohongxin0 avatar Feb 16 '25 21:02 zhaohongxin0

Hi, for later reference, I just added a new comment to your topic here: https://support.openanalytics.eu/t/docker-container-unresponsive-after-1-2-days-with-shinyproxy-deployment/3008/12

It would be good if we can find the root cause of ShinyProxy going to > 100% CPU usage, since this shouldn't happen.

Is ShinyProxy compatible with Docker Swarm's --replicas option? If not, are there alternative methods to scale ShinyProxy to handle increased load?

Yes, but for this to work correctly you need to setup Redis, such that the multiple replicas can communicate. See https://shinyproxy.io/documentation/configuration/#high-availability-and-scaling and https://shinyproxy.io/documentation/configuration/#enabling-app-persistence . But I don't expect this will solve your problem.

LEDfan avatar Feb 18 '25 14:02 LEDfan