Hosting Shiny

Preface

Motivation

Shiny is a reactive web application framework used by R and Python users to communicate their results to others. Whether you are just starting out with Shiny, or you are a seasoned programmer, at some point you’ll need to share your app with your colleagues and users. You might decide to send them scripts or deploy the app and share the URL that takes people to your app. The documentation and books about the Shiny ecosystem are phenomenal resources. However, these resources focus on the development of the applications and decidedly cover very little about what to do once the app is deployed.

It might surprise you, but there are at least /FIXME: CHECK THIS NUMBER/ 20 hosting options for Shiny. Navigating these options and finding up-to-date advice on choosing one and getting started is not easy or trivial. Information about Shiny hosting is scattered around the Internet and is often incomplete. Recommendations are usually narrowly focused and never really ask important questions such as: Why do you want this app to be deployed? Who is this app for? What is your budget? The goal of the book is to help you learn about the hosting options and what it takes to host your apps securely.

Current available books focus on the R aspect of Shiny, which is not surprising given that Shiny for Python is a relatively recent addition to the Shiny ecosystem. Luckily, Shiny for R and Python have very similar deployment and hosting patterns. Therefore, we can cover both in the same book. We think this is important, because with the increasing popularity of Shiny available for R and Python, learning more about the hosting side of the application life-cycle will be a critical need for programming enthusiasts and data science professionals alike.

Who Is This Book For?

If you are asking any of the following questions, this book is definitely for you:

  • What Shiny hosting solutions are out there?
  • How do I decide which of these options suits my needs, my budget, and my skill level the best?
  • How can I get started, and where can I get help if I get stuck?

If you are not (yet) asking these questions, but want to learn about servers, cloud instances, and containers from the perspective of Shiny apps, this book is still for you.

You might be a researchers in academia, government, and at a nonprofit organization who wants to self-host Shiny apps so that you can show your results to your colleagues, your stakeholders, or to the public. You might work at a small agency or a startup and want to securely host apps for your clients and users. Or you might be a data scientist who wants to effectively collaborate with people in the IT and engineering department on Shiny app deployment and hosting.

What Will You Learn?

The book is structured into four main parts:

  • Part I. Getting started – This will give you the fundamentals for the rest of the book, including some background, concepts, and setup instructions.
  • Part II. Shiny Apps – This part deals with everything that happens on your local machine, including developing and organizing Shiny apps, and ways of running the apps locally.
  • Part III. Hosting Shiny Apps – This part describes all the ways of how Shiny apps can be hosted on remote machines, like cloud servers. This part is the longest, because there are quite a few hosting options.
  • Part IV. What is next – You’ll find a summary of all the things you might want to do next with your Shiny app, things that might either be too advanced or are harder to describe in a physical book format.

The book does not end on the last page. You can find online supplements, including the HTML version of the book and all the code that we present in the book and more on the book’s website at FIXME: add final website.

What Will You Not Learn?

This book is focused on the many different ways of hosting Shiny apps. This topic is at the intersection of R & Python programming, Shiny app development, and DevOps. We assume you are already familiar with either R or Python. If this is not the case, we suggest you start with accessible introductions to R or Python before going further. You don’t need to know both languages, but knowing at least one is definitely needed.

We will use example Shiny apps to test and demonstrate the different hosting options, but we are not going to teach you how to master Shiny, how to engineer production-grade apps, and how to make outstanding user interfaces with Shiny. You can find all about those topics in these excellent books:

There is also quite a bit that can be said about servers and cloud infrastructure that we won’t cover in this book. DevOps for Data Science (Gold 2024) gives an accessible overview of DevOps conventions, tools, and practices, and provides pointers for further broadening your knowledge in these areas.

Conventions

Throughout the book, we will use title case and all caps for software and frameworks, e.g. Shiny, R, Python SSH, HTML, CSS, etc. We will use monospace code font for inline mentions of libraries and extension packages (e.g. shiny, pandas), also for functions and methods (e.g. summary(), pandas.read_csv()), and file names (image.png). Italicized text will be preserved for publication titles (e.g. Mastering Shiny) and for cases when we imitate self talk. For example: I feel a little bit lost, what do I do now? We will use bold when highlighting or emphasizing words. URLs when pointing to Internet resources, like websites, will be in normal font (e.g. https://mastering-shiny.org), URLs when mentioning with regards to examples will be in code font (e.g. http://127.0.0.1). We will use angle brackets for variable values that you should replace in your code, e.g. https://<your-domain>. Dot-dot-dot within brackets, [...], will indicate that we trimmed the output to save space by not showing too verbose or repetitive text in the book. We will use backslash (\) to break up long commands to help readability and to fit on the printed page.

We use the h10y as a shorthand for Hosting Shiny, and it means that between the first letter h and the last letter y there are 10 other letters. You will see the domain h10y.com used to shorten links and to prevent link rot after the print version of the book is out. We will also use h10y in Docker image namespaces to make image tags shorter.

About the Authors

Péter Sólymos is a senior data scientist with 20 years of experience in wildlife, environmental, and utilities sectors. He holds a PhD in biology, he has authored 70 peer-reviewed publications and several statistical software packages. He is passionate about using statistics and data science to bridge the gap between data and decision making. His focus is on enabling this by helping organizations adopting cloud-native practices into their operations. FIXME: revise. https://peter.solymos.org

Kalvin Eng is a PhD candidate in Computing Science at the University of Alberta with over 15 years of software development experience. His research involves understanding and improving the processes of software engineering. He is passionate about helping organizations develop efficient processes to build software more effectively.
FIXME: revise. https://kalvineng.com

Acknowledgements

We are grateful for Kahlid Lemzouji for continuously finding new reasons to up our game with Shiny hosting. Thanks to Kalob Taulien for helping with our early Shiny hosting endeavors.

Some of the content of this book was developed as part of workshops held by the authors at the Edmonton R User Group (YEGRUG). We are thankful for the Statistical Society of Canada for inviting us to teach the course Delivering applied statistics from concept to production.

FIXME: add here more names as needed

References

Fay, Colin, Sébastien Rochette, Vincent Guyader, and Cervan Girard. 2021. Engineering Production-Grade Shiny Apps. Chapman & Hall. https://engineering-shiny.org/.
Gold, Alex. 2024. DevOps for Data Science. Chapman & Hall. https://do4ds.com/.
Granjon, David. 2022. Outstanding User Interfaces with Shiny. Chapman & Hall. https://unleash-shiny.rinterface.com/.
Wickham, Hadley. 2021. Mastering Shiny. O’Reilly Media, Inc. https://mastering-shiny.org/.