Shiny app takes long time to load - using shiny server on Digital Ocean

679 views
Skip to first unread message

dhin...@djhindley.com

unread,
Sep 10, 2017, 6:25:02 AM9/10/17
to Shiny - Web Framework for R
Hi - I have written a shiny application that is stored on a Digital Ocean cloud server (hence it uses shiny server). The application has several menus, using shinydashboard, and many other specialist R packages that are loaded using library.  Each time the application is loaded it takes c15s to load - does anyone know of a good best practice guide to using shiny server, in order to speed up the application time?  The Digital Ocean droplet has 1GB memory and 20GB Hard Disk.

Thanks

David.

Erik Westlund

unread,
Sep 10, 2017, 7:34:38 AM9/10/17
to dhin...@djhindley.com, Shiny - Web Framework for R
Ssh in

Apt install htop

Then load the app with htop open in the terminal

Watch the memory bar. Does it fill up? How big is the dataset it loads in memory?

Possibly you're running out of memory and it's swapping and causing the slow down. You may need a bigger droplet.

How long does it take to load on your dev machine?


From: shiny-...@googlegroups.com <shiny-...@googlegroups.com> on behalf of dhin...@djhindley.com <dhin...@djhindley.com>
Sent: Sunday, September 10, 2017 5:25:02 AM
To: Shiny - Web Framework for R
Subject: Shiny app takes long time to load - using shiny server on Digital Ocean
 
Hi - I have written a shiny application that is stored on a Digital Ocean cloud server (hence it uses shiny server). The application has several menus, using shinydashboard, and many other specialist R packages that are loaded using library.  Each time the application is loaded it takes c15s to load - does anyone know of a good best practice guide to using shiny server, in order to speed up the application time?  The Digital Ocean droplet has 1GB memory and 20GB Hard Disk.

Thanks

David.

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/4f133ac1-2d22-4cf7-8cf7-7d0e33378b7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dhin...@djhindley.com

unread,
Sep 10, 2017, 10:42:28 AM9/10/17
to Shiny - Web Framework for R
Thanks for the reply.  It takes about 5s to load from Rstudio on my local PC.  I installed htop and the CPU% was near 100% and the memory got up to c33%.  Both then went quickly down, after the app had loaded, although an entry for shiny is still on the list with 33%. How do I interpret these readings please?

Thanks.

Erik Westlund

unread,
Sep 10, 2017, 10:05:10 PM9/10/17
to dhin...@djhindley.com, Shiny - Web Framework for R
Sounds like it's a CPU limitation if your'e at 100% CPU and the memory is fine.

I'd try seeing what kind of gains you can see with by upgrading your droplet to a high CPU version. You can see if extra cores helps too. 

That will at least tell you if CPU power helps. My experience is the CPUs on these VPSs are pretty good, actually.  But it's worth seeing what improvements you get.

Of course, the optimal thing would be to look for optimizations in your shiny app -- if you can find ways to cache common calculations running on boot, that would be the most optimal thing.

Good luck--Erik

To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/ae1a71b6-7a50-4324-8d4a-a9df88702eb3%40googlegroups.com.

dhin...@djhindley.com

unread,
Sep 15, 2017, 10:56:16 AM9/15/17
to Shiny - Web Framework for R
Some further information on this:

1. If I load the shiny application in a web browser, close it down, then reload the application from the same web browser, it loads much quicker the second time.
2. If I increase the CPU of the DO droplet, the initial load time improves a little, but is still not as fast as the second load time in 1. above, even with a smaller DO droplet.  Hence, I have not increased the CPU size of the droplet.
3. Hence, it seems to be related to some sort of initial variable/package loading that is stored for a short period, making the second load time (as in 1. above) faster.

Does anyone have any ideas how to work out what is making the initial load time slow?

Thanks.

Reply all
Reply to author
Forward
0 new messages