[need for advices] fastCaching
| From: | MARTY Fabien | Date: | Sun, 21 Jul 2002 01:06:19 +0000 |
| Subject: | [need for advices] fastCaching | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-7807@lists.php.net to get a copy of this message | ||
Hello,
I have made some benchs of the Cache Package with ab (apache tool in
/sbin). To make them, I have used :
(you have to be root)
ab -c 10 -n 1000 http://127.0.0.1/...
With PEAR/Cache, I obtain near 30 requests per second.
This result is enough in most cases but I find that the result is not
good for a cache solution.
The Cache package is a wonderfull one. It uses a container approach and
it is very well coded. It is completly flexible... But...
Maybe, for a caching solution, the most important thing is perfs, isn't
it ? On the other hand, it's not a solution to make it in a opposite way
and not in the spirit of PEAR.
So as the problem seems to be difficult, I have made a lot of benchs
tonight and I think that bad perfs (relatively) reasons are :
- container approach
- require_once('PEAR.php');
For the first one, I would say that the container approach is a
seductive way but in most cases, only the file container is used ! So
maybe, it's not necessary to use a container approach.
For the second one, this single line burns a lot of time. But without
it, you can't use PEAR error system...
So I have written a class (called fastCache) less flexible and maybe
less powerfull than PEAR/Cache. There is no container approach. The
cache is stored in files. For the problem of require_once('PEAR.php'), I
use the following idea :
- in most cases, the class doesn't include anymore.
- but if an error is detected, the class will include PEAR.php
dynamically (with include_once and not require_once) and then will call
PEAR::raiseError
Benchs give near 150 requests per second (so 5 times more than
PEAR/Cache).
So in my opinion, it would be a good thing to have it in PEAR (to give a
choice to PEAR users).
Advices are welcome ! :-))
Fabien
Nota : The class is attached
Attachment: [application/x-php] fastCache.php
Attachment: [application/x-php] fastCache.php