Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seat queue: maintaining idle containers that can turn to any app? ("stem containers") #527

Open
hq9000 opened this issue Sep 19, 2024 · 2 comments

Comments

@hq9000
Copy link

hq9000 commented Sep 19, 2024

Dear maintainers,

thank you for the incredibly useful product you offer. We have a question/proposal we'd be glad to know your opinion on.

Our Setup

  • we host a large number of different shiny apps apps (several dozens)
  • we use Seat Queue feature to reduce waiting time for the users

Problem

The problem we face is that maintaining an idle container for each of the apps leads to significant RAM footprint - simply because there are too many containers.

Idea

our apps are similar to each other in a sense that before running the server, they all do certain preloading of the same data.

Our thinking goes as follows: that would be great if we could somehow maintain "stem containers" with above mentioned data preloaded, which, however, do not yet know which specific app the container will serve.

If that is possible, we can limit ourselves to maintaining only one idle container instead of a few dozens.

Do you think if we can somehow make shiny proxy work this way? Is there anything like this planned?
If so, we would be willing to offer our help in terms of testing.

Thank you.

@LEDfan
Copy link
Member

LEDfan commented Nov 12, 2024

Hi, thanks for your suggestions. There is currently no native solution in ShinyProxy for this, but it's possible with some more advances setup. First of all, I think this only makes sense if you don't share the containers between users (and thus also are using allow-container-re-use: false), otherwise it will be very hard to implement this inside the app.

What you can do is to have a single app, and use app parameters to have the user select which "specific" app to load. Next, you send this parameter as an HTTP header to the app:

    - id: test
      container-image: openanalytics/shinyproxy-shiny-demo-auth
      parameters:
        definitions:
          - id: app
        value-sets:
          - values:
              app:
                - app1
                - app2
                - app3
      http_headers:
        app: "#{proxy.getRuntimeObject('SHINYPROXY_PARAMETERS').getValue('app')}"

Inside your R code you then check for this header and depending on the value load the exact module (see https://github.com/openanalytics/shinyproxy-shiny-demo-auth). Note that for this to work, Shiny must already be loaded and serving requests.

Of course this has the downside that there is now only one app listed on your main page. You could work-around this by using the external-url feature and create multiple links to the same app. This will still show the page to select the parameters. There is currently no way to automatically select the parameter based on the URL, but you could implement this in JS by using the custom template feature: https://shinyproxy.io/documentation/app-parameters/#custom-template

@hq9000
Copy link
Author

hq9000 commented Dec 18, 2024

hi @LEDfan, thank you for a thorough and insightful answer, we are evaluating if we can implement this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants