Rails: Session and IO

Discussion in 'Ruby' started by treefrog, Jul 15, 2005.

  1. treefrog

    treefrog Guest

    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
    treefrog, Jul 15, 2005
    #1
    1. Advertising

  2. 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/projects/mrplot/

    Dan
    Daniel Amelang, Jul 17, 2005
    #2
    1. Advertising

  3. "treefrog" <> 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.
    Olaf Klischat, Jul 18, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9iSEs=?=
    Replies:
    4
    Views:
    5,267
    =?Utf-8?B?Um9iSEs=?=
    Apr 11, 2007
  2. basi
    Replies:
    4
    Views:
    104
  3. Josef 'Jupp' SCHUGT
    Replies:
    5
    Views:
    174
    Stephan Kämper
    Jan 24, 2006
  4. erhan
    Replies:
    0
    Views:
    144
    erhan
    Jun 30, 2006
  5. Replies:
    2
    Views:
    110
Loading...

Share This Page