I’d like to migrate an old Apache/PHP/Perl application to Ruby, and
I do have some question:
PHP supports persistent MySQL connections, so it does not need
to reopen the connection for every single Web access.
Is there a way to do this in Ruby?
Apache maintains several processes, and subsequent requests
are handled by different processes. An efficient way for
interprocess-Communication is required.
Perl has a module which allows to put a Hash into a shared
memory segment.
The best way that I know of accomplishing all the things you just
described is Apache with Ruby and mod_fastcgi. The fcgi ruby module is
designed so that you write your script to loop over a series of HTTP
requests while everything stays in memory. This means that the database
connection you open at the beginning stays in memory and is accessible
to all of your requests and that memory sharing is just built in.
Here is a page with more information:
Carl Youngblood
Hadmut Danisch wrote:
···
Hi,
I’d like to migrate an old Apache/PHP/Perl application to Ruby, and
I do have some question:
PHP supports persistent MySQL connections, so it does not need
to reopen the connection for every single Web access.
Is there a way to do this in Ruby?
Apache maintains several processes, and subsequent requests
are handled by different processes. An efficient way for
interprocess-Communication is required.
Perl has a module which allows to put a Hash into a shared
memory segment.
The best way that I know of accomplishing all the things you just
described is Apache with Ruby and mod_fastcgi. The fcgi ruby module is
designed so that you write your script to loop over a series of HTTP
requests while everything stays in memory. This means that the database
connection you open at the beginning stays in memory and is accessible
to all of your requests and that memory sharing is just built in.
Yup, thanks for the hint, that’s exactly what I was looking for.
I still have a slight problem with the current fcgi library and ruby1.8:
The cgi object generated with
each_cgi { |cgi|
is of class CGI, but this is not the same as the common CGI
class, so it does not provide functions like .h1 or .html