MESSAGE
DATE | 2020-09-14 |
FROM | Mithun Bhattacharya
|
SUBJECT | Re: [Hangout - NYLXS] cache a object in modperl
|
From hangout-bounces-at-nylxs.com Sat Sep 26 03:26:28 2020 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www2.mrbrklyn.com (www2.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id A9B9F163FD0; Sat, 26 Sep 2020 03:26:03 -0400 (EDT) X-Original-To: hangout-at-www2.mrbrklyn.com Delivered-To: hangout-at-www2.mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 1000) id B585F163FC0; Sat, 26 Sep 2020 03:20:57 -0400 (EDT) Resent-From: Ruben Safir Resent-Date: Sat, 26 Sep 2020 03:20:57 -0400 Resent-Message-ID: <20200926072057.GH10387-at-www2.mrbrklyn.com> Resent-To: hangout-at-mrbrklyn.com X-Original-To: ruben-at-mrbrklyn.com Delivered-To: ruben-at-mrbrklyn.com Received: from mailroute1-lw-us.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mrbrklyn.com (Postfix) with ESMTP id 7F1AF161150 for ; Mon, 14 Sep 2020 01:29:31 -0400 (EDT) Received: from mail.apache.org (localhost [127.0.0.1]) by mailroute1-lw-us.apache.org (ASF Mail Server at mailroute1-lw-us.apache.org) with SMTP id 2ED42121F53 for ; Mon, 14 Sep 2020 05:29:31 +0000 (UTC) Received: (qmail 78647 invoked by uid 500); 14 Sep 2020 05:29:30 -0000 Mailing-List: contact modperl-help-at-perl.apache.org; run by ezmlm Precedence: bulk Delivered-To: mailing list modperl-at-perl.apache.org Received: (qmail 78636 invoked by uid 99); 14 Sep 2020 05:29:30 -0000 Received: from spamproc1-he-fi.apache.org (HELO spamproc1-he-fi.apache.org) (95.217.134.168) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Sep 2020 05:29:30 +0000 Received: from localhost (localhost [127.0.0.1]) by spamproc1-he-fi.apache.org (ASF Mail Server at spamproc1-he-fi.apache.org) with ESMTP id 7CAEDC041E for ; Mon, 14 Sep 2020 05:29:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamproc1-he-fi.apache.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.2, KAM_SHORT=0.001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamproc1-he-fi.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-ec2-va.apache.org ([116.203.227.195]) by localhost (spamproc1-he-fi.apache.org [95.217.134.168]) (amavisd-new, port 10024) with ESMTP id aixp76LxTH0J for ; Mon, 14 Sep 2020 05:29:28 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.221.169; helo=mail-vk1-f169.google.com; envelope-from=mithnb-at-gmail.com; receiver= Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) by mx1-ec2-va.apache.org (ASF Mail Server at mx1-ec2-va.apache.org) with ESMTPS id 14503BC312 for ; Mon, 14 Sep 2020 05:29:28 +0000 (UTC) Received: by mail-vk1-f169.google.com with SMTP id e5so3824904vkm.2 for ; Sun, 13 Sep 2020 22:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=qVNF7DEzxCpXccJtASDhPLwVxZOjjd1ObOjcFerZasw=; b=OTqQNB23cOg+6ssO8egKO3wxIXXoBNbd8HLWuAjjW0c4LSjcC3xWyR/onsn3fSBoMB pvNBrJDHri2vhOSGEar4YdM2zF0dRGgXJOa9ROtPE2EhCFeIYB+Cs6ROfw4zcelxuFaL QlaPRzK8itZRewJqv9p3Z21+vAFmOBBuSuuRwWJTLumtsdP+PJGXy2xJFTXxy0bUZh5l 54hOuViL/biHEEDUBnelVnwOeb70p9YDlLDQRqQBn29ucw6USR8msSQFR+Gq3Jd1haPI TmV2UwAzP4rJJdnTN+wLTeOa783rsJY+gRBAT46OaNFB9Vfs9MkK7F9k/uU/Fjo9Jsbo +EhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=qVNF7DEzxCpXccJtASDhPLwVxZOjjd1ObOjcFerZasw=; b=XYpmBMNmvm/3Z29QkTTPqeQYMqMvH27AKGfbB/6X7BUU7820ujU5MzO+P61kNkyDn8 +zEqhuyCoaeIUHV75ggYfGWYGEHVrBsLj5d2e6E8ROrP/+yTSA6l+rtOG4BTpb/bVgny aVme4Wu/qbBdbnk6AF9WSJkV8WDDkGea8LHcMzf0QSR7PuwsaUxQK0DBqF5xvkTqFQTe Dyg/ImcMF0yORUH4TUIf0forHM/WI8/eU2ugUHVwH2DVBhTHBSXPP058FAP78RgnK9oJ c2HrCvqbMj+vIObK//20CmUKj3PIQEsylT2n8YQuM/YAROgA7udA/5xoliMJ7iPPoRl7 6Veg== X-Gm-Message-State: AOAM533/GMTcj74brMGEGgxwObDylNjFgGZWis5YXPUR0HWi0kxNqpY7 q07cCqL3kjaTxqPbZv+Ni+zmWKtodMG78e8z+zMX4wv7 X-Google-Smtp-Source: ABdhPJx14uwR0CzLFvILREHhP36jkU72T4vd4YBX1VNqUSKyD1h6L6VvknvMWMYiy4jflQrV9fE+RPvU2JJBc3IMi8s= X-Received: by 2002:ac5:ccac:: with SMTP id p12mr6051335vkm.5.1600061360891; Sun, 13 Sep 2020 22:29:20 -0700 (PDT) MIME-Version: 1.0 References: <08a9afe6-15e4-e31e-2dd2-6e64e73fe285-at-pobox.com> <82A06BD9-2EDE-4D5E-923B-3C5120E4B37A-at-utoronto.ca> In-Reply-To: <82A06BD9-2EDE-4D5E-923B-3C5120E4B37A-at-utoronto.ca> From: Mithun Bhattacharya Date: Mon, 14 Sep 2020 00:29:09 -0500 Message-ID: To: mod_perl list Subject: Re: [Hangout - NYLXS] cache a object in modperl X-BeenThere: hangout-at-nylxs.com X-Mailman-Version: 2.1.30rc1 List-Id: NYLXS Tech Talk and Politics List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0049138645==" Errors-To: hangout-bounces-at-nylxs.com Sender: "Hangout"
--===============0049138645== Content-Type: multipart/alternative; boundary="00000000000008ea4605af3f5158"
--00000000000008ea4605af3f5158 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Startup is not a great idea if your webserver is up forever - I have some which are running for months.
How frequently do you wish to refresh the cache ? if you do in startup then your cache refresh is tied to the service restart which might not be ideal or feasible.
On Mon, Sep 14, 2020 at 12:26 AM Adam Prime wrote:
> I left out the link to the thread. Here it is. > > https://marc.info/?t=3D119062870700002&r=3D1&w=3D2 > > > > On Sep 14, 2020, at 1:18 AM, Wesley Peng wrote: > > =EF=BB=BFThat's great. Thank you Adam. > > Adam Prime wrote: > > If the database doesn't change very often, and you don't mind only gettin= g > updates to your database when you restart apache, and you're using prefor= k > mod_perl, then you could use a startup.pl to load your database before > apache forks, and get a shared copy globally in all your apache children. > > https://perl.apache.org/docs/1.0/guide/config.html#The_Startup_File > > This thread from 13 years ago seems to have a clear-ish example of how to > use startup.pl to do what i'm talking about. > > If you need it to update more frequently than when you restart apache, yo= u > could potentially use a PerlChildInitHandler to load the data when apache > creates children. This will use more memory, as each child will have it'= s > own copy, and can also result in situation where children can have > different versions of the database loaded and be serving requests at the > same time. If you want to go this way you might want to also add a > MaxRequestsPerChild directive to your apache config to make sure that > you're children die and get refreshed on the regular, if you don't alread= y > have one. > > Adam > > On 9/13/2020 10:51 PM, Wesley Peng wrote: > > Hello > > > I am not so familiar with modperl. > > > For work requirement, I need to access IANA TLD database. > > > So I wrote this perl module: > > https://metacpan.org/pod/Net::IANA::TLD > > > But, for each new() in the module, the database file will be downloaded > from IANA's website. > > > I know this is pretty Inefficient. > > > My question is, can I cache the new'ed object by modperl? > > > If so, how to do? > > > Thanks. > >
--00000000000008ea4605af3f5158 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Startup is not a great idea if your webserver is up foreve= r - I have some which are running=C2=A0for months.
How f= requently do you wish to refresh the cache ? if you do in startup then your= cache refresh is tied to the service restart which might not be ideal or f= easible.
=3D"gmail_attr">On Mon, Sep 14, 2020 at 12:26 AM Adam Prime < mailto:adam.prime-at-utoronto.ca">adam.prime-at-utoronto.ca> wrote: iv> er-left:1px solid rgb(204,204,204);padding-left:1ex"> dir=3D"ltr">I left out the link to the thread.=C2=A0 Here it is.=C2=A0v>
<= /div>
=EF=BB=BF That'= ;s great. Thank you Adam.Adam Prime wrote= :If the database doesn't cha= nge very often, and you don't mind only getting updates to your databas= e when you restart apache, and you're using prefork mod_perl, then you = could use a startup.pl = to load your database before apache forks, and get a shared copy globally i= n all your apache children.
">tartup_File" target=3D"_blank">https://perl.apache.org/docs/1.0/guide/confi= g.html#The_Startup_File
">This thread from 13 years ago seems to have a clear-ish example of = how to use startup.pl t= o do what i'm talking about.
"cite">If you need it to update more frequently than when you restart= apache, you could potentially use a PerlChildInitHandler to load the data = when apache creates children.=C2=A0 This will use more memory, as each chil= d will have it's own copy, and can also result in situation where child= ren can have different versions of the database loaded and be serving reque= sts at the same time.=C2=A0 If you want to go this way you might want to al= so add a MaxRequestsPerChild directive to your apache config to make sure t= hat you're children die and get refreshed on the regular, if you don= 9;t already have one.
n>Adam
On 9/13/2020 = 10:51 PM, Wesley Peng wrote:
e">Hello
e> ockquote>
<= span>I am not so familiar with modperl.
> ckquote>
pan>For work requirement, I need to access IANA TLD database. lockquote>
=
quote type=3D"cite">So I wrote this perl module: te> <= a href=3D"https://metacpan.org/pod/Net::IANA::TLD" target=3D"_blank">https:= //metacpan.org/pod/Net::IANA::TLD
<= blockquote type=3D"cite"> quote>
n>But, for each new() in the module, the database file will be downloaded f= rom IANA's website.
e=3D"cite">
uote>I know this = is pretty Inefficient.
=3D"cite">
ote>My question i= s, can I cache the new'ed object by modperl?
lockquote>=
"cite">If so, how to do?
ote type=3D"cite">
<= /blockquote>Thank= s.
e> --00000000000008ea4605af3f5158-- --===============0049138645== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Hangout mailing list Hangout-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/hangout --===============0049138645==-- --===============0049138645== Content-Type: multipart/alternative; boundary="00000000000008ea4605af3f5158" --00000000000008ea4605af3f5158 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Startup is not a great idea if your webserver is up forever - I have some which are running for months. How frequently do you wish to refresh the cache ? if you do in startup then your cache refresh is tied to the service restart which might not be ideal or feasible. On Mon, Sep 14, 2020 at 12:26 AM Adam Prime wrote:
> I left out the link to the thread. Here it is. > > https://marc.info/?t=3D119062870700002&r=3D1&w=3D2 > > > > On Sep 14, 2020, at 1:18 AM, Wesley Peng wrote: > > =EF=BB=BFThat's great. Thank you Adam. > > Adam Prime wrote: > > If the database doesn't change very often, and you don't mind only gettin= g > updates to your database when you restart apache, and you're using prefor= k > mod_perl, then you could use a startup.pl to load your database before > apache forks, and get a shared copy globally in all your apache children. > > https://perl.apache.org/docs/1.0/guide/config.html#The_Startup_File > > This thread from 13 years ago seems to have a clear-ish example of how to > use startup.pl to do what i'm talking about. > > If you need it to update more frequently than when you restart apache, yo= u > could potentially use a PerlChildInitHandler to load the data when apache > creates children. This will use more memory, as each child will have it'= s > own copy, and can also result in situation where children can have > different versions of the database loaded and be serving requests at the > same time. If you want to go this way you might want to also add a > MaxRequestsPerChild directive to your apache config to make sure that > you're children die and get refreshed on the regular, if you don't alread= y > have one. > > Adam > > On 9/13/2020 10:51 PM, Wesley Peng wrote: > > Hello > > > I am not so familiar with modperl. > > > For work requirement, I need to access IANA TLD database. > > > So I wrote this perl module: > > https://metacpan.org/pod/Net::IANA::TLD > > > But, for each new() in the module, the database file will be downloaded > from IANA's website. > > > I know this is pretty Inefficient. > > > My question is, can I cache the new'ed object by modperl? > > > If so, how to do? > > > Thanks. > >
--00000000000008ea4605af3f5158 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Startup is not a great idea if your webserver is up foreve= r - I have some which are running=C2=A0for months.
How f= requently do you wish to refresh the cache ? if you do in startup then your= cache refresh is tied to the service restart which might not be ideal or f= easible.
=3D"gmail_attr">On Mon, Sep 14, 2020 at 12:26 AM Adam Prime < mailto:adam.prime-at-utoronto.ca">adam.prime-at-utoronto.ca> wrote: iv> er-left:1px solid rgb(204,204,204);padding-left:1ex"> dir=3D"ltr">I left out the link to the thread.=C2=A0 Here it is.=C2=A0v>
<= /div>
=EF=BB=BF That'= ;s great. Thank you Adam.Adam Prime wrote= :If the database doesn't cha= nge very often, and you don't mind only getting updates to your databas= e when you restart apache, and you're using prefork mod_perl, then you = could use a startup.pl = to load your database before apache forks, and get a shared copy globally i= n all your apache children.
">tartup_File" target=3D"_blank">https://perl.apache.org/docs/1.0/guide/confi= g.html#The_Startup_File
">This thread from 13 years ago seems to have a clear-ish example of = how to use startup.pl t= o do what i'm talking about.
"cite">If you need it to update more frequently than when you restart= apache, you could potentially use a PerlChildInitHandler to load the data = when apache creates children.=C2=A0 This will use more memory, as each chil= d will have it's own copy, and can also result in situation where child= ren can have different versions of the database loaded and be serving reque= sts at the same time.=C2=A0 If you want to go this way you might want to al= so add a MaxRequestsPerChild directive to your apache config to make sure t= hat you're children die and get refreshed on the regular, if you don= 9;t already have one.
n>Adam
On 9/13/2020 = 10:51 PM, Wesley Peng wrote:
e">Hello
e> ockquote>
<= span>I am not so familiar with modperl.
> ckquote>
pan>For work requirement, I need to access IANA TLD database. lockquote>
=
quote type=3D"cite">So I wrote this perl module: te> <= a href=3D"https://metacpan.org/pod/Net::IANA::TLD" target=3D"_blank">https:= //metacpan.org/pod/Net::IANA::TLD
<= blockquote type=3D"cite"> quote>
n>But, for each new() in the module, the database file will be downloaded f= rom IANA's website.
e=3D"cite">
uote>I know this = is pretty Inefficient.
=3D"cite">
ote>My question i= s, can I cache the new'ed object by modperl?
lockquote>=
"cite">If so, how to do?
ote type=3D"cite">
<= /blockquote>Thank= s.
e> --00000000000008ea4605af3f5158-- --===============0049138645== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Hangout mailing list Hangout-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/hangout --===============0049138645==-- |
|