Re: Porting

2001-09-24 Thread Perrin Harkins

 What really makes mod_perl better than Java?

This is a common thread, which you should look up in the archives.  It's
best to avoid starting up a discussion with this vague a question, since it
will lead to a flood of advocacy e-mails.

 Didn't the eToys guys do some benchmarking? (Perrin?)

We did.  We knew we were going to use Linux, so we took the fastest Java
stuff (Resin + IBM's JVM) and wrote a quick test servlet to select some
stuff from Oracle and display it.  When we ran the same thing under
mod_perl, Perl was a little bit faster.  Note that Caucho has some
benchmarks they published which are not very good since they have poorly
optimized Perl code (it's a Registry script, not a handler).

When we saw that Perl was just as fast, we had no reason to switch from a
productive platform that we all liked to one that only some of our team had
skills on.

- Perrin




Re: [ANNOUNCE] TicketMaster.com sponsors mod_perl development

2001-09-24 Thread Perrin Harkins

 i am not sure what they are using mod_perl for.

Ticketmaster.com also owns CitySearch.com.  They run CitySearch.com on
mod_perl.  You may want to check back on Ticketmaster.com in a few months.
- Perrin




Re: Setting PerlRequire in a Perl section

2001-09-21 Thread Perrin Harkins

 Actually, yes, I had. PerlVINC is not really what I needed, the goal was
 not to reload %INC per VirtualHost, the need was to have a single
 PerlRequire set up @INC properly per VirtualHost (so Apache::StatINC
 would work). Ordinary this would have been done with something like 'use
 lib $FindBin::Bin/lib/, but since that doesn't work under mod_perl I
 was toying with using Perl sections.

It sounds like maybe you were not understanding that in the mod_perl 1.x
series there is only 1 Perl interpreter shared between all VirtualHosts
(they are virtual, after all).  That means there can only be one @INC for
all VirtualHosts as well.  Things like PerlVINC cheat by messing with @INC
on each request.

- Perrin




Re: Setting PerlRequire in a Perl section

2001-09-21 Thread Perrin Harkins

 I understood the limitation of the single interpreter, the problem again
 was to append to @INC per VirtualHost.

It's confusing when you say that, since there's only one @INC for
everything.  I'm interpreting this as meaning that you have a bunch of
applications with different install directories and you want them all to go
in the global @INC.

 The goal was to be able to checkout the application source from our CVS
 repository, Include its app.httpd.conf from the main httpd.conf, and
 be ready to go, with the absolute path for each application's lib
 directory appended to @INC for StatINC to work.

How do you avoid hard-coding the paths to app.httpd.conf then?  If you're
already hard-coding that path on each server, you should be able to just
make everything else relative to that.  Is that what you were trying to do
with your original post?  That code would work fine if you change
$PerlRequire to a straight 'require'.  They do the same thing.

Perl
 my $dirroot = $0;
 $dirroot = s/\.htaccess$//;
 require ($dirroot . 'modperlstartup.pl');
/Perl

 As I mentioned previously we switched to absolute paths in the
 per-application startup.pl file. Its a pain to maintain a per-server
 times per-application list of lib paths, but that fixes us until I get
 to see what mod_perl 2.0 has in store for me :-)

Well, what Stas was talking about with mod_perl 2 was just having different
Perl interpreters (with different @INCs) per VirtualHost, which actually
doesn't sound like it has much to do with your problem.

I still don't understand what problem you're trying to solve well enough to
give good advice, but configuration management issues are commonly handled
through an installation process that sets local paths.  The last time I had
to do that for a mod_perl app, we used Template Toolkit to generate our
httpd.conf and startup.pl with local paths during the install.  For simpler
localization, you could just use a couple of substitutions, or you could try
playing with MakeMaker.

- Perrin




Re: Shared cache with IPC::Shareable

2001-09-19 Thread Perrin Harkins

 I'm sharing memory between httpd processes using IPC::Shareable. It is
working
 but seems to behave inconsistently (memory is often not being freed
etc..). I'm
 using it for creating common cached areas for file and database contents
shared
 between httpd children. Is there a better way to do this i.e. Am I stuck
with
 IPC::Shareable? I'm running mod_perl and the whole application is running
as a
 single content handler.

 It also isn't as fast as I thought it would be  - sure it takes a long
time to
 do the initial load of all caches on the first request, but I just thought
it
 would be a little faster than it is. Are there any performance issues I
should
 be aware of with IPC::Shareable or shared mem in general?

Yes, shared memory can be pretty slow.  You should look at Cache::Cache
(specifically the file cache) or MLDBM::Sync.
- Perrin




Re: mod_proxy and mod_perl in guide

2001-09-17 Thread Perrin Harkins

 After checking Apache code for mod_proxy looks like it is normal
behaviour.
 File modules/proxy/proxy_util.c function ap_proxy_send_fb. This function
 reads from originating server into buffer and then writes to the customer
from
 this buffer. BUT the socket is closed AFTER all the data is sent to the
 client (file module/proxy/proxy_http.c function ap_proxy_http_handler. So
 the heavy mod_perl server is not released for serving other requests
untill
 the data is sent to the client by proxy.

 Maybe I'm missing something but the practice shows that this is true and
Guide
 contains error.

Maybe the thing you're missing is that mod_proxy takes care of the lingering
close.  Those of us who have tried the two-server setup have all seen
dramatic reductions in the number of mod_perl processes required.
- Perrin




Re: FilesMatch for files that don't exist

2001-09-17 Thread Perrin Harkins

 I'd like to have a controller module, where any url
 that has a .phtml page will call the handler in the
 controller module. Within the controller module I use
 logic to determine which module (if any) should
 process the request using push_handlers.

 The issue is that I'm using virtual urls, so these
 .phtml files don't actually exist and FilesMatch
 wants a physical file on the server. I'm curious if my
 approach is the best way.

It's easier to use a directory structure, i.e. everything under /perl/ is
handled by your controller module.  You should also look at
Apache::Dispatch.
- Perrin




Re: DBI connections build up..

2001-09-14 Thread Perrin Harkins

  Your script uses an END block to disconnect.  If you use
  Apache::Registry, that will not be run until the server is shut down.
  With Apache::DBI, you should get one connection per Apache process, and
  they'll stay open.  If you are changing the login parameters (i.e.
  different user each time), you can't use Apache::DBI because you'll get
  a huge build-up of connections.

 really? when did that change? As much as I know, Apache::Registry scripts
 always run END blocks.
 http://perl.apache.org/guide/porting.html#END_blocks

Right, my mistake.  I was thinking about BEGIN blocks and Registry vs.
PerlRun.
- Perrin




Re: DBI connections build up..

2001-09-14 Thread Perrin Harkins

  Your script uses an END block to disconnect.  If you use
  Apache::Registry, that will not be run until the server is shut down.
  With Apache::DBI, you should get one connection per Apache process, and
  they'll stay open.  If you are changing the login parameters (i.e.
  different user each time), you can't use Apache::DBI because you'll get
  a huge build-up of connections.

 really? when did that change? As much as I know, Apache::Registry scripts
 always run END blocks.
 http://perl.apache.org/guide/porting.html#END_blocks

Right, my mistake.  I was thinking about BEGIN blocks and Registry vs.
PerlRun.
- Perrin




Re: Template or XML?

2001-09-14 Thread Perrin Harkins

 We have also heard something about OpenInteract, which is based on
 Template Toolkit - may be it would be simplier to use it?

It does sound like a possible good choice for your purposes, since it
combines a basic application structure with Template Toolkit integration and
an object/relational mapping tool (SPOPS) for data management.

Personally, the way I would do this is to write the config stuff you're
doing in XML as straight Perl data structures (nested hashes and arrays).  I
would do all of the database processing in standard Perl modules, and only
use TT to display results and editing forms.  If your TT templates seem
messy, it may be because you're trying to do too much application logic in
them.  It's best to avoid things like the DBI plugin and do all the real
work before you run the template.

- Perrin




Re: Template or XML?

2001-09-14 Thread Perrin Harkins

 We have also heard something about OpenInteract, which is based on
 Template Toolkit - may be it would be simplier to use it?

It does sound like a possible good choice for your purposes, since it
combines a basic application structure with Template Toolkit integration and
an object/relational mapping tool (SPOPS) for data management.

