Rserve - Multiple instances on one server?
Asked Answered
P

2

4

Is it possible to run multiple instances of Rserve on one server at the same time?

For example 10 instances meaning 10 separate R workspaces listening on different ports via Rserve on the same machine?

Pietrek answered 5/2, 2014 at 14:57 Comment(0)
I
3

Answer is yes, if it is Unix/Linux. Answer is no, if it is Windows. More can be found here http://www.ci.tuwien.ac.at/Conferences/DSC-2003/Proceedings/Urbanek.pdf, page 2 says it explicitly.

Intemperance answered 5/2, 2014 at 15:11 Comment(2)
Suppose I have an R session running on the web and in that session I have a dataframe "sample_data". Now I want to call another function in a new browser window which will transform a particular variable in the 'sample_data' into a new variable.My question is how will I retain 'sample_data' so that it can be used in a new R session ? I am using RserveZoroaster
This answer is wrong. On both Windows and Linux, you can have multiple Rserve processes listening on different ports, which was asked by the OP. However, only on Linux, you can have multiple connections running simultaneously on one Rserve listener. On Linux it will fork a sub process for each connection. This is more convenient than having Rserve listening on multiple ports.Slosh
T
7

In the same document specified by @Oleksandr, it clearly states on page 5-6, that in Windows, there is an alternative solution:

Don't run 1 Rserve process, but start multiple Rserve processes, each on a different port (which can be easily specified in the rserve command). Each Rserve process has its own environement. Connect 1 thread of your application with 1 unique Rserve connection: Then you can exploit parallellism from within your application.

So the answer to your question is: Yes, you can.

I've tested this with a C# application, and it works. You can use libraries like this: https://github.com/kent37/RserveCLI2

EDIT August 4 2015: We are now effectively using this in a (windows) production application, namely calling the R code from a C# codebase do to the statistical analysis. We use RServe and RServeCLI for connecting and communication between the 2 codebases. To implement this in a structured manner, we used this pattern for pooled resources. Hope this helps.

Turpentine answered 17/11, 2014 at 9:6 Comment(0)
I
3

Answer is yes, if it is Unix/Linux. Answer is no, if it is Windows. More can be found here http://www.ci.tuwien.ac.at/Conferences/DSC-2003/Proceedings/Urbanek.pdf, page 2 says it explicitly.

Intemperance answered 5/2, 2014 at 15:11 Comment(2)
Suppose I have an R session running on the web and in that session I have a dataframe "sample_data". Now I want to call another function in a new browser window which will transform a particular variable in the 'sample_data' into a new variable.My question is how will I retain 'sample_data' so that it can be used in a new R session ? I am using RserveZoroaster
This answer is wrong. On both Windows and Linux, you can have multiple Rserve processes listening on different ports, which was asked by the OP. However, only on Linux, you can have multiple connections running simultaneously on one Rserve listener. On Linux it will fork a sub process for each connection. This is more convenient than having Rserve listening on multiple ports.Slosh

© 2022 - 2024 — McMap. All rights reserved.