mod_cache in apache2.2 using custombuild-Quick Help required

anay

Verified User
Joined
Dec 7, 2005
Messages
114
Hello,

Please give me quick guide how can I add mod_cache properly in my current apache2.2, php 5.2, mysql 5.1.x configuration.

If I recompile apache with mod_cache, am I required to recompile php and mysql too ?

Please guide !
 
Very quick: copy the configure script of apache (run "./build used_configs" to know which one) from the configure/ to the custom/ directory within custombuild/, edit it, run "./build apache". No need to do anything else.
 
Ok.. I already did that and recompiled apache using ./build apache.

Now how do I enable it ? am I required to add line in /etc/httpd/httpd.conf ?

I added following as want disk cache ..
<IfModule mod_cache.c>
<IfModule mod_disk_cache.c>
CacheDefaultExpire 3600
CacheEnable disk /
CacheRoot "/opt/ap2cache/"
CacheDirLevels 2
CacheDirLength 1
CacheMaxFileSize 1000000
CacheMinFileSize 1
CacheIgnoreCacheControl On
CacheIgnoreNoLastMod On
CacheIgnoreQueryString Off
CacheIgnoreHeaders None
CacheLastModifiedFactor 0.1
CacheDefaultExpire 3600
CacheMaxExpire 86400
CacheStoreNoStore On
CacheStorePrivate On
</IfModule>
</IfModule>

looks likes files are being cached as /opt/ap2cache has lots of files now.
How do I make sure its being cached and things I should know to improve ?
 
Well, I'm not an expert. I did my configuration following my needs, but here it is anyway:
Code:
	CacheRoot /var/www/cache
	CacheEnable disk /
	CacheDirLevels 5
	CacheDirLength 4
	CacheDefaultExpire 1200
	CacheMaxExpire 86400
	CacheMaxFileSize 10485760
	CacheMinFileSize 1
I guess you should ask on a specialized forum about finer configuration and detailed explications. http://httpd.apache.org/docs/2.2/mod/mod_cache.html is an useful resource too.
I remember using squidclient to control squid, but I don't know if there is a similar application for apache mod_proxy and mod_cache (I guess you are using mod_cache for proxying, not local memory caching, since you use the disk option).
 
I used the disk option as somewhere I read case study about mod_cache and found that its more efficient to use disk cache than RAM cache unless you have plenty of RAM.

Though I can see its caching but site which was giving trouble is still giving trouble, other sites on this servers are improved. However, server's load is reduced 50% but still its lot more than normal.
 
Well, there is no point on trying to reduce disk IO load (mod_cache is effective only on static data, and that for local data means disk IO load) by caching on disk. Also, I suggest you try to find the real bottleneck, because I'm not convinced you did.

Those are the reasons you may have too much load on some websites:

- disk IO is full and Apache is constantly waiting for read or write access on static data

- disk IO is full and PHP is constantly waiting for read or write access on static or dynamic data (to create images thumbnails or use temporary files, for example)

- CPU is full and Apache is constantly waiting for access to do something internally

- CPU is full and PHP is constantly waiting for access to do something internally (creating opcode, for example)

- CPU is full and PHP is constantly waiting for access to run opcode

Each (and more, if you use any other feature/interpreter/database etc) of those possibilities have a completely different solution, so start auditing your server and I'll be able to help by reading the results.

The easiest solution, that should work with almost everything? Buy massive amount of memory, that costs nothing, and cache everything (from static data with mod_cache, to PHP opcode with opcode cachers to MySQL tables, indexes and queries, etc) into it with reasonable parameters.
 
Well, this box is old p4 with 1 GB RAM, I am considering to buy another box but I am just not conviced why only one site is taking a lot more server resources than 3-4 sites takes algother and that too with almost 10x of traffic in total.

If this site is turned off, server loads are less than 1 even at busiest time of the day. The site ausing problem is based on pligg script. You can check it at : http://www.gyach.com

I have just turned off mod_cache as it was rather delaying things.

The thing I am worried is that on this little traffic its using such resources, what if its traffic increases to 4x-5x, which I can do but I am afraid to promote unless site is in good shape.

Basically I have seen lots of Mysql load when this site is ON. Lately was trying to tweak mysql but can taste only in day time when there is traffic.
As of now load is around 1.5 on average but used to be 0.5 or lesser at these timings.

So where should I start or simply set up a new box ?
 
An average load of 1.5 for linux on a P4 (single core) means that half of the time your CPU and disks IO are fully used and "the system is happy" (load 1.0), while the other 50% of the time there is a single process waiting to access either the CPU or the disk (load 2.0), which may or may not be bad, depending on which process are we talking about.

I know for a fact that MySQL can be tuned very profoundly, and that badly written applications often need a good MySQL tuning. There are many posts on this forum about many scripts that help you tune your distribution, just use the search feature.

Also, remember to always run those tuning scripts during the second (or more) peak in traffic since MySQL started (i.e. if you have traffic peak at 17h and run MySQL on Monday at 18h, run the script Wednesday at 17h). In other words, when you run the script MySQL must 1) have been running at least one time during the whole peak time and 2) be currently serving a peak time. If you don't follow this, I assure you they won't give you the correct answers.
 
Back
Top