Personally, the way I would do this is to write the config stuff you're
doing in XML as straight Perl data structures (nested hashes and arrays).  I
would do all of the database processing in standard Perl modules, and only
use TT to display results and editing forms.  If your TT templates seem
messy, it may be because you're trying to do too much application logic in
them.  It's best to avoid things like the DBI plugin and do all the real
work before you run the template.

- Perrin




Re: Persistent Database connections

2001-09-14 Thread Perrin Harkins

 Before running my perl script (f1.pl) i see five httpd@hostname sessions
in
 Oracle V$session but at the moment in which i run f1.pl there appear a
 seventh session alone such f1.pl@hostname.

 The mechanism of persistent connections seems to be not workinkg properly.

What is it that makes you think it's not working properly?  You should get
one connection for each httpd process, and then no more.

- Perrin




Re: DBI connections build up..

2001-09-13 Thread Perrin Harkins

 DJ (David J Radunz) wrote:
 I am having a problem with a module im writing connecting to the
 database everytime its run, and not cleaning up the database
 connection when its finished.

Your script uses an END block to disconnect.  If you use
Apache::Registry, that will not be run until the server is shut down. 
With Apache::DBI, you should get one connection per Apache process, and
they'll stay open.  If you are changing the login parameters (i.e.
different user each time), you can't use Apache::DBI because you'll get
a huge build-up of connections.

- Perrin



Re: Apache::DBI Segmentation fault

2001-09-10 Thread Perrin Harkins

 I am getting a segmentation fault on configtest when using Apache::DBI
 (using the startup.pl example in Apache::DBI Distribution). When trying
 to start the server I get no error messages but the server isn't
 running afterwards

Do you know that your DBI works without Apache::DBI?  It would be helpful if
you could post the relevant parts of your httpd.conf and startup.pl too.
- Perrin




Re: mod_perl proxy to mod_ssl or vice-versa?

2001-09-10 Thread Perrin Harkins

 i've seen discussion at perl.apache.org/guide about having a
 hefty mod_perl server with a lightweight server proxying
 the heavy-lifting requests to the mod_perl server (same machine,
 different machine).

 can this be done with mod_ssl and mod_perl?

Yes, lots of people do that.  You need the front-end to have mod_proxy and
mod_ssl.

 internet  firewall mod_ssl   backend mod_perl
  [1.2.3.4]  [192.168.7.10]
 :443  ssl verify --- apache:80
 :80   portforward -- apache:80

 i'm thinking of using port forwarding on 1.2.3.4 to send :80 http
 requests directly to the mod_perl server, and have :443 https
 requests get verified thru the mod_ssl server which then also get
 sent to the mod_perl server at 192.168.7.10 (HTML::Mason needed
 to do the work).

I suggest you have both go through the front-end server.  There are multiple
reasons to do this, which are outlined in the guide.

- Perrin




Re: RFC: Apache::Session::CacheAny

2001-09-09 Thread Perrin Harkins

Tatsuhiko Miyagawa wrote:
 
 Announcing the Adapter module which provides a way to use
 Cache::Cache subclasses as Apache::Session storage implementation.

Hmmm...

Don't take this the wrong way, but what's the purpose of this? 
Apache::Session does very little beyond what Cache::Cache does.  In
fact, the only things I can think of are the tied interface, which is
slower than methods and often confuses people who make updates deep
within the structure that don't trigger a save, and the ID generation,
which is really just a stub and needs to be replaced for any serious
project.

Also, why bother with Apache::Session::Lock::Semaphore at all? 
Cache::Cache already provides atomic updates.  You should be able to use
NullLocker with the same level of safety.

- Perrin



Re: RFC: Apache::Session::CacheAny

2001-09-09 Thread Perrin Harkins

princepawn wrote:
 Above and beyond the efficiency issues you discuss above, could you
 comment on what Apache::Session would need to be useful in a serious
 project?

I was commenting specifically on the ID generation.  The algorithm
supplied does not guarantee unique IDs, especially when you have a
cluster of machines.  The design of Apache::Session makes it possible to
drop in your own replacement for ID generation, which is what you should
do if you're building a large-scale production system.  Last time I
needed to deal with this I used mod_unique_id as my starting point,
which does generate unique IDs across a cluster.
- Perrin



Re: RFC: Apache::Session::CacheAny

2001-09-09 Thread Perrin Harkins

Tatsuhiko Miyagawa wrote:
 Cache::Cache is a cache interface for any key-value pairs with
 optioinal automatic expire  purge.
 
 Apache::Session is a framework for persisntent hash data with
 unique identifier and automatic serialiization/deserialization for
 hash.

To me, they both look like persistent hashes.  Apache::Session assumes
you will be storing a serialized hash in each hash value, and that it
will generate IDs for keys if you don't supply one, but otherwise
they're about the same.

 Why not combine these two? That's all what this module does.

Okay.  Just wondered if I was missing something.

 Cache::Cache ensures file-based atomic update. But IMHO
 it's not enough for Apache::Session's session transactions, which
 should be done exclusively. Session data would get logically
 inconsistent when there are multiple concurrent requests with same
 one session id.

Apache::Session uses shared read locks, so I think you can still have
problems there.  It doesn't gurantee an atomic read-change-modify.

- Perrin



Re: tracing memory problem

2001-09-07 Thread Perrin Harkins

 ok, i'll look into that. I've been using RLimitMEM and RLimitCPU

One thing to be aware of is that using rlimit will kill your process harshly
when it goes over the limit.  It's better to use Apache::SizeLimit for basic
size control, and use rlimit as a backup safety measure to catch runaway
processes.  Apache::SizeLimit will detect processes that are getting too big
and make them cleanly exit after they finish the current request.
- Perrin




Re: memory leaking with closures

2001-09-07 Thread Perrin Harkins

  Oddly, if you just do
 
  my $sub = sub { $var; };
 
  it does not grow, definately something strange going on. Happens on
  perl 5.004_04, 5.005_03 and 5.6.1.

 You mean this works for you?:

 while (1) {
{
my $var = 'x' x 50;
my $sub = sub { $var; };
}
# $var and $sub should be gone, but memory is never freed
sleep 1; # Don't crash things =)
 }

 that's because your $sub goes out of scope.

The leaking behavior only happens when you use nested anonymous subs.  It
should always be possible to avoid it, although your code may look uglier.

 the other one seems like a
 bug.

 If I didn't miss something, it seems that we need to run this through p5p.

It's been known about for a while.  I'm not sure what the status of getting
a fix is.  I assume that it must be difficult to fix or it would have been
changed a long time ago.

- Perrin




Re: embperl

2001-09-07 Thread Perrin Harkins

 Just wanted to ask to any embperl user, is there any real advantage
 about using embperl instead of PHP ?

If you want a high-level summary of Embperl features, you could take a look
at my article on perl.com:
http://www.perl.com/pub/a/2001/08/21/templating.html

- Perrin




Re: sharing % across requests

2001-09-06 Thread Perrin Harkins

 sorry, I think I misread the question - the verbosity threw me.

No, I think you got it right.  He wants to share a hash between multiple
Apache children.

I recommend using either MLDBM::Sync or Cache::Cache for this.

- Perrin




Re: Another Apache::DBI problem

2001-09-06 Thread Perrin Harkins

 Syntax error on line 304 of /export/apache/conf/httpd.conf:
 Can't load
 '/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/DBI/DBI.so' for
 module DBI: ld.so.1: /export/apache/bin/httpd: fatal: relocation error:
 file /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/auto/DBI/DBI.so:
 symbol main: referenced symbol not found at
 /usr/local/lib/perl5/5.6.1/sun4-solaris/DynaLoader.pm line 206.
  at /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/DBI.pm line 189
 BEGIN failed--compilation aborted at
 /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/DBI.pm line 189.
 Compilation failed in require at
 /usr/local/lib/perl5/site_perl/5.6.1/Apache/DBI.pm line 4.
 BEGIN failed--compilation aborted at
 /usr/local/lib/perl5/site_perl/5.6.1/Apache/DBI.pm line 4.
 Compilation failed in require at (eval 4) line 3.

 Line 304 of httpd.conf is the PerlModule Apache::DBI command.

 Any ideas?

This looks like a DBI installation problem, not an Apache::DBI problem.
Does DBI work when you don't use Apache::DBI?
- Perrin




Re: memory leaking with closures

