mod_perl: sharing data across httpd childs ?

Discussion in 'Perl Misc' started by howa, Oct 15, 2008.

  1. howa

    howa Guest

    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.

    >> top -bc -n 1 | grep httpd


    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.
     
    howa, Oct 15, 2008
    #1
    1. Advertising

  2. howa <> writes:

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


    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/
     
    Joost Diepenmaat, Oct 15, 2008
    #2
    1. Advertising

  3. howa

    howa Guest

    Hello,

    On Oct 15, 6:48 pm, Joost Diepenmaat <> wrote:
    > howa <> writes:
    > 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.
    >



    Thanks for reply.

    Even I put the line:

    >> TestPM::init();


    inside the startup.pl, still the same
     
    howa, Oct 15, 2008
    #3
  4. howa

    Guest

    howa <> wrote:
    >
    > By stress testing the test.cgi, I found memory is not shared at all,
    > using the top command, e.g.
    >
    > >> top -bc -n 1 | grep httpd

    >
    > 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?


    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.
     
    , Oct 15, 2008
    #4
    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. Darren Oakey

    Sharing Session data across two projects

    Darren Oakey, Dec 19, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    422
    Darren Oakey
    Dec 19, 2003
  2. Mervin Williams

    Sharing data across web forms?

    Mervin Williams, Apr 9, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    479
    Cor Ligthert
    Apr 9, 2004
  3. Nele Paulsen
    Replies:
    3
    Views:
    188
    A. Sinan Unur
    Dec 17, 2003
  4. Replies:
    2
    Views:
    456
    Big and Blue
    Jan 25, 2006
  5. Roy M

    mod_perl in Apache httpd

    Roy M, Oct 16, 2008, in forum: Perl Misc
    Replies:
    0
    Views:
    82
    Roy M
    Oct 16, 2008
Loading...

Share This Page