Deploying a Shiny app for production | R bloggers

Deploying a Shiny app for production | R bloggers

[This article was first published on pacha.dev/blog, and kindly contributed to R-bloggers]. (You can report a problem with 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.

If this post is useful to you, I kindly ask for a minimum donation Buy me a coffee. It will be used to continue my Open Source efforts.

You can send me questions for the blog at this form and subscribe to receive an email when there is a new post.

I received this question for the blog:

Hello pacha.dev, it’s a pleasure to meet you. My name is Santiago from Peru. I’ve been following your work since tabulapdf gran paquete, and now with tabler and d3po great things are coming. I looked at the OPEN TRADE STATISTICS dashboard and saw that it is a shiny app. I’d love to know if you have any recommendations on how to host a shiny app for production (shiny.apps.io falls short for production), if you have a preference for AWS or Azure, and if there’s a blog post on that, that would be great. Greetings from Peru.

Thanks, Santiago! Your question is well formulated and specific. I’ll try to honor the effort by providing a helpful answer.

Shinyapps.io is a great service for hosting Shiny apps, but as you said, it has limitations for production use. To be honest, the restrictions only apply to the free tier. Paid plans offer more resources and features, and it’s a great option for paid hosting. I have used it and ot does its job well.

However, Shinyapps.io can be expensive and there are cheaper alternatives if you are willing to manage your own server. I used DigitalOcean for a long time, to the point that I created a variety of R/Shiny images for their marketplace. At some point my account was suspended without explanation, so I’ve tried other providers and I can’t recommend it now.

Currently I use Camera to host my shiny apps. They offer a variety of server configurations at a reasonable price, and their support is good regarding SSH and other remote access methods. With Kamatere, you have to set up the server yourself, including installing R, Shiny Server, and any other dependencies your app requires. This gives you more control over the environment and can be more cost-effective for production use. Please note that I do not have a promotional code and do not receive any fees for recommending Kamatera; I just love their service.

I also used AWS, a robust and scalable option for hosting Shiny apps. AWS offers services like EC2 for virtual servers and they offer a very fast hosting service. However, AWS can be complex to set up and manage, especially for those unfamiliar with cloud services. It can also be more expensive than other options.

Kamatera is simpler. You get access to a regular virtual machine, they offer multiple Linux distributions and Windows, but you need Linux for Shiny Server. After setting up the server (e.g. how much RAM and number of cores), you can install R, Shiny Server and any other necessary packages. You also need to configure security settings such as firewalls and HTTPS certificates.

Today we have a wide range of tutorials on YouTube, which will show you the necessary steps:

  1. Set up an SSH key to securely access the server.
  2. Install R and Shiny Server on the server (same as on your local Linux machine).
  3. Install NGINX or Apache for the web server (I use NGINX).
  4. Configure the firewall to allow traffic on the necessary ports (443 for HTTPS, 3838 for Shiny, 22 for SSH etc.)
  5. Install all required R packages for your Shiny app.

To simplify step 5, I really recommend it golem to design your app as an R package, which will greatly simplify deployment and dependency management. I have two videos explaining the basics of Golem: part 1 And part 2.

These general steps do not include configuring an SQL database, internal API, or configurations to connect to a third-party API. These are steps in addition to setting up a domain name and HTTPS certificates, which are also important for production use. Several blogs explain how you can use Let’s Encrypt to obtain free SSL certificates and configure them with NGINX or Apache to securely control your app from a website such as https://santiago-shinyapp.com.

I hope this helps you get started hosting your Shiny app for production use!

Now the shameless self-promotion part: you can hire me to configure a server for your project. You can contact me at Fiverr.


#Deploying #Shiny #app #production #bloggers

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *