You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Carl Eklof <ca...@yahoo.com> on 2005/12/19 23:14:15 UTC
Using EmbPerl's Caching Functionality
As part of my performance tuning, I thought I'd also give the new caching functionality a whirl. I did get it to work, and when it did, it worked very well (thanks Gerald). BTW, I found some posts from people that want the cache to be disk-backed, but I MUCH prefer it to be in memory, as being disk-backed would produce much worse performance that dynamically generating pages for me, especially under high-load.
I did encounter a couple problems, one of them is still preventing me from using the caching.
1) I couldn't get EMBPERL_CACHE_KEY_FUNC, or EMBPERL_EXPIRES_FUNC to work in my httpd.conf (and I do have Embperl_UseEnv on) Trying to set either one would cause Apache to seg fault.
Setting
EMBPERL_CACHE_KEY_FUNC "sub {$ENV{REQUEST_URI}}"
or
EMBPERL_EXPIRES_FUNC "sub {1}"
...and making a request would cause the following in the error_log:
[Mon Dec 19 16:38:23 2005] [notice] child pid 9518 exit signal Segmentation fault (11)
2) I got the EMBPERL_EXPIRES_FUNC functionality to work by specifying and EXPIRES sub in my base.epl. As in:
[!
sub EXPIRES {
<decide to return 0 or 1>
}
!]
However, I couldn't get the documented &CACHE_KEY sub to get invoked. I tested by putting a print to STDERR, which never printed anything. This prevents me, and probably others from using the caching because EmbPerl's default computation of a cache key doesn't seem to make a distinction between:
- http://coolhost.com/foobar
and
- http://coolhost.com/helloworld
...which is a very important distinction on my site, thus I would get the /foobar page, when making a request for /helloworld, or vice versa.
Does anybody have any working sample of the EMBPERL_CACHE_KEY_FUNC?
Happy Holidays,
-Carl
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Using EmbPerl's Caching Functionality
Posted by Gerald Richter <ri...@ecos.de>.
>
> Setting
>
> EMBPERL_CACHE_KEY_FUNC "sub {$ENV{REQUEST_URI}}"
> or
> EMBPERL_EXPIRES_FUNC "sub {1}"
>
> ...and making a request would cause the following in the error_log:
>
> [Mon Dec 19 16:38:23 2005] [notice] child pid 9518 exit
> signal Segmentation fault (11)
>
Do you have any chance to run this under gdb and send me a stackbacktrace?
If possible, compile Embperl with
perl Makefile.PL debug && make
>
> However, I couldn't get the documented &CACHE_KEY sub to get
> invoked.
Mmmh, I have to check this and will get back to you as soon as I found a
little time...
Gerald
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Using EmbPerl's Caching Functionality
Posted by Carl Eklof <ca...@yahoo.com>.
I should have included my version info:
EmbPerl 2.0.0 (official release, not a beta)
Apache 2.0.54
----- Original Message ----
From: Carl Eklof <ca...@yahoo.com>
To: embperl@perl.apache.org
Sent: Monday, December 19, 2005 17:14:15
Subject: Using EmbPerl's Caching Functionality
As part of my performance tuning, I thought I'd also give the new caching functionality a whirl. I did get it to work, and when it did, it worked very well (thanks Gerald). BTW, I found some posts from people that want the cache to be disk-backed, but I MUCH prefer it to be in memory, as being disk-backed would produce much worse performance that dynamically generating pages for me, especially under high-load.
I did encounter a couple problems, one of them is still preventing me from using the caching.
1) I couldn't get EMBPERL_CACHE_KEY_FUNC, or EMBPERL_EXPIRES_FUNC to work in my httpd.conf (and I do have Embperl_UseEnv on) Trying to set either one would cause Apache to seg fault.
Setting
EMBPERL_CACHE_KEY_FUNC "sub {$ENV{REQUEST_URI}}"
or
EMBPERL_EXPIRES_FUNC "sub {1}"
...and making a request would cause the following in the error_log:
[Mon Dec 19 16:38:23 2005] [notice] child pid 9518 exit signal Segmentation fault (11)
2) I got the EMBPERL_EXPIRES_FUNC functionality to work by specifying and EXPIRES sub in my base.epl. As in:
[!
sub EXPIRES {
<decide to return 0 or 1>
}
!]
However, I couldn't get the documented &CACHE_KEY sub to get invoked. I tested by putting a print to STDERR, which never printed anything. This prevents me, and probably others from using the caching because EmbPerl's default computation of a cache key doesn't seem to make a distinction between:
- http://coolhost.com/foobar
and
- http://coolhost.com/helloworld
...which is a very important distinction on my site, thus I would get the /foobar page, when making a request for /helloworld, or vice versa.
Does anybody have any working sample of the EMBPERL_CACHE_KEY_FUNC?
Happy Holidays,
-Carl
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Using EmbPerl's Caching Functionality
Posted by Gerald Richter <ri...@ecos.de>.
>
> I don't see a way to explicity tell EmbPerl to 'not cache'
> certain pages. I ended up making the cache_key_func call
> another sub that performed additional logic to set the key to
> "", and I used a EMBPERL_EXPIRES_FUNC to always expiring
> those queries.
>
Another way would be to put the CACHE directives inside <Location> or
<Files> block to limit it to only some page
>
> The only awkwardness I'm now seeing is that Embperl seems to
> sometimes call the cache_key_function multiple times per
> request. I added a 'print STDERR 'FOO' to the sub, and I
> occationally see the message get printed multiple times (~11).
>
Ok, there are surely some potential for optimizations...
Gerald
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Using EmbPerl's Caching Functionality
Posted by Carl Eklof <ca...@yahoo.com>.
Hello,
I applied the patch, and caching now works (thanks Gerald!). I tested the following lines in my httpd:
EMBPERL_CACHE_KEY_OPTIONS 0
EMBPERL_CACHE_KEY_FUNC "sub {return $ENV{REQUEST_URI}}"
Which seems to have solved my problem of the cache not making the distinction between:
http://host/foobar
and
http://host/helloworld
I don't see a way to explicity tell EmbPerl to 'not cache' certain pages. I ended up making the cache_key_func call another sub that performed additional logic to set the key to "", and I used a EMBPERL_EXPIRES_FUNC to always expiring those queries.
The benchmark results so far show a very significant improvement (>2x) when replaying the user logs for a duration of time about as long as the expiration time. I have a lot of queries to the home-page for each city, so caching those alone is significant. Incase anybody is currious to see another EmbPerl site, mine is at (http://beethere.net/). I should have caching on the live site in the next couple days.
The only awkwardness I'm now seeing is that Embperl seems to sometimes call the cache_key_function multiple times per request. I added a 'print STDERR 'FOO' to the sub, and I occationally see the message get printed multiple times (~11).
I highly recommend applying the patch, and giving caching a whirl. It's a nice performance gift from Gerald, and easier to set up than most dedicated caching systems.
Happy Holidays,
-Carl
----- Original Message ----
From: Gerald Richter <ri...@ecos.de>
To: Carl Eklof <ca...@yahoo.com>; embperl@perl.apache.org
Sent: Wednesday, December 21, 2005 00:13:30
Subject: RE: Using EmbPerl's Caching Functionality
Hi,
> 1) I couldn't get EMBPERL_CACHE_KEY_FUNC, or
> EMBPERL_EXPIRES_FUNC to work in my httpd.conf (and I do have
> Embperl_UseEnv on) Trying to set either one would cause
> Apache to seg fault.
>
>...
> Does anybody have any working sample of the EMBPERL_CACHE_KEY_FUNC?
>
The attached patch should fix both the xx_FUNC parameters in httpd.conf.
Note that EMBPERL_CACHE_KEY_FUNC can only be defined in httpd.conf, but not
inside the page itself (as EMBPERL_EXPIRES_FUNC does)
Gerald
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
RE: Using EmbPerl's Caching Functionality
Posted by Gerald Richter <ri...@ecos.de>.
Hi,
> 1) I couldn't get EMBPERL_CACHE_KEY_FUNC, or
> EMBPERL_EXPIRES_FUNC to work in my httpd.conf (and I do have
> Embperl_UseEnv on) Trying to set either one would cause
> Apache to seg fault.
>
>...
> Does anybody have any working sample of the EMBPERL_CACHE_KEY_FUNC?
>
The attached patch should fix both the xx_FUNC parameters in httpd.conf.
Note that EMBPERL_CACHE_KEY_FUNC can only be defined in httpd.conf, but not
inside the page itself (as EMBPERL_EXPIRES_FUNC does)
Gerald
** Virus checked by BB-5000 Mailfilter **