More than one user per container?


I understand the reason of errors! When we are using round robin algoritm every new reqest from one user (f.e. get some js or css file) go to different backends (in our case different containers). In this situation user may try to get file from container, where shiny server session did not start (because we start shiny server session in another container - with which we made first connection). To resolve this problem we should bind user to exact container.

  worker_processes 1;

events { worker_connections 1024; }

http {

sendfile on;

map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;

upstream myapp1 {
hash $remote_addr;
    server your_real_ip:3838 fail_timeout=300 max_conns=150;
server your_real_ip:3839 fail_timeout=300 max_conns=150;
server your_real_ip:3939 fail_timeout=300 max_conns=150;
   # server shiny-2:3838;

#sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server {
    listen 80;
    location / {
        proxy_pass         http://myapp1;
        proxy_redirect     http://myapp1/ $scheme://$host:$server_port/;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;
    proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 20d;
        proxy_buffering off;


This nginx config works with docker compose. New challenge is to dynamically update config for docker swarm.



Yes, I agree with your opnion that there’s one limitation on the current one user - one container strategy of shinyproxy. If the app needs to load large size of data, the current strategy will suffer. However, if one container allows N users at the same time, those users can share the data and save the loading time and resources. In some cases, this is very important.


It’s great that you have figured it out. If you get a solution for this new challenge, please update here! Thanks.


Yes, that’s definitely a significant difference when the app needs to load large dataset. Even for just one user, since the container gets killed once the user signs out or the heartbeat times out, the data needs to be loaded again. So the problem is actually sometimes we need an app to be running for a long period of time(or permanent) and serve more than one user.