Click here to get back home

mod_perl: sharing data across httpd childs ?

 HomeNewsGroups | Search

comp.lang.perl.misc - PERL programming language 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
mod_perl: sharing data across httpd childs ? howa 10-15-2008
Posted by howa on October 15, 2008, 4:36 am
Please log in for more thread options
I am refering to the tutorial (http://modperlbook.org/html/4-2-3-
PerlModule-and-PerlRequire.html),
about setting up Perl module memory sharing across http childs:


==================================

1. in httpd.conf

Added PerlRequire /home/www/cgi-bin/startup.pl

the its contents is:

use strict;

use lib "/home/www/cgi-bin/";

use TestPM ();

1;

==================================

2. The TestPM's content

use strict;

package TestPM;

my $data;

sub new {

        my ($class) = @_;

        my $self = {};

        bless $self, $class;

        return $self;
}

sub init {
        $data = "1234567890" x 1000000;        # 10M of data
}


==================================

3. test.cgi


#!/usr/bin/perl

print "Content-type:text/html\n\n";

use strict;

use TestPM;

TestPM::init();

==================================


By stress testing the test.cgi, I found memory is not shared at all,
using the top command, e.g.

show/hide quoted text

11290 web 25 0 100m 23m 1620 R 47 0.3 0:00.29 /usr/
local/apache_1.3.41/bin/httpd
11247 web 20 0 101m 23m 1628 R 41 0.3 0:05.15 /usr/
local/apache_1.3.41/bin/httpd


As you can see, each httpd is using 23m, and 1620bytes shared, which I
belive the much data is shared....


Any idea?

Thanks.





Posted by Joost Diepenmaat on October 15, 2008, 6:48 am
Please log in for more thread options

show/hide quoted text

The only data that might be shared is data that is already initialized at
the startup phase. Data that's copied / assigned during at later stages
will not be shared. The manual and the book both mention this.


--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

Posted by howa on October 15, 2008, 7:23 am
Please log in for more thread options
Hello,

show/hide quoted text


Thanks for reply.

Even I put the line:

show/hide quoted text

inside the startup.pl, still the same



Posted by xhoster on October 15, 2008, 2:07 pm
Please log in for more thread options
show/hide quoted text

In addition to what the other post said, it should be pointed out that
the SHR column of the "top" command does not reflect all modes of memory
sharing. For example, Copy-On-Write sharing does not seem to accounted
for as shared. I think it reflects only shared libraries (*.so files) and
not any kind of data sharing. It would be nice if the "man top" did a
better job of explaining this. You need a better way of diagnosing how
much memory is actually being used.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Similar ThreadsPosted
mod_perl 2.0 and apache 2.2 Undefined subroutine &ModPerl::ROOT::ModPerl::Registry error January 24, 2006, 3:43 pm
Net::Server and data sharing November 21, 2005, 8:09 pm
sharing variables-data perl-asp February 23, 2006, 9:44 am
Prevent kill signals to childs June 5, 2008, 1:04 am
modPerl, Apache, and REMOTE_USER November 25, 2006, 2:50 pm
Prototype mismatch under ModPerl::PerlRun September 6, 2005, 5:59 pm
CPAN conflict issue - CGI.pm vs ModPerl::Registry September 25, 2006, 12:42 pm
modperl: HTML::Template not working inside handler February 25, 2008, 2:33 pm
HowTo tell if from cmd_line || httpd December 20, 2004, 5:05 pm
mod_perl in Apache httpd October 16, 2008, 12:17 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy