I've recently got stuck on a small problem. I use aggregate plugin which generates huge images from variety of data-sources. Those images are continously being watched by service-desk team, moreover - several applications are fetching them as well.
I've wrote a small experimental plugin which caches images in shared-memory after they were watched. It also adds a small informational legend on the bottom of the image.
without memorize plug-in generating one image on quad-core machine with 4gigs of ram takes from 2.5 to 6 seconds (depending on poller is running or not). With memorize plugin installed, cached images are returned within 1 microsecond and less (from 4000 to 7000 times faster).
Browser renders images on the fly and pooler gets extra cpu resources, while RAM consumption is relatively small.
moreover, png images are compressed up to the max, so average image size drops ~10%:
without memorize: 91.73 KB (93927 bytes)
with memorize: 78.96 KB (80853 bytes)
here are some examples:
when poller isn't running:
when poller is running:
after simple refresh memorize starts doing it's job:
poller isn't running:
poller is running:
memorize statistics when poller isn't running:
Code: Select all
displayed graphs count: 4
rendered from rrd: 2
rendered from cache: 2
avg rrd render time: 2.600489
avg cache render time: 0.000336
benefit(times): 7739.550595
used cache memory size: 361947
Code: Select all
displayed graphs count: 4
rendered from rrd: 2
rendered from cache: 2
avg rrd render time: 6.138474
avg cache render time: 0.001444
benefit(times): 4251.020776
used cache memory size: 361982
after downloading it, please see "README". Most likely you will have to tune some kernel parameters to cache more images.
Also, make sure you have the following extensions enabled in php.ini (or statically compiled-in):
php-gd2 with FreeType lib - to see statistical information on image
shmop - to cache images in memory
sysvsem
sysvshm
this plugin was tested with cacti 0.8.7b + PIA 2.1
on freebsd-7 and debian-4 systems (+reported working on gentoo)
running on php5.2 + mysql 5.1+apache 2.2
whithout any aditional kernel tunig