CPU Usage update

The changes I made to MacMegasite seem to have helped the CPU usage situation. It’s reduced the CPU usage by each execution of PHP.CGI by at least 50% as well as reducing the overall CPU usages. Here are the resource usage stats for the last few days, only counting CPU usage by PHP.CGI.

Date Total CPU time # php.cgi Avg CPU
12/05 3780.4000 32005 0.118
12/04 4786.4100 32526 0.147
12/03 3713.8700 31634 0.117
12/02 3720.8000 30562 0.122
12/01 4409.1400 17624 0.250
12/30 5685.9700 21089 0.270
12/29 5281.2200 21208 0.249

Lightweight Drupal home page

I’ve cleaned up my code for MacMegasite’s new page by breaking it up into separate include files for the left & right sidebars. The entire code is less than 50 lines and uses only a single database query and no calls to Drupal code.

Here’s the full code, not including the style sheet and sidebar content:

<html>
<head>
<meta http-equiv=content-type content="text/html; charset=utf-8">
<title>MacMegasite</title>
<style type="text/css" title="text/css">
<!--
@import url(INC/style.css);
-->
</style>
</head>
<body>
<img src="INC/logo.gif" class=logo>
<br>

<div class="left">
<?php include "INC/left.inc" ?>
</div>

<div class="right">
<?php include "INC/right.inc" ?>
</div>

<table class=content>
<?php
$dbname="your_database_name";
$host="your_host_name";
$user="your_user_name";
$pass="your_password";

$dbi = mysql_connect($host,$user,$pass);
mysql_select_db($dbname);

$query = "select nid, title, teaser from node where status=1 and promote=1 order by nid desc limit 10";
$res = mysql_query($query,$dbi);
while (list($nid,$title,$teaser) = mysql_fetch_row($res)) {
   print "<tr><td>";
   print "<h1><a href='http://www.macmegasite.com/drupal/node/".$nid."'>".$title."</a></h1>\n";
   print $teaser;
   print "<hr width=75% align=center><br>\n</td></tr>\n";
}
?>
</table>

</body>
</html>

CPU Usage

I think I may have come up with a real solution to MacMegasite’s CPU usage problem. I’ve created a new lightweight front page which doesn’t use Drupal but lists the content from the database. When you view an article from the front page, it uses Drupal to display it. The front page code is very simple, consisting only of a single database query to Drupal’s node table.

I may need a new web host

I may need to find a new web hosting company. I love DreamHost and I’ve had no problems with them, but my sites are using too much CPU time. I’ve received several warnings about MacMegasite from them like the following:

Unfortunately it appears that your site is using more than your
fair share of system resources on your shared hosting machine
jezebel. Our system has flagged your account because it is using a large number
of CPU minutes per day on jezebel. We need you to trim down your
resource consumption considerably. Should you ignore this or subsequent warnings your
account may be moved to an evaluation server which could cause downtime.

Specifically your CPU minute usage for today is 100.63.

DreamHost gives me a ridiculously huge bandwidth and disk space limit, which I’m nowhere near reaching. There’s no way anyone could reach that limit without using too much CPU time unless they’re simply hosting large media files.

I’ve done as much as I can to attempt to reduce the CPU usage, including reducing the number of articles on the front page, removing blocks, disabling features, and increasing the throttle level. I’m using a standard installation of Drupal 4.6.3 with no unusual modules, but the site gets around 30,000 hits a day. If anyone else is hosting a Drupal site with that amount of activity at DreamHost, are they also getting those warnings?

WorldBeatPlanet Changes

I’ve made a few changes to WorldBeatPlanet. First, I’m using a new theme based on the Blix theme with some color changes. The biggest change is the WorldBeatPlanet Store is no longer a separate site – the store is now integrated with the main content. I found that the amazon_items module I was using isn’t compatible with Drupal 4.6.3 so I switched to Amazon Tools. It looks a bit nicer than the old amazon item links, but I don’t like that it now creates an additional node for the amazon item link with every product node I create.

Condo site upgraded

I found that Drupal CVS was way too unstable, so I upgraded the condo site to 4.6 instead. I was still able to use the image gallery module and the nicer theme.

Testing Drupal CVS

I’m trying out Drupal CVS (which will eventually become 4.7) at the condo website and I’m running into lots of problems. The editing forms are badly broken. With Flexinodes such as the new Event, custom fields aren’t shown in the entry form so you can’t really do anything. The image gallery module, which is one of the main features I wanted to use in the new version, is even more badly broken. Images don’t appear at all, and you can’t enter a title or description.

I may end up backing off to 4.6.3 (the site is currently running 4.5 rather than 4.6.3 like I’m using at macmegasite & worldbeatplanet).

No more trackbacks at macmegasite

I was experimenting with Drupal’s Trackback module for a few days at MacMegasite, but I turned it off today due to spam & other problems. I was getting way too much trackback spam, plus the moderation feature didn’t work (most likely it isn’t compatible with my version of Drupal, 4.6.3). I was also getting lots of SQL errors in the log from it.

ShareYourMusic.com relaunched

I’ve relaunched ShareYourMusic.com as a separate site which no longer shares content with WorldBeatPlanet. It will provide a community for independent artists with forums and a store to sell their music. Right now I’m only selling CDs through CD Baby, but I’d also like to publish and sell music myself.

It shares the same Drupal installation with WorldBeatPlanet but uses a completely separate database, using Drupal’s multiple site feature. When I was developing the site, rather than creating the database on my PowerBook and uploading it to the live server after I finish configuring it, I created the database directly on the live server, configured it from a local Drupal installation on my PowerBook, and after it was fully set up I edited the settings.php for shareyourmusic.com to point it to the new database.