Video: How to Scale Shiny Dashboards

[This article was first published on r – Appsilon Data Science | End­ to­ End Data Science Solutions, 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.

Shiny Dashboard Scaling Thumbnail

This presentation was a part of a joint virtual webinar with Appsilon and RStudio entitled “Enabling Remote Data Science Teams”. Find a direct link to the presentation here

How to Scale a Shiny App to Hundreds of Users

In this video, Appsilon’s VP of the Board & Co-Founder Damian Rodziewicz explains best practices for scaling Shiny applications in production. Damian explains three of the areas that Appsilon focuses on to scale Shiny applications: Frontend LeveragingExtracting Computations, and creating a stable and scalable Architecture.

R Shiny applications are fast by default but can become extremely slow if they are not properly built, especially when there are tens or hundreds of people using them. Having best practices in mind from the beginning of the project can save you a lot of trouble down the line. 

Learn More: Why You Should Use R Shiny For Enterprise Application Development

Vertical and Horizontal Scaling

If you intend to scale your Shiny app, there are two concepts we need to explore: Vertical Scaling and Horizontal Scaling.

Horizontal and vertical scalingIt’s best to start with proper vertical scaling – you should make sure the application is fast and robust in the first place while running on a single machine, and then you can add as many machines as you want in an efficient way (horizontal scaling). With this in mind, let’s return to our three previously mentioned areas: Leveraging Frontend, Extracting Computations, and Setting the Architecture. 

Pillars of making Shiny apps faster

Below is a quick rundown of each area, but please reference the video presentation for a full explanation. Above all, it’s important to Make the Shiny Layer Thin. This means that Shiny should only be doing the work that it’s best at – creating an interface between R and your browser.  The rest of the work (such as interactivity or long computations) should be offloaded to the browser or handled by the database, etc.

Leverage Frontend 

  • Render inputs in UI and update them in Server – failing to do so requires re-rendering entire widgets, which makes the application run slower.
  • Run inline JavaScript – the package shinyjs allows you to do this. It’s best used to make some quick toggles.
  • Set all actions in JavaScript – handle things like button clicks with JavaScript, not with Shiny.
  • Learn more about leveraging frontend in Shiny here.

Extract Computations 

  • Remote API – the Plumber library is excellent for doing this. You rarely need the entire dataset when using the application, so why not filter it down first and then load only what you need when you need it. This logic is easily wrapped into a simple API.
  • Use a database – loading large files in memory isn’t scalable for tens/hundreds/thousands of users. Using a database can dramatically improve the performance of Shiny apps. 
  • Are heavy calculations freezing your Shiny app? Appsilon is developing the shiny.worker package to address this problem. shiny.worker is currently still under development, but it can be made available to clients and non-profit organizations on request.

Architecture

  • RStudio Connect and Shiny Server Open Source allows you to deploy applications quickly.
  • We use Ansible – to provision the whole infrastructure, install requirements, RStudio Connect, and deploy the application.
  • Learn more about the options for deploying Shiny apps here.

Learn more

Appsilon is an RStudio Full Service Certified Partner. We are global leaders in Shiny and we specialize in advanced enterprise Shiny apps for Fortune 500 companies. Reach out to us at [email protected].

Article Video: How to Scale Shiny Dashboards comes from Appsilon Data Science | End­ to­ End Data Science Solutions.

To leave a comment for the author, please follow the link and comment on their blog: r – Appsilon Data Science | End­ to­ End Data Science Solutions.

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)