2001-09-06 Thread Perrin Harkins

 With this simple test script:

 print Content-type: text/html\n\n;
 my $var = 'x' x 50;
 my $sub = sub { my $sub2 = sub { $var; }; };
 print Done\n;

 $var does not get freed, and the process grows each request. Has anyone
 seen this sort of behavior and have any ideas/workarounds (besides don't
 do that).

I've commented on this before, as have others, in the context of using
Error.pm.  There is no workaround for this except don't do that.
- Perrin




Re: Another Apache::DBI problem

2001-09-06 Thread Perrin Harkins

 The DBI installation went fine, I used CPAN. DBI version is 1.20. I looked
 for the DBI.so and the DBI.pm files and they are in the correct paths.

 What may be the problem?

I don't know, but you might have more luck asking about it on the DBI list.
Or you could do some searching on Google for similar error messages.
- Perrin




mailing list responses (was Re: FW: AuthCookie Woes!)

2001-09-04 Thread Perrin Harkins

 Further...no one needs to know or care about PerlMod around hereI
posted a
 question two weeks ago about Apache::AuthDBI...and no one responded.

 So looks like you are on your own..

Not true; people do know and care about Apache:: modules around here.  There
are lots of reasons why you might not have received a timely response to a
particular question.  You may be asking about a module that no one on the
list uses.  You may be asking at a bad time when the people who know this
module don't have time to help you.  You may not have posted enough
information.  You may have sent your message in HTML or as an attachment
(which annoys many people on this and other lists).

You can ask your question again if you like, or you can check the
documentation of the module in question to see if there's any more specific
instructions for getting help.  There's also a wealth of information in the
list archives which you can search through.

- Perrin




