Where and How to host your Shiny App

Shiny app deployment

Featured image

You have created your genius Shiny app. How are you going to show it to the world?

A look at different methods and their pros and cons on deploying your Shiny apps in a remote server to allow access to an audience to view and use …

Once the development of a Shiny app is done, the next step would be to allow the designated users to take advantage of its functionality. Shiny allows us to share an application using primarily on the following three mediums..

  1. Shinyapps.io
  2. Shiny server
  3. RStudio Connect

But before moving into the web based hosting methods, if you are still interested in sharing your Shiny application so that your recipient user can run the application locally, here are few methods that are available at your disposal depending on your need.

I will now be going through the above three hosting means in an introductory level and provide basic guidelines as to how a shiny application hosting can be done on each.

  1. Shinyapps.io

Shinyapps.io is a platform as a service (PaaS) provided by RStudio for hosting Shiny applications. This is an alternative any Shiny developer can take if he/she wants to deploy the application to the web but does not have enough resources and capability to maintain an own server. This method is fairly straightforward and the publishing of a developed application is convenient. This task does not require any heavy hardware installations or a separate functional process at all. The hosting of the application on Shinyapps.io is as simple as a push of a button or one line of R code.

Let me show you how its done with a sample Shiny apps

To deploy your application on Shinyapps.io you first need to have the following two components:

  1. R development environment such as RStudio IDE
  2. The latest version of the rsconnect package

We all know that to develop the Shiny application, the R development environment should already be there. So number one is ticked. The next thing you need is othe rsconnect package which deploys Shiny applications to the shinyapps.io service. To install rsconnect on the R environment simply run the following code:

install.packages(‘rsconnect’)

After the installation, like any other package, load the library into the R Session by running:

library(rsconnect)

Well to deploy an application on Shinyapps.io, you need to have an account registered on this service. I have provided the official user guide link to creating and verifying your own Shinyapps.io account here.

Now that you have created the account on Shinyaps.io, lets host the application there shall we?

To host the built Shiny application, the deployApp function from the rsconnect package will be used.

To host the application simply type deployApp() on the console. If you are using an IDE such as RStudio, clicking the publish button will deploy the application on Shinyapps.io service while opening the application for the developer to view.

Shinyappsio Publish Button

Once the deployment is done, the browser will open up and navigate to the newly deployed application.

Wondering Why it is that simple?

Well that is mainly because this is a free hosting opportunity brought to Shiny developers by RStudio where they allow us to host our applications on their servers FOR FREE.

But FREE DOES NOT MEAN ENTIRELY FREE

Alt Text

This is a free service provided by RStudio and that comes with its own bottlenecks. I myself wanted to try this service but due to the heavy load of data that are being pulled in by the API calls, the application is computing heavy. In such scenarios, the hosted application does not function as expected and the only way around this would be to purchase extra memory or upgrade to n elevated account.

But that in mind, it should be mentioned that this method is all the more convenient if the application to be hosted is simple and light weight.

Now lets look into the next method…

  1. Shiny server

Now imagine you want to have more control over the data and the outputs generated by you application and you are not entirely confortable with letting RStudio hosting and keeping a copy of your data on their servers…

Then the above method of using Shinyapps.io might not be the way forward since this method requires your code and data to be copied to RStudio servers since this service is hosted by RStudio itself.

This is where the option of using your own RServers comes into play.

Shiny Server is a program that runs in the back end which builds a web server designated to host Shiny applications. With Shiny Server the developers are given the ability to host the developed applications in a controlled environment, such as within an organization. This way, the data and the other confidential information is never delivered to the hands of a third party and thus the privacy is secured.

The convenience in using Shiny server is that it will host each application in its siloed and individual web address and instantaneously execute and “up” the application when a certain user visits the pointed URL of the hosted application.

The Shiny server method of hosting comes with two editions of its own. Simply said the free and open source version known as Shiny server and the paid version known as Shiny server pro

Shiny Server Professional offers the following features on top of the open source Shiny Server including:

If you are interested in understanding a complete and in detail breakdown of the features delivered by the methods we discussed so far for hosting a Shiny application, namely the Shinyapps.io, Shiny server (open source edition) and the Shiny server pro, visit this link here.

Now that I have detailed in brief different methods to deploy/host Shiny applications, the specificity of the business use case shall dicate the method which is used.

Till we meet again, happy and Shiny coding folks…!!!

Congratulations! You’ve deployed your first Shiny application…!!!

Alt Text