Persistent R sessions in Shiny Server?

2,650 views
Skip to first unread message

Jules

unread,
Jun 16, 2013, 5:31:00 PM6/16/13
to shiny-...@googlegroups.com
Hi,

I've installed shiny-server (using Ubuntu13.04) and have been testing out some new applications I've developed via remote browser. I noticed that after multiple access, the computer started to work much slower, even freeze, requiring a re-boot. Eventually, I discovered that the system memory was gradually being consumed by multiple R-sessions that were launched during the initialization of each shiny app, and persist after the access to that app has been disconnected (at least remotely via the browser).  With multiple access, I can end up with dozens of sleeping R processes. Is this expected behaviour? 


Thanks!

Jules

unread,
Jun 19, 2013, 11:37:28 PM6/19/13
to shiny-...@googlegroups.com
Here's some additional detail: the multiple sleeping R processes are all pointing to

/usr/lib/R/bin/exec/R --no-save --slave -f /usr/local/lib/node_modules/shiny-server/R/SockJSAdapter.R

depending on which app was run, each process is consuming from 50-70mb of memory.At this point, the only way I can see to recover the memory is to manually kill the processes. 

Any thoughts or suggestions?

Thanks!

Joe Cheng

unread,
Jun 20, 2013, 3:35:19 PM6/20/13
to shiny-...@googlegroups.com
That shouldn't be; the processes should be terminated after the browser window closes. Can you set the environment variable SHINY_LOG_LEVEL=TRACE and then restart shiny-server? Then it'll output plenty of diagnostics to show whether it's attempting to kill these processes.


--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jules

unread,
Jun 21, 2013, 1:31:49 AM6/21/13
to shiny-...@googlegroups.com
Joe,

Thanks for the reply. After setting the environmental variable as you suggested, I looked for application log files in the /var/shiny-server/log directory to further investigate. As a simple example, I launched the 01_hello app, and initially found the following test in the associated log file: Listening on port 38345
Next, I closed the browser window, and the log file disappeared from the log directory!

Can you tell what I'm doing wrong here? I'm not having much luck getting to the root cause of my problem, as the log files are being deleted before I can read them once I close the browser window. As a possible clue, I went back to my first install in an RHEL linux install, and there doesn't appear to be this problem. So it appears to be Ubuntu-specific...

Thanks!

Joe Cheng

unread,
Jun 21, 2013, 1:55:08 AM6/21/13
to shiny-...@googlegroups.com
The log files deleting themselves is expected; we do that when we detect the R process exiting normally after we asked nicely, so we don't fill up the hard drive with log files that don't tell us anything interesting.

Our servers are all Ubuntu as well, and I'm running Ubuntu 13.04. I don't see this problem normally but there have been times when we've had extra R processes hanging around seemingly forever, so I don't doubt what you're seeing. Can you try killing all the processes, and then deploying the simplest possible R app (like hello shiny) and see if the problem reproduces with that?

Jules

unread,
Jun 21, 2013, 2:36:01 PM6/21/13
to shiny-...@googlegroups.com
Joe,

Thanks again.

OK, so here's what I did:

1) To make sure that there's no "legacy configuration" issues, I started with a fresh install of Ubuntu13.04
2) Install R, shiny, nodejs and shiny-serve according to install procedures on shiny-server website
3) copy examples folder to shiny-server/www folder
4) launch shiny server
5) successively run and close several of the applications in the examples folder
6) in xterm, type: ps aux  so as to see the details of all processes running.

As you continue to run and then close the browser windows, I'm seeing (via ps aux)  that there's a growing list of shiny processes persisting. Closing the browser or shutting down shiny-server has no effect---the only way to stop the multiple shiny processes is to manually kill them.

Is this what you are seeing as well?

Thanks!

Joe Cheng

unread,
Jun 21, 2013, 11:03:14 PM6/21/13
to shiny-...@googlegroups.com
I'll follow up with you off the list. 
Sent from my phone

Sarven Capadisli

unread,
Jul 12, 2013, 4:37:34 AM7/12/13
to shiny-...@googlegroups.com
I'm experiencing this issue as well. Care to share a solution?

I've also tested with Upstart, in case the service wasn't killed
properly with sudo shiny-server alone. I see a dangling process for each
service which was started, even if I close the browser for extra measure
e.g.,

/usr/lib/R/bin/exec/R --no-save --slave -f
/usr/lib/node_modules/shiny-server/R/SockJSAdapter.R

-Sarven
> <http://rstudio.github.io/shiny/tutorial/#hello-shiny>) and see
> /usr/local/lib/node_modules/__sh__iny-server/R/SockJSAdapter.R
> shiny-discus...@__googlegroups.__com.
>
> For more options, visit
> https://groups.google.com/__grou__ps/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> 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.
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
> --
> 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
> <javascript:_e({}, 'cvml',
> 'shiny-discuss%2Bunsu...@googlegroups.com');>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> Sent from my phone
>

Jeff Allen

unread,
Jul 12, 2013, 11:15:23 AM7/12/13
to shiny-...@googlegroups.com
Hi Sarven,

What operating system are you using?

We're aware of a bug in recent Debian systems (Ubuntu 14 included) described here: https://github.com/rstudio/shiny-server/issues/22 . We're working on the fix, but it's going to require a fair amount of work and testing to get it running properly.

Does that sound like it might describe the issue you have?

Jeff
>     'shiny-discuss...@googlegroups.com');>.

Sarven Capadisli

unread,
Jul 12, 2013, 11:35:41 AM7/12/13
to shiny-...@googlegroups.com
Thanks Jeff, that's precisely it. I can confirm this issue on my local
Ubuntu 13.04.

Looking forward to the fix. I'll keep an eye on the Github issue for any
possible tests I can contribute with.

-Sarven
> <https://groups.google.com/__grou__ps/opt_out>
> > <https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>>.
> >
> >
> >
> > --
> > 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 <http://googlegroups.com>.
> > For more options, visit
> > https://groups.google.com/__groups/opt_out
> <https://groups.google.com/__groups/opt_out>
> > <https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>>.
> >
> >
> >
> > --
> > 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 <javascript:>
> > <javascript:_e({}, 'cvml',
> > 'shiny-discuss...@googlegroups.com <javascript:>');>.
> > For more options, visit
> https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
> >
> >
> >
> >
> > --
> > Sent from my phone
> >
> > --
> > 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 <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
> >
> >
>
>
> --
> 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
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages