Hi R-helpers Has anyone had any experience doing CGI or Servlets or using an httpd server in R? Context: we are interested in running dynamic demographic calculations on the internet (life tables, and such) in response to form submissions. I might do simple cgi to get started, but loading in data each time seems like it would be quite, quite slow. I have looked at Rserv, but I am most interested in something non-Java (once Sun goes the way of the dinosaurs, so will that silly language -- come on, flame me, I can take it!) If there is a project, I might be able to contribute to it. If there isn't, I might start one.... Thanks! webb
On Wednesday, May 5, 2004, at 18:09 Europe/London, foobar wrote:> Hi R-helpers > > Has anyone had any experience doing CGI or Servlets or using an httpd > server in R? > >yes. See the R FAQ, section 4. (Or maybe you already have, in which case I misunderstood the question...) Best wishes, David
Here's a related question: Do any of the mentioned R-web interfaces (Rweb, R-Online, CGIwithR, RSPerl) support reusing the same R process, eliminating the startup overhead? This would be useful to me as well. Currently I use such a method on my computing cluster: All 40 compute nodes run an R process/compute server that listens at a socket for any connection and subsequent commands from another computer. When the master process disconnects, the R processes go back to listening at the socket. Connecting to the R compute servers this way takes < 2 milliseconds rather than the typical ~2 second R startup time. Thanks for any tips. -Frank -----Original Message----- From: Christian Lederer [mailto:christian.lederer at imse.med.tu-muenchen.de] Sent: Thursday, May 06, 2004 10:04 AM To: r-help at stat.math.ethz.ch Subject: Re: [R] cgi/servlets/httpd in R Hi, if found that the easiest way for me doing CGI with R was using the RSPerl package. So i could do all the CGI related things in Perl and call R functions from Perl to do the statistics. You can get RSPerl from http://www.omegahat.org. If loading the data each time gives a performance problem, i guess that you could use RSPerl together with fastcgi, so the R initialization and loading the data would happen only once. If you try this, i would be very interrested in your experiences. The RSPerl package is somewhat outdated, but it worked well together with R 1.6.0 (i didn't try newer versions). Christian :-) David Firth wrote:> On Wednesday, May 5, 2004, at 18:09 Europe/London, foobar wrote: > >> Hi R-helpers >> >> Has anyone had any experience doing CGI or Servlets or using an httpd >> server in R? >> >> > > yes. See the R FAQ, section 4. (Or maybe you already have, in which > case I misunderstood the question...) > > Best wishes, > David > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Samuelson, Frank* wrote:> Currently I use such a method on my computing cluster: All 40 > compute nodes run an R process/compute server that listens at a socket for > any > connection and subsequent commands from another computer. > When the master process disconnects, the R processes go back to listening > at the socket. Connecting to the R compute servers this way > takes < 2 milliseconds rather than the typical ~2 second R startup time.Your solution seems what I am looking for, actually. Questions: 1. How do you communicate with an R process? I can only think of embedded code like SQL in Perl. 2. How do you find an R node that is open? 2.5 You are haveing cgi scripts connect to the R processes, right? Or are the R processes available for another purpose? 3. How much of your code are you willing to share :)? We are interested in making demographic analysis tools available online (life-table-ish stuff to start with, then as much as we can get grant money for). W
wwsprague at ucdavis.edu wrote:> Your solution seems what I am looking for, actually. Questions:FWIW, another possible option if your data is stored in an RDBMS is Postgres with PL/R; see: http://www.joeconway.com/plr/ As of Postgres 7.4 you can preload and initialize libraries at postmaster start, which means that each forked database backend includes a fully initialized copy of libR. If you are interested, there is some information available regarding how to use this with PHP to generate online charts here: http://www.joeconway.com/oscon-pres-2003-1.pdf HTH, Joe
Actually, what I have is probably not what you want, and I wrote it as an example of what I was looking for, and what is probably possible. My code is just a hack of the snow socket code. To answer your questions: 1. The communication is done by serializing R objects. That is, the process connecting to the R compute nodes is an R process as well. Not helpful in this situation. 2. Again, not what you want. In the cluster every node has 1 R job, and all get connected simultaneously until they're done computing, then released simultaneously. 2.5 No, see 1. 3. You may have the code if you want, but like I said, you probably don't. These recent posts gave some good information though: https://www.stat.math.ethz.ch/pipermail/r-help/2004-May/049239.html https://www.stat.math.ethz.ch/pipermail/r-help/2004-May/049321.html I think RZope/RSOAP and/or Rserve may be what we're looking for. They're not on CRAN and weren't listed in the faq. -Frank -----Original Message----- From: wwsprague at ucdavis.edu [mailto:wwsprague at ucdavis.edu] Sent: Friday, May 07, 2004 12:50 PM To: Samuelson, Frank* Subject: Re: [R] cgi/servlets/httpd in R Samuelson, Frank* wrote:> Currently I use such a method on my computing cluster: All 40 > compute nodes run an R process/compute server that listens at a socket for > any > connection and subsequent commands from another computer. > When the master process disconnects, the R processes go back to listening > at the socket. Connecting to the R compute servers this way > takes < 2 milliseconds rather than the typical ~2 second R startup time.Your solution seems what I am looking for, actually. Questions: 1. How do you communicate with an R process? I can only think of embedded code like SQL in Perl. 2. How do you find an R node that is open? 2.5 You are haveing cgi scripts connect to the R processes, right? Or are the R processes available for another purpose? 3. How much of your code are you willing to share :)? We are interested in making demographic analysis tools available online (life-table-ish stuff to start with, then as much as we can get grant money for). W