Slow initial page-load on shiny server with long "Time to first byte"

1,934 views
Skip to first unread message

Morten Joergensen

unread,
Aug 23, 2015, 5:00:30 PM8/23/15
to Shiny - Web Framework for R
Hi

I have the shiny server installed on a VPS and experience a time to first byte (TTFB) well over 1 second when browsing through my installed apps. At refresh on the same app it is quite fast though. I have experienced that if I browse the app from another computer (with another IP address) just before opening it from my main computer it loads faster than without.

Is it only me who experience these long TTFB and what could I do to make it faster?

Hope you can help

Morten

mr.ti...@gmail.com

unread,
Sep 2, 2015, 11:37:10 AM9/2/15
to Shiny - Web Framework for R
I have seen 9 second TTFB on initial load with 274ms on refresh.  Looking for ways to reduce TTFB...

Joe Cheng

unread,
Sep 2, 2015, 12:34:55 PM9/2/15
to mr.ti...@gmail.com, Shiny - Web Framework for R
That's indicative of startup code taking a long time, most likely code in your global.R (if you have one) or in server.R above your server function. Consider what calculations you're doing there, and whether these calculations can be done ahead of time and cached in an .RData or (preferably) .rds file.

If you're finding even simple apps take a long time to start up, then that's not expected and you should definitely let us know.

--
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/217c5570-19b5-4890-90ff-df22645bef36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

T Muir

unread,
Sep 2, 2015, 2:08:35 PM9/2/15
to Shiny - Web Framework for R, mr.ti...@gmail.com
This is the "Welcome to Shiny", "It's Alive" app that draws the 'histogram of x'.  Is there anything I can change in the configuration to speed this up i.e. keep a few R sessions idling?

Morten Joergensen

unread,
Sep 2, 2015, 2:12:10 PM9/2/15
to Shiny - Web Framework for R, mr.ti...@gmail.com
For me the "problem" was a slow initiation of the R process for each app although they are very simple (including the histogram on the front page of the shiny home page). I have set the 
app_idle_timeout
to a couple of days and the apps are loading quite fast now.

The weird thing was that when I browsed the apps alternating they loaded slow but when I installed Varnish (without caching as I set it up wrongly in the first try) it became fast... It still was a slow start though after waiting fore the time to the R process to terminate. Varnish is now (when correctly setup) only giving me 100-200 ms but as long as the R process is running it works great.

Best regards

Morten

Joe Cheng

unread,
Sep 2, 2015, 2:27:59 PM9/2/15
to Morten Joergensen, Shiny - Web Framework for R, mr.ti...@gmail.com
Those are insanely slow times for a simple app, should be sub second times. Is the CPU busy during this time?
--
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.

Morten Joergensen

unread,
Sep 2, 2015, 3:18:37 PM9/2/15
to Shiny - Web Framework for R, morten.joer...@gmail.com, mr.ti...@gmail.com
I have loading times from 2-4 seconds after a shiny-server restart with 30-50% of the CPU used during load

Morten

Joe Cheng

unread,
Sep 2, 2015, 3:20:48 PM9/2/15
to Morten Joergensen, Shiny - Web Framework for R, mr.ti...@gmail.com
What kind of CPU/ram do you have? Anything unusual in your Rprofile.site files?
On Wed, Sep 2, 2015 at 12:18 PM Morten Joergensen <morten.joer...@gmail.com> wrote:
I have loading times from 2-4 seconds after a shiny-server restart with 30-50% of the CPU used during load

Morten

--
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.

T Muir

unread,
Sep 2, 2015, 3:50:50 PM9/2/15
to Shiny - Web Framework for R, morten.joer...@gmail.com, mr.ti...@gmail.com
Nothing out of ordinary in rprofile.site and similar CPU load at below, plenty of RAM.

Morten Joergensen

unread,
Sep 2, 2015, 3:52:10 PM9/2/15
to Shiny - Web Framework for R, morten.joer...@gmail.com, mr.ti...@gmail.com
Well its a 6-bucks-a-month-VPS so it probably hasn't got that much power 512 MB of memory. Maybe that is the problem. I have not edited the Rprofile.site file.

Morten

T Muir

unread,
Sep 4, 2015, 2:00:56 PM9/4/15
to Shiny - Web Framework for R, morten.joer...@gmail.com, mr.ti...@gmail.com
That's not my problem.  I have 128GB RAM and 16 cores.
Reply all
Reply to author
Forward
0 new messages