It would be more efficient if you provided a link so people can see what you're using that could be turned off, etc.
I can't provide a link since its an adult site.
And GauGau, I'm working hard to upgrade to cpg1.4.4. Right now my galleries themes are too heavily hacked but as soon as I figure out how to make all my themes work for cpg 1.4.4. I'll make the upgrade.
Anyways.... here's what I've done so far this week:
I started out with getting a load of 40-50 during peak hours. Incredible, no? I had to get it down so I followed these steps.
Steps:
#0: Turn off random images, last commented images, etc.
I did this about 2 weeks ago when I wasn't collecting statistics on the loads. I just knew the gallery was slow and had to do something about it.
#1: Use the MYSQL query cache
For me the benefits of this were negligible. Coppermine tables were saved but the pictures table can't be used because each new view causes an update to the table. I could not calculate the load savings.
#2: Use a php cache like eAccellerator
Load dropped to 6-11 during peak hours. Coppermine uses a lot of static php files, so saving them in a cache keeps them from being recompiled each time a user needs them.
#3: Split the large gallery into multiple smaller ones.
I split the one large gallery into 5 ones with each holding about 10,000 pictures. The load during peak hours was unchanged, but during non-peak hours my load fell slightly---from about 1.6 to 0.7. My hypothesis is that during peak hours the load is unchanged because users were staying longer, thus more people used the gallery at a time. I can't be certain of this till I compare my visitor statistics of this week to the average.
#4: Turn off forum statistics (view counts, album counts, etc.)
- Still checking to see what kind of savings this will bring
What I have left to do:
Turn off checking for banned users, updating the banned list
Turn off voting and view counting
-- Why? Voting and viewing cause table updates. In order to keep a table in the query cache, we want it to update as infrequently as possible.
Ideally I'd want to keep voting and view counting. My first thoguht was "make a cache for the votes and views" then commit the changes later, but where will I store the cache? If I use a temporary table inside a database, then when there are enough updates I'll have a table that's comparable in size to the original pictures table. Then any benefit I get will vanish till I commit the changes and clear the temporary table.
Till I turn off voting, I'm finding the queries for hit and voting statistics and making them low priority sql updates.
One last thing I did was put in a 'fuse'. I modified init.inc.php and added the lines
global $modSettings;
$time = time();
if (($time - $modSettings['fuseBox_lastAvgTime']) > 60)
{
$load = preg_match('~average: ([\d\.]+)~', @shell_exec('uptime'), $match) == 1 ? (float) $match[1] : false;
$modSettings['fuseBox_lastAvgLoad'] = $load;
$modSettings['fuseBox_lastAvgTime'] = $time;
}
$safe = isset($_COOKIE['cpg_ah_gallery_fuse']) ? (int)$_COOKIE['cpg_ah_gallery_fuse'] : 0;
echo 'Last Avg Load: '.$modSettings['fuseBox_lastAvgLoad'];
if ($modSettings['fuseBox_lastAvgLoad'] > 2)
{
echo ' -|- Warning: The public galleries do not function when the load is greater than 10.';
}
if ($modSettings['fuseBox_lastAvgLoad'] > 10 && !($safe) && !USER_IS_ADMIN)
{
$server_load = $modSettings['fuseBox_lastAvgLoad'];
pageheader("Server too busy, please try later");
msgbox("Server too busy, please try later", "Server too busy, please try later<br> current load $server_load");
pagefooter();
exit;
}
else
{
if (!($safe))
{
setcookie("cpg_ah_gallery_fuse", 1, time()+1800); // Expires in 30 minutes and ensures users who were in the gallery during that time will stay
}
}
just after
if (!GALLERY_ADMIN_MODE && $CONFIG['allow_private_albums']) get_private_album_set();
The above code checks if the server load approximately above 15 and refuses new entrants into the gallery. I hand each entrant a cookie that expires in 30 minutes, so I know if they have recently been in the gallery.
The fuse has been the best at halting the load spikes that I was previously seeing.