shiny-server, multiple users and heavy computations

6,260 views
Skip to first unread message

Daniel Bowen

unread,
Aug 2, 2013, 3:00:27 PM8/2/13
to shiny-...@googlegroups.com
Hello again.

I am building tools that will be made public to many users. Let's say one of these tools provides an interface for a user to execute computations that takes R ~15-30 seconds to complete. If, say, 10 users all hit Go at about the same time in this proposed tool, is the 10th user going to wait ~150-300 seconds to get his/her results?

I can further-clarify my question if necessary. Basically, I am wondering if the computations will stack, or if shiny-server runs them independent of one another (in parallel).

Thanks again for this wonderful R library!

PS if they do stack, this becomes quite a large limitation... and my question becomes: "... is the only way around this to implement large-scale parallel processing R libraries? ... i.e., Rmpi

Joe Cheng

unread,
Aug 2, 2013, 5:38:57 PM8/2/13
to shiny-...@googlegroups.com
For each Shiny R process, the computations stack as you describe--this is an inevitable consequence of R being single-threaded. 

The open source version of Shiny Server launches a single R process per app. The commercial version will allow you to configure multiple R processes per app; you could configure it to launch a new R process for each user if you wanted. 
--
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.
 
 


--
Sent from my phone

Daniel Bowen

unread,
Aug 3, 2013, 2:02:27 PM8/3/13
to shiny-...@googlegroups.com
thank you. I has suspected this was the case.

On another note, the apps given in the "More Examples" section of http://www.rstudio.com/shiny/ do not seem to be working properly. The stocks one requires the "zoo" package. The other two return: not compatible with INTSXP

again, thank you for this development. I can't wait to see the commercial version of shiny-server.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joe Cheng

unread,
Aug 3, 2013, 4:06:17 PM8/3/13
to shiny-...@googlegroups.com
Thanks for the heads up! Examples should be fixed now. 
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.
 
 

Sainath Adapa

unread,
Aug 6, 2013, 10:56:22 PM8/6/13
to shiny-...@googlegroups.com
if i have two apps like this example.com/app1 , example.com/app2, does the shiny server launch a R process for each app? If so, then if a person X uses app1 and person Y uses app2, the computations donot stack, is this thought process correct?
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jeff Allen

unread,
Aug 7, 2013, 9:10:56 AM8/7/13
to shiny-...@googlegroups.com
That's correct. If you're using Shiny Server, then each application is assigned its own R process, so having one user on each app would not stack, but would run independently.

Huidong TIAN

unread,
Mar 12, 2014, 10:58:38 AM3/12/14
to shiny-...@googlegroups.com
What if the server has only one CPU? One application may have used all CPU space, then the second application must wait, right?

Jeff Allen

unread,
Mar 12, 2014, 11:01:18 AM3/12/14
to shiny-...@googlegroups.com
Sort of. Modern CPUs will interweave processes that are both fighting for attention. So if you ran two intensive R processes on a single-CPU machine, they would both just run at ~50% performance but they would run simultaneously.

Jeff

Huidong TIAN

unread,
Mar 12, 2014, 3:53:39 PM3/12/14
to shiny-...@googlegroups.com
If a shiny application conducts some kinds of model fitting, which generally will take 50 seconds to finish (CPU runs 100%) and a commercial version of Shiny-server has 10-concurrents. Now 10 users request the shiny-server at same time, will each user need 500 seconds to get the result? What if the server has 2 CPUs? will each user need 250 seconds to get the result?

Huidong TIAN

unread,
Mar 12, 2014, 4:01:36 PM3/12/14
to shiny-...@googlegroups.com
For a single-CPU server, does it short calculation time by launching a new R process? The new launched process also need to share the same CPU. 
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jeff Allen

unread,
Mar 12, 2014, 4:06:49 PM3/12/14
to shiny-...@googlegroups.com
That sounds right, but just to be clear...

