How to talk to R from Node.js?
Asked Answered
K

0

6

I'd like to do intensive, non-interactive calculations/data analysis using R. The analysis requests would be called from a Node.js/Express backend.

The input structure is a JSON of ~100kB and the calculation should run asynchronously, of course. The output data from the data analysis in R is much smaller (~5kB). Binary data formats (e.g. protobuf) could be used as well. There is no visualization involved.

I'm new to R but found a package which leverages ZeroMQ (as client). Already used øMQ in another project => would be my favorite way to communicate, but I'm open to any kind of efficient and stable communication (e.g. Redis).

  • Is it possible to run some kind of R-Server? If yes, does it run nearly as stable as Node.js? (I could use monit to watch and restart a process like I'm doing it with node.)
  • How could I talk from Node.js to R?
  • Does R have to create an expensive new session for each request or reuse existing ones?

Environment: Debian/Ubuntu, available as well: Redis, MongoDB

Keats answered 20/10, 2015 at 13:51 Comment(5)
npmjs.com/package/rstats ; opencpu.org ; rforge.net/RserveYahoo
I currently run a MEAN stack that communicates to an R server with OpenCPU as the middleware. Allows a front end AngularJS that asynchronously works with R in the background. Installing OpenCPU is fairly simply, it does all the hard work for you. opencpu.orgTorrence
Thanks a lot. Sounds really good to me. For my requirements openCPU or RServe look like to be adequate solutions, at least I'll give both a try. I'd up-vote and mark correct if it was an answer :-)Keats
@Keats : 4 years later, I am looking for something similar. Do you mind to share your experience on communication between R server & Node.js? Thank you very much.Athlete
@epsilon91 sorry, I'm far away from this now. We decided a totally different solution and I don't remember any details. Cannot help you.Keats

© 2022 - 2024 — McMap. All rights reserved.