[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rails: Session and IO

treefrog

7/15/2005 1:02:00 PM

Hi,
I want to use Gnuplot as part of a Rails application to generate data
plots from a large database and filtering software via a web front-end.

The problem is that Gnuplot is fairly slow to start up, but I can't
keep it up via a session variable because IO won't serialize.

Any ideas

regards, treefrog

2 Answers

Daniel Amelang

7/17/2005 3:15:00 AM

0

Well, only you know how slow is too slow, but gnuplot for me has
always been quite fast. Make sure you've come to that conclusion with
adequate evidence.

Have you tried mrplot?

http://rubyforge.org/projec...

Dan


Olaf Klischat

7/18/2005 7:58:00 AM

0

"treefrog" <stephen.hill@motorola.com> writes:

> Hi,
> I want to use Gnuplot as part of a Rails application to generate data
> plots from a large database and filtering software via a web front-end.
>
> The problem is that Gnuplot is fairly slow to start up, but I can't
> keep it up via a session variable because IO won't serialize.
>
> Any ideas

cgi.rb (which Rails is built on) provides different "session storage"
backends; see cgi/session.rb. PStore ((de)serializing to/from files)
is the default in Rails iirc; you'd need MemoryStore, which just puts
the objects in a global hash, which should work with anything,
including open files. I don't know how to set the storage type when
using Rails, but it shouldn't be too hard.

This method has the obvious disadvantage that it'll only work as long
as your web application runs in a single Ruby interpreter, i.e. it
won't scale very well to medium to large sites, where you want to use
things like FastCGI and/or more than one web server to balance the
load. If that is the case, the obvious alternative would be to write a
dedicated "mediator" application that runs and controls gnuplot as a
child process of itself, takes gnuplot commands from your Rails
application(s) over (short-lived) connections (most likely a named
pipe or a network socket). I'm not sure how much overhead there is in
establishing such a connection on every request, but it should be
faste than starting gnuplot each time.