ShinyProxy 3.1.1: What’s New And How It Improves Scalability And Performance Of Your Shiny Applications

[This article was first published on Tag: r - Appsilon | Enterprise R Shiny Dashboards, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

ShinyProxy has emerged as a powerful solution for deploying Shiny applications, empowering organizations to share interactive data visualizations and analyses.

With its robust feature set, ShinyProxy has simplified the process of managing and scaling Shiny apps for a wide range of use cases. The ShinyProxy 3.1.1 release marks a significant leap forward, introducing new features that optimize performance, enhance resource management, and expand deployment options.

The two main scalable hosting solutions are Posit Connect and ShinyProxy. We did the research for the comparison, you do the reading.

This article explores the key advancements in ShinyProxy 3.1.1 and how they empower organizations to unlock new levels of scalability and efficiency.

Impact Of New Features

ShinyProxy 3.1.1 introduces several powerful features designed to address the growing demands of Shiny application deployments. These features offer a compelling set of advantages:

  • Enhanced Resource Efficiency: The new container sharing feature allows multiple users to utilize a single container, dramatically optimizing resource allocation and reducing overall server load.
  • Faster User Experience: Pre-initialization of containers ensures that applications are ready for use, minimizing wait times for users and providing a seamless and responsive experience.
  • Expanded Deployment Options: The addition of AWS ECS support opens up new possibilities for serverless deployments, providing organizations with greater flexibility and scalability.
  • Streamlined Container Management: Improved container naming conventions and an updated Docker library enhance usability and ensure compatibility with the latest Docker releases.
  • Enhanced Control and Security: The ability to set user limits at a global and application-specific level provides administrators with greater control over resource usage and strengthens security measures.

We prepped everything you need to know about running your Shiny apps in a container. Learn more in our comprehensive guide.

More Efficient Container Management With Container Sharing

Traditionally, ShinyProxy operated on a one-user-per-container model. While this approach offers isolation and customization benefits, it can lead to increased resource consumption, especially when dealing with a large number of users. ShinyProxy 3.1.1 introduces the groundbreaking concept of container sharing, allowing multiple users to share a single container.

This new approach in container management significantly impacts resource utilization and scalability:

  • Reduced Resource Consumption: Container sharing drastically reduces the number of containers required to serve a given number of users, leading to substantial savings in CPU, memory, and other resources.
  • Increased Scalability: With container sharing, ShinyProxy can now efficiently handle a much larger number of concurrent users with the same hardware infrastructure.
  • Faster Startup Times: Although container sharing might slightly increase the initial startup time of a container, subsequent users connecting to the shared container experience significantly faster startup times compared to launching a new container.

To ensure that user-specific information is still accessible within a shared container environment, ShinyProxy utilizes HTTP headers to transmit crucial data like usernames and groups directly to the application. This approach eliminates the reliance on environment variables, which are insufficient in shared containers.

Configuration:
To enable container sharing, you can specify the seats-per-container property in your application’s configuration. For example:

proxy:
  specs:
  - id: my-shared-app
    display-name: My Shared App
    container-cmd: ["R", "-e", "shiny::runApp('/app')"]
    container-image: openanalytics/shinyproxy-demo
    container-network: sp-net
    seats-per-container: 5

This configuration allows up to five users to share a single container instance for the “my-shared-app” application.

Achieving Instant App Readiness With Pre-Initialization

ShinyProxy 3.1.0 introduced the concept of pre-initialization, a powerful feature that dramatically improves application startup times. Instead of waiting for a container to launch when a user requests an application, ShinyProxy can pre-initialize a pool of containers ready for immediate use.

When a user requests an application, they are instantly assigned to one of these pre-initialized containers, eliminating the wait time associated with container startup. This results in a seamless and highly responsive user experience.

The impact of pre-initialization is particularly significant in scenarios with:

  • High User Volume: Pre-initialization ensures that a pool of readily available containers can handle sudden spikes in user demand, preventing delays and ensuring a smooth experience for all users.
  • Resource-Intensive Applications: For applications that require substantial resources to start, pre-initialization minimizes the perceived wait time for users, making the application feel more responsive.

Configuration:
To enable pre-initialization, you can configure the minimum-seats-available property in your application’s configuration:

proxy:
  specs:
  - id: my-pre-initialized-app
    display-name: My Pre-Initialized App
    container-cmd: ["R", "-e", "shiny::runApp('/app')"]
    container-image: openanalytics/shinyproxy-demo
    container-network: sp-net
    minimum-seats-available: 3

This configuration ensures that at least three pre-initialized container instances are always available for the “my-pre-initialized-app” application.

Deeper Dive Into The Other New Features

Container Re-use

Whether a (pre-initialized) container can be re-used by a different user (has no effect when minimum-seats-available isn’t specified).

allow-container-re-use: true

Normally ShinyProxy removes the container after first use. It can only be used when seats-per-container equals 1. When set to false, you benefit from pre-initialized containers, while still having the guarantee that a container is used by a single user only..

Scale Down Control

ShinyProxy waits to scale-down after a scale-up (defaults to two minutes). This means that if a user stops using an app, the container is released only if there was no scale-up in 2 minutes.

scale-down-delay: 2

By increasing this value (in minutes), you can prevent too many scale-up and scale-downs in a short period.

For more details on container sharing and pre-initialization, check out the official documentation.

Custom Container Names

Simplifies container management by allowing administrators to customize container names using SpEL expressions. This provides greater flexibility and control in identifying and managing containers within a deployment.

Configuration:

container-name:  'sp-container-#{proxy.id}-#{container.index}'

Up-to-Date Docker Library

ShinyProxy 3.1.1 includes an updated Docker library, ensuring compatibility with the latest Docker releases and addressing potential compatibility issues with older libraries. This enhancement contributes to the platform’s overall stability and reliability.

User Limits

Administrators can now set limits on the total number of running applications, both globally and on a per-application basis. This feature empowers organizations to better manage resources and prevent potential overloads, particularly in public-facing or resource-constrained environments.

Configuration:

  • Global limit: Define the max-running-containers in the proxy section of your configuration file.
  • Per-application limit: Use the max-instances property within the specific app’s configuration.

AWS ECS Backend

The introduction of AWS ECS (Elastic Container Service) support expands ShinyProxy’s deployment options, allowing organizations to leverage the power of serverless deployments using AWS Fargate. This backend provides enhanced scalability, eliminates server management overhead, and integrates seamlessly with other AWS services like CloudWatch and IAM. A ready-to-use Terraform deployment example is available to simplify the setup process.
A downside of AWS ECS is that in most cases it takes more time to start the container compared to the other backends. But of course it can be used together with the pre-initialized container feature, reducing the startup time to less than a second.

Enhanced Monitoring (Not explicitly mentioned but valuable)

ShinyProxy 3.1.0 introduced enhanced monitoring capabilities, particularly for pre-initialized and shared containers. New dashboards provide comprehensive insights into the performance and resource usage of these containers, enabling administrators to effectively monitor and manage their deployments.

Conclusion

ShinyProxy 3.1.1 sets a new standard for deploying and managing Shiny applications. The groundbreaking features of container sharing and pre-initialization, coupled with expanded deployment options through AWS ECS support, mark a promising advancement in scalability, performance, and resource efficiency.

These enhancements, along with usability improvements and enhanced monitoring capabilities, empower organizations to unlock the full potential of Shiny applications and cater to increasingly demanding deployment scenarios. You can check out full release notes in this documentation.

Want to get more insights on the latest in R/Shiny and data science as a whole? Sign up today for our weekly newsletter!

The post appeared first on appsilon.com/blog/.

To leave a comment for the author, please follow the link and comment on their blog: Tag: r - Appsilon | Enterprise R Shiny Dashboards.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)