Chapter 2 Introduction to Shiny in Production

Why are we here?

Shiny applications are being deployed in high-value, customer-facing, and/or enterprise-wide scenarios. Unfortunately, they are often being done without the benefit of best practices. This workshop will help you and/or your IT colleagues who support your data scientists learn how to accelerate a successful Shiny application deployment in production scenarios.

Over the past year, software developers at RStudio have been working hard to dispel rumors that Shiny “isn’t ready and can’t run in production”. They’ve built a bunch of cool new tools that are useful in preparing applications for production and understanding how to configure and scale them for optimized performance and user experience.

This workshop will cover all these new tools for shiny development as well as the equally important logistical pieces of a production story:

  • What does production infrastructure and tooling look like for Shiny apps?
  • How do we get Shiny apps from development into production?
  • How are Shiny apps maintained production?

When developers begin to think of infrastructure as part of their application, stability and performance become normative. - Jeff Geerling “Ansible for DevOps”

2.1 Workshop Objectives

Running Shiny in Production

  • Is Shiny ready for production?
  • What does it take to get there?
  • What do you need to know?
  • What tools are available?
  • How do you develop a workflow?

Understand the importance of incremental changes and testing

  • Version control
  • Tests for package upgrades
  • Use of separate environments for staging and production
  • Incorporating automated testing into a development workflow: shinytest

Data product tradeoffs

  • What are the advantages to using Shiny vs Plumber vs R Markdown
  • What is the difference between a stateless Plumber API and a Shiny Session?

Development vs. Production environment considerations

  • Defining a data model
    • Working with databases
  • Tools for understanding application performance
    • shinyloadtest
    • profvis
  • Tools for improving application performance
    • Plot caching
    • Synchronous vs asynchronous paradigms: async

Deployment architecture and tools

  • Introduction to analytic infrastructure
  • Configuration management
  • Resources for scaling horizontally

2.2 Workshop Infrastructure

  • RStudio Connect
  • PostgreSQL
  • RStudio Server Pro

Instructions for accessing the classroom environment are available in the workshop slide deck.