Re: Shared memory caching revisited (was it's supposed to SHARE it, not make more!)

2001-09-04 Thread Perrin Harkins

 I don't think Cache::Cache has enough logic for an atomic
 read-modify-write in any of its modes to implement (for example) a
 web hit counter.  It has only atomic write.  The last write wins
 strategy is fine for caching, but not for transacting, so I can see
 why Rob is a bit puzzled.

In his example code he was only doing atomic writes as well, so it should
work at least as well for his app as what he had before.

 It'd be nice if we could build a generic atomic read-modify-write

Maybe a get_for_update() method is what's needed.  It would block any other
process from doing a set() or a get_for_update() until the set() for that
key has completed.  It's still just advisory locking though, so if you
forget and use a regular get() for some data you later plan to set(), you
will not be getting atomic read-modify-write.  Maybe get() could be re-named
to get_read_only(), or set a flag that prevents saving the fetched data.
Most caching apps are happy with last save wins though, so I guess
anything like that would need to be optional.

- Perrin




Re: Constant subroutine NEW redefined at ...

2001-09-03 Thread Perrin Harkins

 I dont know what I've done, but somehow my httpd.conf has led to a
 number of warnings about me redefining a number of things.

Are you running the latest mod_perl?  Do you have PerlFreshRestart on?
- Perrin




Re: ErrorDocument + Apache request tracing

2001-09-03 Thread Perrin Harkins

 2 - Is there anyway to have apache dump to the lag exactly what it is
 doing so that I can get some idea of why it has my web browser idling
 away and not returning anything?

You can use strace, truss, or some similar tool.
- Perrin




Re: IPC::Shareable, or, it's supposed to SHARE it, not make more!

2001-08-31 Thread Perrin Harkins

 One of the shiny golden nuggets I received from said slice was a shared
 memory cache.  It was simple, it was elegant, it was perfect.  It was also
 based on IPC::Shareable.  GREAT idea.  BAD juju.

Just use Cache::Cache.  It's faster and easier.
- Perrin




Re: Apache::Session::File and free memory weirdness

2001-08-30 Thread Perrin Harkins

 Odd thing #1:  As it gets into evening time, load on the machine drops off
 and there are fewer httpd children running, but I am not seeing free
 memory return to that 1.3GB level.  At most it comes back up to 400MB or
 so.  I don't think the httpd children are hanging on to memory, because
 they cycle through pretty quickly - MaxRequestsPerChild is set to 512 and
 none of the processes are ever more than a couple minutes old when I look
 in.  Is there any reason to think the parent httpd process would hang on
 to anything?

I have noticed that over time the new processes will spawn with less memory
shared.  I'm not sure exactly why this is, but it does seem to happen.  A
nightly complete restart of the server will reset things, but you may not
have that option.

 Odd thing #2:  (This part seems most bizarre to me.)  At 5:15 AM, we run a
 Perl script that finds and deletes Apache::Session::File session and lock
 files that are older than 28 days.  Usually there are about 50,000 old
 files that get deleted out of about 2,300,000 total.  Almost immediately,
 free memory on the machine jumps back up to 1.3GB.  What's up with that?

Sounds like you're counting the buffers and cache in your used memory.
Depending on what OS you're on, you may want to look at a tool other than
top.  The memory used for buffers and cache will be available to
applications if they need it.

- Perrin






Re: mod_perl memory consumption

2001-08-28 Thread Perrin Harkins

 I wrote a program that converts 5 gigs of emails stored in mysql to
 phisical messages on disk (resulting in approximately 10 gigs). The
program
 consumes way to much memory although I've wrote it in a very clean way
(use
 strict, no globals, use of udef $var; to help free memory). I start it
 telneting to :80 and through time process takes from 15 megs to more than
 100 megs and only about 20% of messages are converted so far. The program
 uses vpopmail.pm and should run approximately one day. Maybe it would be
 faster if I used Apache::FakeRequest or something similar eleminating use
of
 mod_perl (plain cgi) ? I'm using HTML::Mason.

It will definitely not be faster if you use CGI.  It may take care of your
memory problems, but only by avoiding them.  You should be able to fix the
problem in your code and use mod_perl for this.

 Why is the memory consumption so high ? According to my calculations it
 should take less than 100 kilobytes.

What are you basing that on?

It sounds like you have some data structure which you are adding to and
never clearing out.  One thing to be careful of is the MySQL DBI driver.
The last time I used it, it fetched all returned rows into memory.  With a
large result set, that could take up tons of RAM.

- Perrin




Re: Problem with DBD::Oracle with mod_perl

2001-08-23 Thread Perrin Harkins

 Nope, you've got it. If you don't have transactions (anything else?) to
worry about, I'd say to use
 Apache::DBI.

Apache::DBI doesn't have a problem with transactions.  If you're doing
strange things like changing isolation levels on particular requests you can
get into trouble, but that's an unusual case and you can always write your
own cleanup code for it.
- Perrin




Re: Problem with DBD::Oracle with mod_perl

2001-08-23 Thread Perrin Harkins

 Apache::DBI doesn't have a problem with transactions.

 Ah, OK. What about when a shared connection is rolled back in one process,
 will it effect other running processes with the same handle?

Database handles are never shared between processes.  If you missed this,
you should re-read the Apache::DBI docs.
- Perrin






Re: Problem with DBD::Oracle with mod_perl

2001-08-22 Thread Perrin Harkins

  Are you using Apache::DBI?  Are you opening a connection in the parent
  process (in startup.pl or equivalent)?
 Yes, yes.

Don't open a connection during startup.  If you do, it will be shared when
Apache forks, and sharing a database handle is bad for the same reasons
sharig a file handle is.  Open a connection in the child process instead.
You can use connect_on_init() from Apache::DBI if you like.
- Perrin




Re: Problem with DBD::Oracle with mod_perl

2001-08-22 Thread Perrin Harkins

 After some time of work (about hundred of requests), I get

 DBD::Oracle::db prepare failed: ORA-03113: end-of-file on communication
 channel
 (DBD: error possibly near * indicator at char 1 in '*select
slogan_text
 from
  slogans') at /usr/local/www/lib/SQL.pm line 221.

 and all Oracle-using perl programs within Apache stops to work until I
 restart Apache.

 With two clients fetching a page both at one time, I'm 100% getting this
in
 less than a minute.

Are you using Apache::DBI?  Are you opening a connection in the parent
process (in startup.pl or equivalent)?
- Perrin




Re: Why do RaQ4is run mod_perl so slowly?

2001-08-19 Thread Perrin Harkins

On Saturday 18 August 2001 02:36 pm, Philip Mak wrote:
 I have a RaQ4i server (450MHz AMD K-6 processor). If I have 20 mod_perl
 httpd processes running concurrently, then the system's load average goes
 up over 10.0 and CPU usage is 100%. The machine has RAM to spare, so
 swapping is not the problem.

 Is that the norm for a 450MHz server, or is there something I can do to
 make it work better?

That's not normal; something is wrong.  Most mod_perl machines tend to have 
low load (1) because they aren't doing anything CPU intensive.  High loads 
like yours are generally associated with swapping.  If you're sure there's no 
memory problem, then you should try to figure out where all that work is 
going.  Maybe your app thrashes the disk and you need a faster one.  Maybe 
you have runaway processes.  Or maybe you just have that very rare thing: a 
CPU-intensive web app.

Doing some research with Devel::DProf and Time::HiRes is probably your next 
step.  You need to find out where all that work is going.

- Perrin



Re: Problem with use getting the wrong file

2001-08-16 Thread Perrin Harkins


 I have two mod_perl programs on my site. One is in the directory inr2,
 and the other is in the directory otherinr2.

 These mod_perl programs have exactly the same code. Both of them do:
 use cfg;

 where cfg.pm is a file that's in both inr2 and otherinr2, but it's
 different in these directories.

 But the code in otherinr2 is getting the cfg.pm from inr2 since they
 have the same filename and relative paths. How can I make the use
 command not act braindead about this? Is there a CPAN module that I can
 import to overload the use command with something that takes the full
 pathname into account perhaps?

You can specify a full path to use/require.  Check man perlfunc for the
details.  You can also specify a path relative to the current working
directory if you don't like hard-coding full paths in your scripts.
- Perrin




Re: PerlModule

2001-08-16 Thread Perrin Harkins

 My apache server does not start up when I add
 PerlModule B::TerseSize
 to the httpsd.conf file. Or any PerlModule flag. Any one can tell me
 why? I am trying to determine a leakage in my script...

Do you have B::TerseSize installed on your system?  It's not a standard
module.  Check your error_log for messages.
- Perrin




Re: Problem with use getting the wrong file

2001-08-16 Thread Perrin Harkins

 I have learned recently(and the original poster as well) that despite two
 files having different file names, and doing a require
 /full/path/to/file.pl, modperl will only compile the file once because
they
 both have the same package name.

No, I don't think that's correct.  Perl will compile both files if they have
different paths and you specify the full path.  However, if they do have the
same package name, the second one will overwrite the first one, which is
probably not what you intended.

 I have yet to find a solution to the problem that I like... I have a file
 that contains the database information (username, password, db name,
connect
 functions, ect) and for a while I couldnt figure out why two scripts using
 two seperate files for database info would connect to the wrong database
 heh.

There are tons of solutions for having separate config files for two
scripts.  You could name the config files differently and call the right one
from each script.  You could use a path relative to the current directory in
your require statement.  You could one conf file with one big hash of
configuration that is keyed on a variable you set with PerlSetVar to
something different for each script.

- Perrin




Re: Socket Nightmare On NT.

2001-08-15 Thread Perrin Harkins

 I am running mod_perl 1.2 on NT. I have been working with it for over 4
 months, and am beginning to understand it. But for the past 4 months, I
have
 complained about a socket problem using IO socket. The only answer I got
was
 to turn the max child from 50 to 1. When I do that the IO::Socket module
 works. But the site runs in a serial mode. Why use mod_perl then?

Were you not aware that mod_perl always runs in serial mode on NT?  This
won't change until mod_perl 2.  Most people say that it's still faster than
CGI.  If you can't live with that, you should use CGI or PerlEx or something
similar.
- Perrin




Re: HTTPD eating all RAM

2001-08-14 Thread Perrin Harkins

On Tue, 14 Aug 2001, Mike P. Mikhailov wrote:
   I'm useing Apache/1.3.12 (Unix) mod_perl/1.25 Embperl 1.3b7 under RH
   7.0. From request to request size of the httpd grows and eat all
   available RAM. Daemon run under -X option. My question is:
   
   how can I find out which exactly variable are eating RAM ?
 
   I'm absolutely sure that I'm not useing global variables.

You should read the guide at http://perl.apache.org/guide/ for more info
on memory growth.  Some growth over time is normal and you might want to
use Apache::SizeLimit to control it.

- Perrin




Re: Children dying

2001-08-14 Thread Perrin Harkins

On Tue, 14 Aug 2001, Aleksandr Vladimirskiy wrote:
 I am running a perl 5.6.0, mod_perl 1.26, apache 1.3.19 on Solaris 2.6. I
 get the following error in my logs:
 
 [Tue Aug 14 10:45:10 2001] [notice] child pid 2630 exit signal
 Segmentation Fault (11)
 
 It looks like the child serves a request and immidiately dies.
 
 Does anyone have any ideas on how to figure out why this keeps happenning?

There is info in the distribution and in the guide (debug section) on how
to get stack traces of your code or of Perl itself.
- Perrin




Re: mod_perl s//g

2001-08-14 Thread Perrin Harkins

On Tue, 14 Aug 2001, Rasoul Hajikhani wrote:

 Are there any traps that I should be aware of when using s//g? I was
 reading the online mod_perl docs and could not find anything to that
 effect. But I do recall working with Perrin (correct me if I am wrong
 Perrin) that there were some issues with using global tag in
 substitutions.

No, it's the /o (compile) flag that has issues.  It's in the guide:
http://perl.apache.org/guide/perl.html#Compiled_Regular_Expressions
- Perrin




Re: Restricting MP3 files being served

2001-08-14 Thread Perrin Harkins

 I have a lot of large MP3 files, and want to restrict the number that
Apache
 serves concurrently. Is this possible ? I'm posting it here since I assume
 it would require some sort of module to achieve it. ?? (Win 32).

You want mod_throttle.  I don't know if it works on Windows.
- Perrin




Re: url mangling/rewriting

2001-08-13 Thread Perrin Harkins

  I see. You mean your session state is not stored on the database,
  but stored as encrypted text in session id itself.

 Yes, and the problem is whether there is some good
 algorithm, which will generate this kind of session
 ids. Security is not main part of this solution, but
 easy finding of these session ids is not desirable. ;)

So, it's not really a session ID then; it's your session data.

There are tons of two-way encryption modules on CPAN.  Try looking at
Crypt::CBC.

- Perrin




Re: Compiling with RegistryLoader

2001-08-09 Thread Perrin Harkins

 I try to precompile a perl script on SERVER start-up using the typical
 configuration. But I start the server a get a lot of errors or warnings
that
 refer to standard Perl modules.

It looks like you're having problem stemming from mod_perl executing the
PerlRequire command twice during startup.  Try upgrading to mod_perl 1.26,
which fixes this bug.
- Perrin




Re: my OR our that is the question ?!

2001-08-09 Thread Perrin Harkins

 So what is the REASON for this copy-on-first-call behaviour.(there have to
 be some reason, if i'm not totaly dull to see it )

It's called a closure.  You can read up on it in the Camel book or in Damian
Conway's OO book.
- Perrin




Re: Help with cookies

2001-08-08 Thread Perrin Harkins

 Long time no hear... I heard you moved to NY...

This is true.  I'm exploring new territory.

 I think I do send a response back to Apache! I
 mean I return OK status. Or do you mean something else? Like
 $r-header_out(...)?

You need to send the headers (with $r-send_http_header or something
similar), and print something to the client.  Otherwise, your Set-Cookie
header will never get sent out.

Glad to see you're still mod_perl-ing.

- Perrin




Re: Help with cookies

2001-08-08 Thread Perrin Harkins

 Umm... Is

return OK;

 the correct thing to return when using multiple handlers?

Yes, according the mod_perl docs.  It only stops if you return something
other than OK or DECLINED.

- Perrin




PerlRequire/PerlModule and %INC

2001-08-06 Thread Perrin Harkins

There have been some messages on the Mason list about people experiencing
startup.pl being loaded twice, even without PerlFreshRestart on.  I know the
server restarts during startup, but PerlRequire and PerlModule are both
supposed to obey the laws of %INC, right?  I seem to remember some
discussion about this before, but I can't remember what the outcome was and
I can't find it in the archive.
- Perrin




Re: Again, Modperl running scripts slower than non-modperl!?

2001-08-05 Thread Perrin Harkins

  Not having read anything before this, but it seems that your machine is
  going into swap because there is not enough RAM available.  That kills
 your
  performance always.  Could you run your test on a different machine or
  temporarily switch off the regular server?
 
  Trying to run close to 200 Mbyte modperl Apaches on a 256 Mbyte machine
is
  not going to work.  Have you looked at MaxRequestsPerChild?

 This is set at 0

What are you using to control process size?  Apache::SizeLimit?  It looks
like you have some code that hogs memory, and you'll need to control it
somehow.  Most people have servers more in the range of 10-40MB, with a
bunch of that shared.

- Perrin




Re: odd behavior with Cache::Cache

2001-08-05 Thread Perrin Harkins

on 8/4/01 1:34 PM, brian moseley at [EMAIL PROTECTED] wrote:
 also, has there been any thought given to locking cached
 items? when i'm using a shared cache with multiprocess
 apache, the opportunity exists for multiple requests to
 access a single session simultaneously, which can lead to
 races. which i'm happy to ignore for now but would be nice
 to eventually prevent.

Gunther's Extropia stuff includes optional support for sessions that lock in
the way you're describing, but I've never seen any other session
implementation that did it this way.  It seems that the session pattern is
generally used for transient data where last-save-wins is fine as long as
the integrity of the data is protected during the actual writes.  If you
need fancier locking, you could try ripping the lock stuff out of
Apache::Session.

- Perrin




Re: dbi abstraction layer on perlmonks

2001-08-03 Thread Perrin Harkins

Stas Bekman wrote:

Maybe the guide should include links to the most mature peristence
abstraction layer projects out there:
- Class::DBI
- Alzabo
- Tangram
- SPOPS


I suppose that could fit into the help.pod. Otherwise it's not directly
related to mod_perl, and the guide has to start shrinking rather than
growing.

That's fine.  The guide has become sort of a catch-all for web site 
building techniques, and maybe that should be changed in the interest of 
the maintainer's sanity.

I'd also start working on the new docs for mod_perl 2.0, so I can see an
extended chapter on databases and persistence layers in the users guide.

I vote to cover only the mod_perl specific stuff in there, as you said 
above.

Perrin, would you like to be the database chapter pumpkin?

Possibly.  We should talk more about what would go into that chapter 
when you start working on the new guide.

- Perrin





Re: dbi abstraction layer on perlmonks

2001-08-03 Thread Perrin Harkins

Robert Landrum wrote:

 The guide is a great thing, and removing items from it is risky.

Think of it as refactoring.




Re: More stuff not working with conversion to modperl?

2001-08-01 Thread Perrin Harkins

John Buwa wrote:
 Isnt there a way to clear global variable to a null after a web transaction
 is complete?

Apache::PerlRun does that.
- Perrin



Re: [OT] Inspired by closing comments from the UBB thread.

2001-08-01 Thread Perrin Harkins

 I think a lot of people's approach, including mine, is to have OO Perl
 modules for all database access.  In my code (I use Mason), a web page
 only gets its data through calls like this:

 my $obj = NAIC::User-(DBH=$dbh, EMAIL='[EMAIL PROTECTED]');
 $obj-load;
 my $groups_list = $obj-groups();

 That way any needed SQL changes, or even ports to a new database,
 don't have to be done everywhere in my code.

That's what I do too.  I suppose this could still be called embedded SQL
though.

You could put your SQL in a separate file, but I don't like that approach
because it doesn't seem like you would be changing SQL without changing the
other code very often.  Having your SQL right next to where it's being used
is convenient, and a HERE doc makes it easy to read.

- Perrin




Re: [OT] Inspired by closing comments from the UBB thread.

2001-08-01 Thread Perrin Harkins

 not to mention the HTML embedded all throughout the perl (are they on
 glue?)

 What's the alternative there?  Embed perl in the HTML?

You could do that (Text::Template), or you could use a tool like Template
Toolkit or HTML::Template.  See
http://perl.apache.org/features/tmpl-cmp.html for a description of the
available options.
- Perrin




Re: [OT] Inspired by closing comments from the UBB thread.

2001-08-01 Thread Perrin Harkins

 As for SQL, I just wish people would expand their horizons a little and
 start doing a bit of reading.  There are so many different ways to avoid
 embedding SQL in application code and I sincerely wish programmers would
 THINK before just coding... it's what differentiates scripters from
 engineers and I suggest everyone who embeds SQL in their perl for anything
 other than quick-and-dirty hacks start considering other options for the
 good of the programming community AND THE SANITY OF WHOMEVER HAS TO
MAINTAIN
 OR ALTER YOUR CODE.

 If you wish to see one enlightened approach, please read this:


http://developer.apple.com/techpubs/webobjects/DiscoveringWO/EOFArchitecture
 /index.html

I appreciate your kind words about my templating posts, but I don't agree
that an object-relational mapper is always the right answer for database
integration.  Using objects to model your data, and having the objects
manage their own persistence through SQL calls is faster and easier for many
things, and it allows you to do things that can't be done with an O/R
mapper, like advanced SQL tuning (optimizer hints), aggregation of commonly
fetched data into one query, etc.  You still get encapsulation of the SQL
behind the object interface, and your high-level logic doesn't need to use
any SQL directly.

It would really be nice if someone could write an overview of the O/R
mapping tools for Perl.  I know Dave Rolsky was working on one, but it's a
big job and he's busy with Mason.

- Perrin




Re: Not embedding SQL in perl

2001-08-01 Thread Perrin Harkins

   I have found that stored procedures + perl module wrapper around the
procs.
   is a nice, balanced approach.
  
   The procs. give a nice performance boost as they are precompiled into
the
   server (we use Sybase).

 They are definitely faster, and significantly so.

Maybe so for Sybase.  In Oracle, your SQL statements get cached anyway, as
long as you're using bind variables instead of just dynamically building the
SQL strings.  (They get cached even if you don't use bind variables, but
they'll quickly overflow the cache if you keep changing them with each new
value in the WHERE clause.)

 Using RPC calls instead of language commands also improves speed, and
 solves the quoting problem, too.

The same goes for bind variables.
- Perrin




Re: [OT] Inspired by closing comments from the UBB thread.

2001-08-01 Thread Perrin Harkins

 http://axkit.org/docs/presentations/tpc2001/anydbd.axp

Is this basically a hash of SQL statements, indexed by DBD type?  Or is
there something more that I'm missing?  (I should have gone to your TPC
talk...)




Re: require v.s. do in modperl

2001-08-01 Thread Perrin Harkins

 I have a CGI application where I do:

 require 'db.pl';

 where db.pl defines some functions and variables related to connecting to
 the database, and then executes C$dbh = DBI-connect(...).

snip

 I can get around this by changing Crequire to Cdo, but is that the
 correct way of doing things?

No.  Put the connect stuff in a subroutine and call it from your
application.  Things in the main section of a required file are only
supposed to run once.

- Perrin




Re: Apache::DBI Oracle LOB problem

2001-08-01 Thread Perrin Harkins

 Mmm, haven't seen it, but we use LONG instead of CLOB as the datatype
 for the sequence. Is there any reason to use CLOB, and does using LONG
 make the problem disappear?

Oracle doesn't want you to use LONG anymore.  It's deprecated.

Questions for Steven:
Have you followed all the documentation on using LOBs in DBD::Oracle?  Are
you sure that LongReadLen is set high enough?

- Perrin




Re: require v.s. do in modperl

2001-08-01 Thread Perrin Harkins

Gunther Birznieks wrote:
 
 At 07:16 PM 8/1/2001 -0400, Perrin Harkins wrote:
   I have a CGI application where I do:
  
   require 'db.pl';
  
   where db.pl defines some functions and variables related to connecting to
   the database, and then executes C$dbh = DBI-connect(...).
 
 snip
 
   I can get around this by changing Crequire to Cdo, but is that the
   correct way of doing things?
 
 No.  Put the connect stuff in a subroutine and call it from your
 application.  Things in the main section of a required file are only
 supposed to run once.
 
 I am not sure, but I don't think connect() is only supposed to run once
 especially with Apache::DBI?

Right, and at the moment he has it in the main section, so it's only
running once.  He should move it to a sub and call it from his
application so it gets run every time.



Re: Buffering Output

2001-07-31 Thread Perrin Harkins

 Anybody know if exist some module how CGI::Out for buffering output in CGI
script ?

Is there a reason you can't just append everything to a variable until the
end?  If that won't work, you can tie STDOUT.  Apache::Filter might help.
- Perrin




[ANNOUNCE] Perl Templating Guide, v 0.9

2001-07-31 Thread Perrin Harkins

http://perl.apache.org/features/tmpl-cmp.html

The article Choosing a Templating System is now available at the above
URL.  This is the same material I presented at the O'Reilly conference,
but a bit less rushed.  It gives an overview of currently available
templating tools and their basic features.

This version is bound to have some bugs and general foolishness in it,
so please send me an e-mail if you spot anything.

Some ideas for future versions:
- Code sample for each system
- Links to other articles for each system
- More complete benchmark information
- Recommended practices for using templates in general

Slouching towards 1.0,
Perrin



Re: RewriteRule Proxy problems

2001-07-30 Thread Perrin Harkins

 In my lightweight httpd.conf, I have:

 RewriteRule ^/(.*)\.asp http://66.33.85.239/$1.asp [p]

 If I go to http://www.buildreferrals.com/rotatorstats.asp, it gets proxy'd
 correctly.

 But if I go to http://www.buildreferrals.com/rotatorstats.asp?login=pmak0
 (that's the same URL, but with a query string added), then I get a 404
 Not Found error.

Of course you do. Your regex ^/(.*)\.asp doesn't match that URL with the
query string.
- Perrin




Re: RewriteRule Proxy problems

2001-07-30 Thread Perrin Harkins

   But if I go to
http://www.buildreferrals.com/rotatorstats.asp?login=pmak0
   (that's the same URL, but with a query string added), then I get a
404
   Not Found error.
 
  Of course you do. Your regex ^/(.*)\.asp doesn't match that URL with
  the query string.

 Why not? I did not put a $ at the end of the regexp so it should still
 match. I've also tried:

 RewriteRule ^/(.*)\.asp(.*) http://66.33.85.239/$1.asp$2 [p]

 but got the same 404 Not Found error.

Sorry, I should have said that it wouldn't match the query string itself.
(I'm a little under-rested and over-caffeinated at the moment.)  Looking
back at your post, it seems like it still should have worked although it
would have had no query string in the proxied request.  You might try
^/(.*)\.asp(.*)$ for matching the whole query string, but I wouldn't thing
it would be necessary with a greedy regex.
- Perrin




Re: Child Interprocess Data

2001-07-23 Thread Perrin Harkins

 Kevin Schroeder wrote:
 I want to create a program for mod_perl that shares information in
 between all the child processes so they all have current information.

There are many CPAN modules that cover this.  Check the guide at
http://perl.apache.org/guide/.  One option that's easy to get started
with is the MLDBM::Sync module, which uses dbm files for sharing.

- Perrin



Re: custom config directives

2001-07-14 Thread Perrin Harkins

 is there any good thorough documentation on building custom
 config directives other than what's in the eagle book? i
 left mine back in au and i don't really want to buy another
 one :)

You're in luck, that chapter is on-line:
http://www.modperl.com/book/chapters/ch8.html




Re: help about ap_pool in Perl

2001-07-11 Thread Perrin Harkins

 I need to save some status informations about each request (in my
 filter each request passes through 3 phases : PerlTransHandler,
 PerlAccessHandler and PerlHandler.

You want $r-pnotes.

- Perrin




Re: [ANNOUNCE] Hello World Benchmarks, updated

2001-07-11 Thread Perrin Harkins

Good work as usual, Joshua.

  mod_caucho
 used to look a lot faster, but my testing methodology changed.
 I used to take the results of the second benchmark run, and
 publish those, but this time only ran the -test for minor
 caching after starting resin (  tomcat ).  So, I'm guessing
 that mod_caucho compiles aggresively in the beginning, killing
 performance for a dry run ( even 60 seconds! ).  To improve
 the numbers for mod_caucho using this methodology might require
 and longer test cycle than 60 seconds.

Ouch!  I would think it's worth doing one full run to prime each system.  Or
do you feel a need to include the initial compilation time?

- Perrin




Re: [ANNOUNCE] Hello World Benchmarks, updated

2001-07-11 Thread Perrin Harkins

Good work as usual, Joshua.

  mod_caucho
 used to look a lot faster, but my testing methodology changed.
 I used to take the results of the second benchmark run, and
 publish those, but this time only ran the -test for minor
 caching after starting resin (  tomcat ).  So, I'm guessing
 that mod_caucho compiles aggresively in the beginning, killing
 performance for a dry run ( even 60 seconds! ).  To improve
 the numbers for mod_caucho using this methodology might require
 and longer test cycle than 60 seconds.

Ouch!  I would think it's worth doing one full run to prime each system.  Or
do you feel a need to include the initial compilation time?

- Perrin




Re: [ANNOUNCE] Hello World Benchmarks, updated

2001-07-11 Thread Perrin Harkins

 I do feel that compile time matters, but really with 60 seconds
 and high MaxRequestsPerChild, these systems are getting plenty
 of compiling caching.

The thing is, if mod_caucho takes 5 seconds the first time it hits each
template, but is the fastest afterwards, these numbers don't give a very
accurate picture of that.  Most people expect a hit on the first access.

 if we wanted to do away with compile
 time entirely, we'd make sure that each system got to precompile
 all its templates like Apache::RegistryLoader, Apache::ASP-Loader()
  Embperl's Execute() in the parent httpd.

No need for anything that fancy.  I'd say just run the test once as a primer
and throw away the results, like you were doing before.  It could be for 10
seconds instead of 60.

 compile time is a very real problem for some
 types of apps like large web sites, and there is an increased
 burden on optimizing each benchmark, which implies an expertise
 in the development environment that many users may not
 have normally.  I have been trying for more out of box benchmarks,
 and not highly optimized benchmarks, using mostly the shipping
 config for a system.

I feel like allowing the templates to compile isn't tuning, just ignoring
startup costs.

 People have suggested before ( you? ) to do two runs, and
 average the results, and I think that this is a fair approach,
 and might be better than just doubling the test time because
 the systems might interact, better yet, do them in one order,
 and then reverse them, to average out sequential interactions
 of the tests on a system ( ??? )

I wouldn't worry about them interacting so much, but I did suggest running
multiple times and averaging.  I think it helps smooth out random bad runs,
which do happen now and then.

Any numbers on the new Apache::ASP CGI mode?

- Perrin




Re: Using mod_perl handlers for max speed?

2001-07-11 Thread Perrin Harkins

 Does this mean that if there's a heavily used script on my system that
 needs to be VERY fast, then it may be worth making it into a mod_perl
 handler?

Not unless you get astonishing amounts of traffic and your script does
almost nothing.  These are very simple test cases, so they exaggerate the
speed differences.  (Intentionally.)  However, you should be aware that
handlers rock, and many of us consider them more fun than Registry scripts.
Registry scripts have their fans as well, of course.

 What are the caveats of using mod_perl handlers instead of normal
 scripts?

You can read more here:
http://perl.apache.org/guide/porting.html#Transitioning_from_Apache_Regis

- Perrin






Re: detecting ssl

2001-07-10 Thread Perrin Harkins

 no need to do a lookup or rely on PerlSetupEnv On I wouldn't think...

 my $ssl = Apache::URI-parse($r)-scheme =~ m/^https/;

Or maybe just look at the port # of the request.
- Perrin




Re: 2 questions

2001-07-09 Thread Perrin Harkins

 I've sent this email to Template-Toolkit mailing list... but there doesn't
 seem to be anyone, so I'm sending it here ...

Um, you did send it at 6:30PM on a Sunday (yesterday).  Support on that list
is really good, but you can't expect everyone to be on the same schedule as
you.

 How can in the parent template distinguish between these two cases
(if
 scalar place it, if file include it ).

You could handle this with a plugin.  The plugin would determine what kind
of thing $stuff is, and then call the appropriate TT methods to handle it.
In your template you say something like:

[% MY_INCLUDE $stuff %]

 I need a way to replace the web-designer
 inputs,select boxes, textareas with thouse generated from me, but also
want
 to preserve the formating/styles etc.. f.e.

There are basically two ways people do this.  One is to replace the standard
HTML elements with your own, e.g. select size=10 name=foo becomes [%
form.select(size = 10, name = foo) %].  The other is to post-process the
resulting HTML with something like HTML::FillInForm.  That could be done
inside a FILTER block.  If the first appeals to you more, but you don't want
your designers to have to think about it, you could pre-process the
templates to translate the form elements to TT syntax.

There's plenty of documentation for this module that covers the details of
plugins and filters.

- Perrin




Re: Apache::SimpleTemplate (don't do it!)

2001-07-09 Thread Perrin Harkins

 I think that CGI::FastTemplate does all of that.
 Please have a look at it, and see if everything you need is not
 already in it.

It's a good module for CGI, since it doesn't rely on caching/compiling
techniques, just simple regex stuff.  It will use a lot less RAM than tools
that compile in-line perl, because it doesn't eval anything or cache
anything.  The only real downside of this module is that coding repeated
sections (loops) can't be done in-line, i.e. you have to use multiple files.
That's a bit of a pain.

- Perrin




Re: CGI module or Apache

2001-07-09 Thread Perrin Harkins

Take a look at http://perl.apache.org/guide/ and read the stuff on libapreq.
- Perrin




Re: The latest templating system: PSP in DDJ

2001-07-09 Thread Perrin Harkins

 What is needed, IMHO, is a clear
 framework,/description/phlogeny/geneology of perl templating systems.

I'm writing such a beast for TPC this month, and will publish it when it's
ready.  I'm not covering every templating module on CPAN though, just the
ones that people seem to actually use based on mailing list traffic.
(Don't e-mail your But I use such and such messages yet.  Wait until you
see my list.)  This is mostly for sanity purposes -- there's just too many
to cover all of them in a meaningful way.

It won't solve all the world's problems, but it might help some people find
a tool that suits them.

- Perrin




RE: ePerl (fragment of Re: Apache::SimpleTemplate)

2001-07-08 Thread Perrin Harkins

 We use ePerl for a fair number of things, and I have yet to run into
 something we needed of which it was not capable.   What are you
 thinking of?

It's not a question of it not being capable, it's just that most people seem
to choose one of the more full-featured tools.  There's lots of talk on the
list about Apache::ASP, Embperl, Mason, etc., but not much about ePerl.
(Maybe I should do some research in the mail archives and graph the results.
Sounds like a magazine column...)  Also, I think Text::Template stole some
users away from ePerl.

Like SSI, ePerl is perfect for some people who just want a simple solution
that stays out of their way.

Also, I believe that security issue Ged referred to was fixed by the author.

- Perrin




Re: Apache::SimpleTemplate

2001-07-08 Thread Perrin Harkins

on 7/8/01 2:46 AM, Gunther Birznieks at [EMAIL PROTECTED] wrote:
 In addition one of the criteria for useful to me is fast. If the
 template system is slow, it's quite annoying. However, this goes against
 other people's ideas of useful being full featured. As Steven Wright
 says (paraphrased) if you had everything where would you put it?

I think this is more of an issue with CGI.  All of the popular tools are
fast enough under mod_perl that they're very unlikely to be your bottleneck.
It's far more likely to be database work or IPC of some kind that slows down
an application.

Under CGI, the caching schemes of many of these systems don't work.  That
does make a difference.

- Perrin




Re: Apache::SimpleTemplate

2001-07-07 Thread Perrin Harkins

 yes, i have *yet another* templating mechanism for
 mod_perl, and i'd like to add it to CPAN if there are
 no major objections.

I hate to be a naysayer, but this doesn't look sufficiently different from
the other options to merit adding it to CPAN.  The trouble is, there are
already too many of these and it looks an awful lot like Apache::ePerl, or
Text::Template.  At the moment you may think there's a need for it because
it's simpler and smaller, but it will almost certainly grow over time.

If you look at the other modules and still think what you have is truly
different, please elaborate a little on why.  No one here is actually going
to stop you from posting it to CPAN, but I will try to talk you out of it if
there's no clear reason to prefer this over other tools.  I mean, just look
at the train wreck you get back from this:
http://search.cpan.org/search?mode=modulequery=template

- Perrin




Re: The latest templating system: PSP in DDJ

2001-07-07 Thread Perrin Harkins

on 7/7/01 9:30 PM, Ron Pero at [EMAIL PROTECTED] wrote:

 Just received my issue of Dr. Dobbs Journal today, and one of the articles
 is A Tiny Perl Server Pages Engine. Pretty nifty.
 
 Read about it here:
 http://www.ddj.com/articles/2001/0108/0108g/0108g.htm
 
 Here is an excerpt:
 PSP is modeled after JSP. It is neither an ASP nor a JSP port. PSP
 includes many JSP-like features and, most importantly, custom tag support.
 The latter gives you the ability to develop custom tag modules to
 encapsulate complex server-side behaviors and business rules into simple
 XML-like elements that content developers can use.
 PSP shares the same basic elements with JSP...

Good grief!  This sounds exactly like Apache::ASP with its XMLSubs feature.
I give up.
- Perrin




Re: returning one instance of an object per request

2001-07-06 Thread Perrin Harkins

 I'm building a web application that has a User perl module.  I have
several other perl modules that need to know the user id of the current
logged in user (or 0 for a guest user).  I was thinking that I could write
the User class in such a way that every time (except the first) a
constructor was called the same instance of the user object would be
returned for each apache request.

 Is this the best way to go about solving my problem?  If so what's the
best way to implement this?  Or maybe I should just pass around the user id
to every class?  I'd perfer to avoid this if possible.

Try this:

sub get_user {
my $user = Apache-request()-pnotes('USER');
if (!$user) {
# first time for this request
$user = MySite::User-new(); # or whatever
Apache-request()-pnotes('USER', $user);
}
return $user;
}

Put it in some utility class that your other classes all use.
Alternatively, you could make your User class cache itself in pnotes and
just have everyone call new(), but that assumes you'll never want to use it
outside of mod_perl.  Also see Class::Singleton.

- Perrin




Re: mod_perl child processes using way too much RAM

2001-07-02 Thread Perrin Harkins

 2.  Cause any httpd_perl child process which exceeds 20 megabytes in
 memory usage to terminate after it's done.

Apache::SizeLimit (and others) can do this.
- Perrin




Re: API Design Question

2001-06-30 Thread Perrin Harkins

 The minimal-module approach can be managed nicely via Autosplit, which
 puts eash sub in its own module with a stub AUTOLOAD that snags things
 into core only when they are called

Note that if they do get called this will end up using more memory than if
you had just loaded them during startup, since they won't be shared between
child processes.
- Perrin




Re: SSI Lost with Mod Perl?

2001-06-26 Thread Perrin Harkins

 I've given Filter and SSI a shot according to the perldocs.

 It didn't work.  I stated to hhack on some of the problems, which first
involved
 in the make install depositing them in the wrong diretory, and then they
SSI
 needed use Apache::Filter statements added.

 Finally, Filter cam back with an error that something or other $r wasn't a
 hash reference, which would not be a quick fix.

 So I've sort of hacked up my own little SSI for the time being and
 deposited it in the modules.

Sorry it didn't work for you.  I've never used Filter, but I used
Apache::SSI with great success.  You weren't trying to use Filter with
mod_include (i.e. not Apache::SSI) were you?

Anyway, there's another CPAN module you can use called CGI::SSI_Parser which
might fit your needs.

 I'm definetely bathing in a Brooklyn Larger Bath when this is done.

I prefer the IPA, taken orally.

- Perrin




Re: SSI advocacy Was:: Multiple AddHandler statements

2001-06-24 Thread Perrin Harkins

Joachim Zobel wrote:
 Including If-Modified-Since - 304 responding?

No, none of them handle that (well, AxKit?), probably because most sites
need to do more than stat-ing the template files to determine if the
page content has been modified.  A site with no dynamic content could be
pre-generated with a make-like procedure and served statically.

 In fact my main objection to the majority of templating systems is that
 they are frameworks. I am using a homegrown template engine at the moment
 and probably would be using template toolkit if I started now, but I
 definitely hate to be framed at work:)

Template Toolkit, Text::Template, and HTML::Template are all pretty good
at staying out of your way.  They're not frameworks like Mason and
Embperl.

But hey, if you like SSI then go ahead and use it.  It's good at what it
does.  I was just pointing out that the templating tools are pretty
solid as well.

- Perrin



Re: SSI Lost with Mod Perl?

2001-06-24 Thread Perrin Harkins

Brooklyn Linux Solutions CEO wrote:
 
 I have modules controlling all the files and their access and content  in the
 directy.  I have no idea
 really why SSI is shut down.  I never used it before.

It looks like you're trying to post-process the output of a PerlHandler
with SSI.  The only way to do that is by using Apache::SSI and
Apache::Filter, as described here:
http://search.cpan.org/doc/KWILLIAMS/Apache-SSI-2.16/SSI.pm

- Perrin



Re: SSI Lost with Mod Perl?

2001-06-24 Thread Perrin Harkins

 IS there a way of pre-processing and post processing a handler?

Only by using something like Apache::Filter.  Apache itself does not support
chaining handlers.

- Perrin




Re: SSI Lost with Mod Perl?

2001-06-23 Thread Perrin Harkins

 I've seemed to have lost my ability to use SSI whenI use the content
 handlers with Mod_perl.


 Is there anyway I can fix this?

Can you be more specific about what you're trying to do?  You can still use
mod_include with mod_perl installed, and you can use Apache::SSI either
alone or as a filter with Apache::Filter.  Does that help?

- Perrin

(P.S. I'm in Brooklyn too!)




Re: SSI advocacy Was:: Multiple AddHandler statements

2001-06-22 Thread Perrin Harkins

 At 14:33 19.06.2001 +0530, you wrote:
 Is there something in SSI which cant be done in a better way using Perl
 ??

 Yes.

 1. SSI with XBitHack full plays the 304 game for me. Every time the
catalog
 database is updated, its SSI frame gets a touch. Thats it. Simple.
Efficient.

 2. SSI provides a way to modularize static HTML. I have lots of small
 HTML snippets. Many of them are generated by a content manager. These
 snippets are put together using SSI.

 3. Performance.

Most of the perl templating systems would be just as good on these points,
and would allow you to catch errors if you are willing to wait until the
whole document is generated before sending.  They also perform about the
same, with Apache::SSI actually beating mod_include in my benchmarks.
However, SSI has one thing going for it, and that's memory usage.  It
doesn't cache pages in memory (neither the C or Perl version), so it doesn't
grow as it processes new pages.  (Well, it grows to the size of the biggest
single page processed.)  This means you can use it on a site with thousands
of unique pages and not worry that all of them will end up cached in memory
for each mod_perl process.

I think the original question on this thread was how to post-process CGI
output through SSI.  I've done this using Apache::SSI, just collecting my
output in a string and then feeding it to Apache::SSI, which provides a
method you can call for this.  You could also look at CGI::SSI_Parser, which
I have not used.

- Perrin




Re: Curious About Require

2001-06-20 Thread Perrin Harkins

   BEGIN {
   delete $INC{'/foo/bar/query.pl'} if exists
$INC{'/foo/bar/query.pl'};
   require '/foo/bar/query.pl';
 }
 
  Mark, your suggestion doesn't work because of BEGIN.

 Ooops, gotta go to sleep. Your suggestion, Mark, will work :) but only in
 Registry/PerlRun which executes BEGIN on every request.

It only needs to do the require once per script, so if you put this in each
script it will be fine.  Also, I don't think Registry runs BEGIN blocks
every time.  Can't remember about PerlRun.

 BTW, here is shorter version of your suggestion:

 BEGIN { do '/foo/bar/query.pl'; }

That's what I used when porting someone's old perl4-ish code to PerlRun.
Both of these quick fixes waste memory though.

- Perrin




Re: ModPerl package Q

2001-06-20 Thread Perrin Harkins

 Well, this is the last time I am going to bring this up. I am on Apache
NT,
 and I have the following .pm file that I believe I localized everything in
 order to create a socket. The code below does work.  But it never makes a
 new socket. As you can see I print out the IO::Socket::GLOB and it shows
the
 same 'reference' 10xff036c each time through. I realize this is because I
am
 not closing and undef the $sock. (see the commented close and undef
towards
 the end). But this works. Except if I shut down the machine I am calling
the
 socket on. Then it dies and never comes back unless I reboot apache. Not a
 good work position to get a web site into.

 But here is the catch. If I do close the socket and either undef or even
 leave that commented out, I only get one send to the socket, and one
reply,
 but it never sends another reply to the server and never gets another
 response back? But yes, it creates a new socket ref each time?

It looks to me like you have a problem with scoping and closures.  Try
making $sock a global, i.e. change my $sock; to use vars qw($sock);.
Then put your close and undef stuff back in.

- Perrin




Re: Curious About Require

2001-06-20 Thread Perrin Harkins

I hate to belabor this point, but I don't want people to get the wrong idea:

  BEGIN { do '/foo/bar/query.pl'; }

 Sorry, I guess I should have been more explicit. I don't want to
 require in the file on every request, but rather only allow the
 same file to be require'd multiple times (to install the same sub
 routines into different packages).

That's what this accomplishes.  It only runs once, being inside of a BEGIN
block.  Using do() instead of require() skips the %INC check, so you don't
have to delete anything from %INC this way.  Of course, do() doesn't check
to see if your module returned true, but they are basically equivalent.
TMTOWTDI.

- Perrin




Re: Cached Code Disappeared?

2001-06-19 Thread Perrin Harkins

 Still seeking assistance form anyone who is experienced with sockets and
 mod-perl /apache on NT.

No NT here, but...

 Anyway, as my previous email showed, I built a site which used a global
 filehandle to a socket. It worked great for about two hours, and then all
of
 a sudden stopped. After rebooting the apache server, all worked well
again.

 I am thinking that the cached code probably went away since no one hit it
 for a while? Does apache give back cached scripts after a certain time of
 not being used?

Not exactly.  An apache child process will eventually die if there's nothing
to keep it busy, but at least one process will always remain, and on Windows
there is always exactly one at any given time (with mod_perl).  If you're
using MaxRequestsPerChild or Apache::SizeLimit or something similar, the
process will eventually be killed and a new one will take it's place,
meaning that code cached during startup.pl/httpd.conf will still be cached
but anything cached in that child will be gone.

You probably don't want to try and change this behavior, since it keeps
processes from growing too large.  However, you should make sure that you
aren't trying to open a socket (or filehandle, or database handle) in the
parent process (during startup) and use it in the children.  Each child will
have to make a new socket the first time.

Hope that helps,
Perrin




Re: Capturing CGI output

2001-06-17 Thread Perrin Harkins

From: Steve Wells [EMAIL PROTECTED]
 I can use $r-lookup_uri('/cgifile.cgi') to gather up the subrequest and
 run it using the run() command.  However, the information from the CGI
 is passed back to the browser instead of handed off to me for
 processing.  Is there some way to capture that information?

You could use LWP to make the request instead of using a subrequest, or you
could use a modified version of Apache::PerlRun or Apache::Registry that
fakes CGI and captures the output.  You can look at Apache::Filter for some
ideas.

- Perrin




Re: templating benchmarks...

2001-06-13 Thread Perrin Harkins

  wow. template toolkil took a big hit, there. (no mod_perl on
  this list? hmm!)

 This benchmark can be very non-representive. If you don't know how to
 optimize each and every thing under test, you end up with unfair
 benchmark and come to potentially wrong conclusions. Take TT, add compiled
 template caching on the disk and shared TT object and I bet TT won't be at
 the bottom.

I actually helped Joshua tune the TT example a little, and it using a cached
Template object and caching the templates used in the test in memory.  The
slowness comes from the fact that it provides a major feature that the
others don't, and it is being exercised in this test.  The magic dot
notation which allows templates to say foo.bar.baz, regardless of what kind
of data structure, object, or code ref foo, bar, and baz may be takes
a little more work.  Whether it's a good idea or not is left as an exercise
to the reader, but I will say this: if Template Toolkit is the bottleneck in
your app's performance, you have either done some serious tuning or written
a really simple application (like this benchmark).

Nevertheless, it's good to see some numbers, if only to convince Andy to
finish his optimized XS version of the TT stash.

- Perrin




Re: templating benchmarks...

2001-06-13 Thread Perrin Harkins

Tom Lancaster [EMAIL PROTECTED] wrote:
 Absolutely. But I'd like to bring up something I've noticed in
benchmarking
 'real' sites: many, if not all, of the templating solutions appear to
 parse the whole of an html page. This is at least true of Apache::ASP and
 HTML::Mason, which I have used. Is it not ?

Not really.  They all cache the page in memory.  It is not re-parsed every
time.

 I have produced really dramatic differences in performance in a two-tier
 setup by judicious use of mod_include vs. wholesale proxying of pages
 with dynamic content through to the mod_perl/Apache::ASP server.
[snip]
 Granted, I have other major bottlenecks involved: using Berkeley DB v1.x
 for session state, for one. Perhaps this explains some of it -- maybe the
 proxied header/footer requests never make session calls.

I suspect that it's a combination of the database access and the network
transfer.  There is no difference in the amount of parsing going on, since
it's all cached after the first time (per child).

- Perrin




<    4   5   6   7   8   9   10   11   12   13   >