Rserve - Binary R server


About Rserve
GIT access
Technical Info
Check results
Package R docs

About Rserve
What is Rserve?

Rserve is a TCP/IP server which allows other programs to use facilities of R (see from various languages without the need to initialize R or link against R library. Every connection has a separate workspace and working directory. Client-side implementations are available for popular languages such as C/C++, PHP and Java. Rserve supports remote connection, authentication and file transfer. Typical use is to integrate R backend for computation of statstical models, plots etc. in other applications.

The following Java code illustrates the easy integration of Rserve:

RConnection c = new RConnection();
double d[] = c.eval("rnorm(10)").asDoubles();

d now contains 10 random samples from the N(0,1) distribution if there is a runing Rserve on the local machine. The RConnection doesn't have to be created more than once for subsequent commands (however, each thread must have its own connection object unless synchronized explicitly).

As a side note - if you are looking just for a way to access R from Java in one application without the need for the client/server concept, you may want to have a look at JRI. It uses JNI to link R directly into Java.

The original Rserve paper is available in the DSC-2003 proceedings. Please cite that paper when using Rserve.

NOTE: Rserve is perfect as a back-end for web services and is often used that way. See also FastRWeb.

Tell us about your project!
Some projects using Rserve:
The Dataverse Network ProjectPhenyx"J" interface
Nexus BPMTavernaBio7
If you are using Rserve, please let us know! Please send me an e-mail if your project uses Rserve! Thanks!
What's new?
    --- The latest Rserve version available from RForge is Rserve_1.8-6 ---
2015/12/23Rserve 1.8-4 bugfix release (affects proxy and compute-separation mode only).
2015/07/20Rserve 1.8-3 release. Added support for Rserve I/O context and new WebSocket/QAP tunnel proxy with extended static content support (supportes conditional GETs and serving compressed content).
2015/05/20Rserve 1.8-2 bugfix release (only affects WebSocket implementation)
2015/04/08Rserve 1.8-1 released on Added ulog support in R, "fork here" for spawning multiple servers and console input OOB support.
2014/09/03Rserve 1.8-0 released on We are currently restricting the 1.8 series to RForge releases (i.e., CRAN still has 1.7) because some applications may rely on control commands which are currently unsupported in the 1.8 series due to a large overhaul of the communication between the master server and the sessions. All other features are considered stable in the 1.8 series. If you don't require control commands (or don't know what it is) then we strongly recommend installing the latest 1.8 version.
2013/08/21Rserve 1.7-3 released. This relase now restores Windows support (thanks to David Champagne from Revolution Analytics!), it allows HTTPS to WebSockets/TLS upgrade (on unix) and cleans up configuration of the various new possible server configurations.
2013/08/12Rserve 1.7-2 released. New keep.alive option and bugfixes
2013/07/02Rserve 1.7-1 is now officially on CRAN. Please see the NEWS for the long list of new features in the new 1.x series. Note that the old Java client has been removed entirely and the REngine-based client now ships in the src/clients/java directory of the source package and the JAR files are even installed in the java directory of the resulting package installation.
Also note that the source repository is now hosted on GitHub - builds and everything else is still performed by
2012/12/10Rserve 1.7-0 is the latest version of Rserve with many new features. Please give it a go - we think it's stable enough. The only reason why it has not been officially released yet is that it currently doesn't support Windows (because many of the new features rely on things lacking in Windows). However, given that it is much more sensible to use unix servers for Rserve deployment (Windows' performance is simply too poor for any server deployment) the majority of users should be able to test the new version and give us feedback.

2012/02/20Rserve 0.6-8 released. Added support for self-control commands as well as RSserverEval(), RSserverSource and control version of RSshutdown.
2012/01/22Rserve 0.6-7 released. This is a security update, if you rely on the built-in authentication, make sure you update at least to this version!
2011/12/10Rserve 0.6-6 released (bugfixes and added support for assigning pure S4 objects)
2011/06/21Rserve 0.6-5 released (Windows-specific updates, use install.libs.R from R 2.13.1 on)
2011/05/19Rserve 0.6-4 released (bugfixes, 64-bit buffer support, changes in Rserve() wrapper)
2011/01/17Rserve 0.6-3 released (added multi-arch support for Windows; update C++ client; one unix bug fix)
2010/09/02Rserve 0.6-2 released (added support for NAs in character vectors; added interactive option - on by default on all platforms; Windows fixes)
2010/05/24Rserve 0.6-1 released (added su and cachepwd config options; added Win64 support; few bugfixes)
2009/10/27Rserve 0.6-0 released (added the concept of control commands aka server-side commands; few bugfixes)
2009/01/25Rserve 0.5-3 released (added string encoding support, allow S3 objects to be synthesized on the client side, added tests, minor fixes)
2008/10/17Rserve 0.5-2 released (fixed bug in readFile and setBufferSize; updated Java client)
2008/07/22Rserve 0.5-1 released (fixes build issues with R 2.7 on Windows and multi-arch install)
2008/07/21Rserve 0.5-0 was released on CRAN. This is a new, major release of Rserve which requires updated client support, because the protocol was substantially changed. It also features a new, efficient R client. Note that the old Java API (JRclient) will no longer be activaley maintained and projects are encouraged to use the new Java API (REngine). This version was in RC stage for quite a long while so hopefully most project switched already. (0.4 versions are still available from RForge for legacy projects, but not from CRAN)
2007/03/15Rserve and its documentation have now officially moved to RForge.
2006/11/15Rserve is now available as a package from CRAN. This also implies that the latest binary versions (both for Windows and Mac OS X) are now available from CRAN. Simply use install.packages("Rserve").
2006/05/03Rserve_0.4-3 released including Windows binary for R 2.3.0. The new 0.4 series supports sessions, i.e. the client can detach from the server and attach to the same session later on (e.g. when the computation has finished). The corresponding new client is now available for download. Also the C++ client has been extended to support authentication and file transfer.
2005/01/12Rserve_0.3-16 released. It allows custom initialization such that you can pre-load data and libraries, allowing even faster responses for specific tasks.
2003/10/08Rserve_0.3-0 and updated Java client released (clients update necessary). Updated FAQ. Updated Windows binary. This version adds support for large data - if you experienced crashes while fetching large data in 0.2 and earlier, use this version instead.
Features of Rserve
  • fast - no initialization of R is necessary
  • binary transport - the transport protocol sends R objects as binary data, not just R text output.
  • automatic type conversion - most R data types are converted into native data types, e.g. the result of rnorm(10) will be double[10] in C/Java. Java client also provides classes for new R types such as RBool, RList etc.
  • persistent - each connection has its own namespace and working directory. Every object you create is persistent until the connection is closed. The client doesn't have to fetch or store intermediate results.
  • client independence - since the client is not linked to R there are no threading issues like in RSJava etc.
  • security - Rserve provides some basic security by supporting encrypted user/password authentication with server challenge. Rserve can be also configured to accept local connections only.
  • file transfer - the Rserve protocol allows to transfer files between the client and the server. This way Rserve can be used as a remote server even for task such as generating plot images etc.
  • configurable - one configuration file is used to control settings and to enable/disable features such as authorization, remote access or file transfer.
What Rserve is NOT
  • Rserve provides no callback functionality. Your application could implement callbacks via TCP/IP and the R sockets but it is not a part of Rserve.
    (Note: callbacks are now supported using OOB commands in OCAP mode)
  • Rserve is not a telnet frontend to R. The printed output is not transported (except via capture.output). Rserve uses binary protocol for transport of objects for better speed.
    (Note: in OCAP mode console I/O is now supported)
  • Rserve is thread safe across connections, but eval methods are not thread safe within one connection. This means that multiple threads should not use the same connection unless they guarantee that no eval calls are run in parallel.

You can read more about the Rserve in the documentation section. Once you read at least the introduction, you can go to the download section to get the necessary files.

Rserve was developed by Simon Urbanek, but anyone interested is welcome to check out the developer section and contribute to the project. The sources are licensed under GPL.