Shiny Server Open Source
You can only run one process per application, and R processes are single-threaded, meaning they can only do one thing at a time. So if an R operation takes 50 seconds, and you have multiple users hit your application at the same time, the first one will wait 50 seconds for their analysis to complete, the second one will wait 100 seconds (50s for the original user's computation + 50s for their own). So the last user would be waiting 500 seconds.

Shiny Server Pro
Shiny Server Pro is able to run multiple processes per application. So it can use all the cores available on your server. If you configured Shiny Server Pro to run one process per connection, and you had 10 people hit your application at once, Shiny Server Pro would spawn 10 different process, one for each user. If you had 10 cores on your server, these would all run in separate cores and each user would have their results in 50 seconds.

However, if you were running on a machine that only had one processor, then these 10 processes would all be fighting for resources. So yes, I would expect that it would take ~500 seconds for all the computation to finish. Or with two cores, it would take about 250s. Pro does allow you to control how many processes you want to spawn for any given application, so I would recommend that you aim not to spawn too many more active processes than you have cores.

Jeff

Huidong TIAN

unread,
Mar 13, 2014, 3:29:17 AM3/13/14
to shiny-...@googlegroups.com
Thanks! I feel much clear now. So, if my server has four cores, then I don't need to buy the 100 concurrents Shiny-server Pro, the 10-concurrents is enough. And for Open source version Shiny-server, can we use parallel packages to overtake its shortcoming? Suppose we have a task need 40 seconds on 4-core CUP, if we run parallel algorithm, then we need only 10 seconds (maybe a little more). If 10 users are using the application at same time, the first one take around 10 seconds, the second one need 20 seconds, and the last one take around 100 seconds, right? But for the commercial version, using the non-parallel algorithm, the first four users will need 40 seconds, and the last 2 users will need to wait 120 seconds, if use the parallel version algorithm, all of them will need 100 seconds to get their result, am I right? 

Jeff Allen

unread,
Mar 13, 2014, 11:33:57 AM3/13/14
to Huidong TIAN, shiny-...@googlegroups.com
I think so.

Keep in mind that not all algorithms can be parallelized, so this won't hold true for all applications. And also bear in mind that our experience has been that most of the "concurrent connections" are just sitting idle. So we can support hundreds of concurrent connections on ~10-12 cores -- it just totally depends on the applications you're running.

Good luck!
Jeff

Thursday, March 13, 2014 2:29 AM
Thanks! I feel much clear now. So, if my server has four cores, then I don't need to buy the 100 concurrents Shiny-server Pro, the 10-concurrents is enough. And for Open source version Shiny-server, can we use parallel packages to overtake its shortcoming? Suppose we have a task need 40 seconds on 4-core CUP, if we run parallel algorithm, then we need only 10 seconds (maybe a little more). If 10 users are using the application at same time, the first one take around 10 seconds, the second one need 20 seconds, and the last one take around 100 seconds, right? But for the commercial version, using the non-parallel algorithm, the first four users will need 40 seconds, and the last 2 users will need to wait 120 seconds, if use the parallel version algorithm, all of them will need 100 seconds to get their result, am I right? 

On Wednesday, March 12, 2014 9:06:49 PM UTC+1, Jeff Allen wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/E75Yv-kKG3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, March 12, 2014 3:06 PM
That sounds right, but just to be clear...

Shiny Server Open Source
You can only run one process per application, and R processes are single-threaded, meaning they can only do one thing at a time. So if an R operation takes 50 seconds, and you have multiple users hit your application at the same time, the first one will wait 50 seconds for their analysis to complete, the second one will wait 100 seconds (50s for the original user's computation + 50s for their own). So the last user would be waiting 500 seconds.

Shiny Server Pro
Shiny Server Pro is able to run multiple processes per application. So it can use all the cores available on your server. If you configured Shiny Server Pro to run one process per connection, and you had 10 people hit your application at once, Shiny Server Pro would spawn 10 different process, one for each user. If you had 10 cores on your server, these would all run in separate cores and each user would have their results in 50 seconds.

However, if you were running on a machine that only had one processor, then these 10 processes would all be fighting for resources. So yes, I would expect that it would take ~500 seconds for all the computation to finish. Or with two cores, it would take about 250s. Pro does allow you to control how many processes you want to spawn for any given application, so I would recommend that you aim not to spawn too many more active processes than you have cores.

Jeff


On Wednesday, March 12, 2014 2:53:39 PM UTC-5, Huidong TIAN wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/E75Yv-kKG3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, March 12, 2014 2:53 PM
If a shiny application conducts some kinds of model fitting, which generally will take 50 seconds to finish (CPU runs 100%) and a commercial version of Shiny-server has 10-concurrents. Now 10 users request the shiny-server at same time, will each user need 500 seconds to get the result? What if the server has 2 CPUs? will each user need 250 seconds to get the result?

On Wednesday, March 12, 2014 4:01:18 PM UTC+1, Jeff Allen wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/E75Yv-kKG3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, March 12, 2014 10:01 AM
Sort of. Modern CPUs will interweave processes that are both fighting for attention. So if you ran two intensive R processes on a single-CPU machine, they would both just run at ~50% performance but they would run simultaneously.

Jeff

On Wednesday, March 12, 2014 9:58:38 AM UTC-5, Huidong TIAN wrote:
--
You received this message because you are subscribed to a topic in the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/shiny-discuss/E75Yv-kKG3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, March 12, 2014 9:58 AM

Huidong TIAN

unread,
Mar 13, 2014, 2:39:21 PM3/13/14
to shiny-...@googlegroups.com
Thank you a lot! One more question: I have two apps, say app1 & app2, each need 10 seconds to run some model fitting, and a 4-core CPU server. Now two users access the two apps separately at the same time, will they all need 10 seconds to get the result, or one need 10 and the other need 20 seconds?

Best!

Reply all
Reply to author
Forward
0 new messages