Something is horribly b0rked

And I don’t have time to fix it now. A bit later. Please hold on

Update: Fixed – Phew.

I think that I will not use the AskApache plugin. Even though it looks very useful (especially since I’ve been mildly hacked once) it managed to b0rk the site twice (although I will admit that the first time it was my fault as well).

However the fact that it is so easy to break your site, even if you have some passing knowledge of web administration like me, makes it a bit dangerous for the faint of heart.

Another problem is that I couldn’t even leave a comment at the plugin’s page due to the heavy spam filtering or whatever. This is especially exasperating when your site is freaking up (not finding the admin pages and whatnot) and you’d like some support. Fortunately I managed to search for keywords and find a comment left by the author of the plugin advising how to fix my problem.

Very big Note: When the author talks about the .htaccess file. He means the .htaccess in the wp-admin/ folder not the one in your domain root. Do not touch the one in the root! I learned that the hard (or rather, the run around in panic, waving my hands around) way,

Dreamhost PS activated!

Engage Warp speed…3!

I just got in Dreamhosts’ new shiny and exciting Private Server thingy after just 2 short days. In all honesty I was expecting at least a few weeks of waiting so I was quite surprised when I got an email informing me that it has been activated 😀

It may have to do with me sending a question their way from the support page, to ask them a few questions relating to this. You see, I was not certain how much of a difference that would make for me, if it was worth it and if I should go for MySQL or Web Server hosting.

You see, I’m still quite a small fry at the moment and between the 3 blogs I’m hosting, I’m not averaging a lot of visitors. I always assumed that by being this small, a shared hosting plan is the best choice. Unfortunately I kept running into performance issues and even though I optimized and tweaked, they just went on and I was sick and tired of having a single page take on average 5 seconds to load and, too often for my liking, upwards of 10. I was even afraid that I was starting to get on Dreamhost’s support nerves with all the support tickets I opened for performance 🙁

It was at the point where I was considering moving to another hosting service (possibly on a virtual server) that my eyes fell on the new Dreamhost PS option, suddenly appearing in my Dashboard. Quite the timing. The reason why I decided to stick with Dreamhost still is that I just love the merry way with which they do business and their support has been very nice in my experience so far. I just felt I should give them another chance.

The PS option mentioned that this is by invitation only however and googling around a bit, I found a few people talking about it but none had any real experience. They were mostly saying that it sounds like a good idea but they were not going to use it because so-and-so hosting was better. Nothing tangible. Since I exchanged a few emails with Dreamhost support and I am now live with it, I thought I might write a few things about it.

Dreamhost PS Performance

I’ve only had the thing running for a few hours now so I can’t make much of a comparison. It does feel much faster for me but it could just be the placebo effect.

PHP

I did try to run my heaviest page just to see the experience: From an average of 10 seconds (due to the heavy php involved) it dropped down to 2.5 secs. This seemed a major improvement, however on a second test I did 8 hours later, the speed was 12 seconds again. Not certain if it’s affected by mysql, slow feed replies or whatnot. Nevertheless, doing a few more tests, the average seems to be 2.2 seconds. This should be in part because of Simplepie’s feed cache.

Gallery

Here the difference is much more striking. My Gallery2 installation used to be unbelievably slow more often than not. I would be lucky if I could get times below 5 seconds per page. Now the average seems to hover at around 2 seconds again and this is, frankly, a very pleasant surprise. Even The Wesnoth Journals gallery seems to have picked up unbelievable speed and that was the one that drew quite a few complaints. Awesome!

WordPress

Here the speed difference did not seem so striking initially. Average speeds hovered at around 2 seconds again which is a speed that I was reaching after my own optimization quite often. The difference now of course is that the speed seems to stay at that average instead of spiking to 5 – 10 seconds without reason. I have not seen one page actually going higher than 5 sec. Same thing persists in both the ACP (which has a heavy theme and is not theme optimized at all) and the Wesnoth Journals.

However a susprise awaited me on my more thorough testing this afternoon. For the first time Ev4r, I get sub second speeds, consistently! And this is without WP-Cache activated! If anything makes the whole page exceed one second, it is the Intense Debate comment script who’s speed is dependent on external servers, and even then the delay is never more than one more sec. This is truly amazing. With WP-Cache, the speed seems to stay consistently subsec!

The WordPress Dashboard speed, as expected, has improved considerably as well and finally I don’t have to wonder why it sometimes takes so goddamn long to load :D. Average speed of Admin Panel items seem to be:

  • Dashboard ~ 2 sec
  • Plugins ~ 3 sec
  • Automated Plugin upgrade ~ 1 sec (!!!)
  • Settings ~ 1 sec
  • Write ~ 1 sec (!!!)

The multiple exclamation marks are on items that truly impressed me since they always seemed to take a inordinate amount of time to load (around 5 secs) and the change is most striking.

Drupal

Here the speed confused me a bit. In my single Drupal installation averga speed hovered at around 3 seconds where suddenly it dropped to subsec again. Cannot really say if the server had a momentary slowdown at the start.

And with that, my little performance check ended. I think the change is quite obvious and for now I am quite happy with the results. I am still curious to see how this will fare during the more active afternoon – night hours (for me, for you Americans it will be morning – afternoon). If things turn around considerably, I will write about it.

Some Dreamhost PS Q&A

During my email conversation with the Dreamhost support, I had the opportunity to ask a few more questions about the service in order to make sure it is right for my needs. I will place the answers here in case anyone else has similar queries.

  • Q: I experience considerable slowdowns with my wordpress installation and it’s certainly not my setup. I think it might be MySQL as I don’t see anything loading for a few seconds and then everything comes up together. However every time I tried to put a support ticket for this, I see the web server under heavy load. I’m now not certain if I should request MySQL or Web Server hosting.
  • A: Go for Web Server. From my results I can see that MySQL hardly plays much of a role after all. My speed improved dramatically from just a small Web Server hosting plan.
  • Q: If I request Web Server and see that it does not make much of a difference, can I switch to MySQL and vice-verca.
  • A: When you request either a web or MySQL PS, since it must be physically setup, you are requesting one or the other and they are not interchangeable. If you decide you want either, you must visit the provisioning page to request whichever you decide you would like and if you want both, you need to request both individually at the same page of the panel-
  • Q: How do I request both a Web Server and a MySQL PS? I can only select one through the radio buttons
  • A: Request one, then go back and request the other.
  • Q: If I decide I don’t want this service anymore (say, because it does not make much of a difference) can I return to my previous shared hosting?
  • A: They won’t be able to move you back if your usage is above what is expected for a shared server account which is the base 150 level of the PS service. As long as you are below that level consistently, then there shouldn’t be a problem moving you back to shared, or at least giving you a discount on it.
  • Q: The information also mentions that I can adjust my RAM and CPU usage in real time. However, if I adjust my usage within the month one or more times, how much am I going to be charged?
  • A: You will only be charged at that rate for as long as you keep the slider AT that rate. So it’s all pro-rated. If you keep it at 150 and then move it up to 1000 for an hour, then back down to 150, you will only be charged the 1000 rate for that hour. No more, no less. 🙂
  • Q: I see the slider gives me the max burst I can get as double. Does that mean that if my rate is not enough I can increase the slider only up to that burst?
  • A: No, once activated you can increase your rate to the max of 2300 at any time, even if you started at 150.
  • Q: I ordered it. How long does it take usually?
  • A: No idea. In my case it took 1 day 😀
  • Q: The rates are vague. How much should I order for a small site with just a few thousand per month?
  • A: Low. I have four worpdress and two gallery2 installations hosted at the moment and my load is around 100Mb of RAM. My CPU is still at 10. My biggest spike was when I disabled WP-Cache and loaded my lifestream 5 times where my RAM jumped to 155.

So, that was my initial review of Dreamhosts shiny new upcoming Private Servers. I hope I have provided you some information to make the correct choices 😉

Memberlist for Collaborative WordPress Blogs

In case you have a self-hosted Worpdress blog which has multiple authors you may have noticed that you don’t have lots of option to show information about each one. You can have each author create a post for himself and link it from the sidebar (Which is how Debunking Christianity does it), or you can create a page for each one after they provide you some information about themselves. Finally you can just leave each author’s page to be the default list of posts.

I wasn’t satisfied with either of those options so I looked around and found something better. So I have just finished with my custom member list setup at the Antichristian Phenomenon and I thought I’d share how I did it in case anyone wishes to implement it as well.

I started after I discovered this excellent guide from WPDesigner. Although I didn’t need the role manager, the rest of the instructions were perfect for my purpose. So I installed the necessary plugins (plus Register Plus to stop spammers registering) and started adding fields.

I then needed to display those fields in each author’s page somehow. In also wanted to do that without making the page totally different from the reast of the site. So I copied the archive.php file to author.php. I enterred the file and inserted all the necessary variables for my fields (as described in the guide) and deleted all archive loops except the author’s. This way the user visiting the author page could see the author profile but also a list of articles they have written.

The curauthor variable was used to grab information for some of the default fields. Unfortunately the Wp User Manager plugin does not give you the names for all the default wordpress fields but fortunately the documentation in curauthor is complete. I copied the html div the archive loop was in (so as to have the same format) and created a little list to show each author’s profile. Here’s how it looks like currently

Once that was done, I decided to see if I could also put comments in each author’s page as well. Unfortunately, just putting the php call for the comments template between the info and the archives did not work. Apparently WordPress does not expect comments on archive pages. However since I am using Intense Debate Comments at the moment I figured that they would be agnostic on where I am putting their script.

Unfortunately since IDC works through the wordpress comments template, where that does not appear, so does IDC. I managed after all to work around this by copying the script itself into the template. It wasn’t easy to get the code for this since IDC insists on providing you with a WP plugin instead of allowing you the option to paste the script somewhere. I finally got the code by telling IDC that I wanted to install it on my gallery. Unfortunately, the script then had the wrong ID and I needed the correct one to have my comments logged at the correct blog. For this, I was able to just edit the WP plugin code and copy the ID from there. So I pasted the script in the template itself and, lo and behold, it worked! I now had comment capability on each author’s profile page 😀

Once this was done, I made a quick test comment to check if it works and noticed that IDC was logging a strange page title for the Author’s profiles. It seems that my theme is using a title for author archives as if they were a category archive and that would not do. I thus edited my header file and placed an if statement to check if it is an author page. On a positive, I changed the page to show a more appropriate title as well as the author’s nickname (through curauth again). Unfortunately IDC still kept grabbing some weird titles (or not at all) but it’s not caused by the title anymore.

Finally, I listed the authors of the blog on the sidebar through a php widget, I looked at it, and it was nice.

How to hunt for WordPress performance hogs

So after my previous post on how I discovered my major causes of wordpress pain, I kept looking on what is causing my other delays. Eventually, while looking at my source code, I discovered that my wordpress page was always reporting how many SQL queries it took and how long they took to complete. Looking at the footer, this was done by this command:

<?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds

Now, I understood that this was very helpful but I couldn’t understand why it was returning a time like 10 seconds when the page was loading for 4-5. A quick google search for this code however did lead me to a page that was explaining how to Keep WordPress overhead down. Through there, I realized that those seconds were some sort of CPU time taken to draw those queries.

Through this then, I now had a semi-accurate way to monitor the impact of each plugin on my site. I only needed to figure out which parts of the site were hogging down the queries and increasing the load time.

I created a quick table in a Spreadsheet and started logging down the differences.

  • First, I made the performance text visible, so that I don’t have to look at the source code each time (You can still see it by scrolling to the bottom of the page)
  • I disabled the WP-Cache so that the queries are done every time
  • I then started disabling each plugin in turn and reloading a page. Then I compared that with the previous loading time (where the plugin was enabled.) I noted down the difference in queries and the average/approximate CPU time difference.

Unfortunately since the CPU time tended to vary from load to load, I couldn’t get an accurate number of the difference. The table I made in the end looked something like this

Plugin name Queries CPU Time Taken
Bad Behaviour 1 5
Hide Text 0 Negligible
Greeklish 0 Negligible
One click install 0 Negligible
SimplePie WordPress Plugin 4 Negligible
Security Scan 1 1

After I went through all the plugins, then I started doing the same thing with my various widgets and snippets of code in my theme that might be causing this.

Once this was done, I had one likely suspect plugin and a few widgets that were probably contributing to this slowdown. You see, my theme, a very heavily hacked HemingwayEx, was using some custom widgets in order to draw from WordPress the latest comments, recent posts and whatnot. These widgets queried the database each and every time a page would load which was quite frankly impractical.

Fortunately a short time before, I had discovered the very useful bundle of post plugins. They were also there to hunt for recent comments & posts and related posts and they also included a built-in caching mechanism! As sweet as it gets.

I quickly modified my widgets to run this code instead and the results were wonderful. By disabling also the single other plugin I found that was slowing things down, Bad Behaviour, I’ve now managed to drop the loading time considerably (or so it seems for the time being). Not only that, but I’ve managed to put a few new toys to use that do a better job than HemingwayEx’s built in functionalities.

Currently my site seems to load lightning fast compared to before but I’m not absolutely convinced this will not change once my shared hosting environment gets bogged down. Hopefully, even if that happens I will still have a much much better performance than before.

I am still stuck at around 65-80 queries per page load but I can’t figure out where they come from. I am hoping that I’ll eventually be able to trace it but for now it seems enough.

Btw, I just loved the functionality of the Post Plugins to measure their own execution time and report it back to you. This is something that all plugins should be doing in order to give the web designer an idea on what is going on with his site. I’m going to work to see if I can implement that in the Lifestream plugin I’m working on and then see if I can place it on other plugin as well.

Btw (2), Can anyone explain why more people don’t take advantage of the Plugin cache plugin? I am fairly certain that a number of heavy plugins (like Popularity contest) could make good use of it.

As always, if you have any more ideas on where to look and tweak to improve my WP performance even more, I’ll be glad to hear them (AKA Whining because no one is commenting on my blog :P).

PS: It’s a pity that I had to disable Bad Behaviour as it worked quite well until now. I also don’t like to reply too much on just a single anti-spam plugin. Unfortunately, the performance hit was undeniable and I’d rather my site doesn’t take an extra 3-4 seconds to load every time.

No OpenID for you

I’ve given up trying to make the WP-OpenID plugin work with my theme. It seems it just doesn’t want to. Watever I do, it either tries to always authenticate on the url (even if it isn’t a provider) or never. I can’t get to it actually check the site.

Also, even if I do use a url that provides openid auth, the comment is rejected as spam (probably by bcspamblock) and I can’t be bollocksed to troubleshoot that.

So for now, unfortunately, I’m disabling OpenID functionality on this site. Let’s hope this can be fixed in the future.

Comments and stuff

So I’ve put a two new tricks on my comment forms.

The first one is that you can now see a preview of what you are going to post. Just write your text and press the preview button and you should see it below. No more orthographical or html errors ;). This was done via the AJAX Comment Preview plugin. It needed me a little css tweaking in order to get it to display as I need it but fortunately I was able to find how to wrap the preview so that it fits with the normal comments.

The second one is the threaded comments option which is done through the plugin with the same name. Although at the moment you can have only one thread per comment, this might make it easier to follow the discussion in case it starts to derail (although I will admit that I don’t have so many commenters). The nifty addition to that is that the author of the comment will now receive an email notification when someone replies to his comment. The bad thing is that you can’t unsubscibe from that but given the low number of comments I get, I do not think that would be a big issue. You can still use the subscribe feature as well, but since this will inform you of every subsequent comment in the thread (even if you do not follow it anymore) most people don’t use it.

This plugin needed me even more time to get right as I needed to format the thread correctly and also test if more than one thread is viable. It is but currently the comment box is screwed on the second comment so I need to work on the css part of it. Until then I’ve enabled only a single thread replies.

One last update is that I expanded the comment field in order to give you a bigger view of what you are writing. I always found the one I had before a bit too small.

I think I’m now going to enable these on my two other blogs as well 😉

Gallery tags not working

So I’ve managed to fix the latest problem that stumped me. This was related to my latest WordPress-WPG2-Gallery combo installation and it was the fact that for some reason the Gallery tag plugin just refused to display the tag cloud correctly. No matter what I tried, the tag cloud always displayed as a list on the blog, (separated by a line, one under the other etc) instead of an inline big & small tag cloud you would expect. Not only that but anything I tried in order to fix this on the WP theme stylesheet did not work. I even tried disabling everything that had to do with <ul> and <li> tags and the damn thing still persists.

What was even more enraging was that by directly accessing the gallery the tag cloud would work as expected, colours and all. Exasperating.

So I spend the whole afternoon and I did manage to fix the tag cloud. I had to use the style injection box that is provided by the WPG2 plugin in order to put the style code that forced list items to be put inline and without line separators. However, no matter what I tried, I could not make the colours change.

Hopefully, while I was lying in bed, it clicked for me. I must have been the gallery theme I was using, wordpress embedded, which makes the gallery fit to your WP theme. However for some reason, the designer has hard coded the font and link colour to the theme, which as a result of being loaded after the WP theme, took precedence. This is the reason why my links had that ugly blue colour and my tag colours would not work. By commenting the colour lines for the <body> and the <a> tags, I was able to force the gallery theme to submit to the WP theme selections.

Just in case anyone is wondering, the stylesheet code I put in my WPG2 Output – Element header textbox is

.g2_column {
width: 100%;
margin: 0px 1px 0px 12px;
}

.tag1 {
display: inline;
background:none;
font-size:8px;}
.tag1 a {color: #828282;}

.tag2 {
display: inline;
background:none;
font-size:11px;}
.tag2 a {color: #AC6FCF;}

.tag3 {
display: inline;
background:none;
font-size:14px;}
.tag3 a {color: #00659C;}

.tag4 {
display: inline;
background:none;
font-size:18px;}
.tag4 a {color: #008200;}

.tag5 {
display: inline;
background:none;
font-size:22px;}
.tag5 a {color: #FFCB21;}

.tag6 {
display: inline;
background:none;
font-size:26px;}
.tag6 a {color: #FF0000;}

.tag7 {
display: inline;
background:none;
font-size:30px;}
.tag7 a {color: #1acdb6;}

Where tag1-7 is the class that the Gallery2 tag plugin uses for each level of tag (based on the quantity)

PS: Yes, I have insomnia again…

Pluginess Updateness Goodness

So I’ve decided to go and update all my plugins now that WP2.3 is good enough to inform me that they have newer versions. All in all I updates Akismet, Popularity Contest, Wordbook, WordPress Database Backup, wp-cache and WPG2. Some of them didn’t make much of a difference but a few had notable improvements.

Popularity Contest actually now works with WP2.3 and it also seems to cooperate nicely with wp-cache as well, something that in the previous version required a modified version. Unfortunately for some reason my most popular posts per category still do not seem to work so I’ll need to investigate this eventually.

WPG2 seems to have achieved v3 while I was not looking and fortunately it seems to be working much better now. As part of the installation process it created a new page called WPG2 which surprised me and my old “Gallery” page stopped working. Fortunately that could easily be fixed by deleting the old one and changing the name of the new one. It still probably needs more configuration but I’ll get to that eventually.

I was thinking of upgrading to the hacked version of UTW but it seems to require double tag posting so for now I think I’ll wait a bit yet. Perhaps I could use the importing function of WP but the idea scares me a bit. If it isn’t updated soon, I may just switch to other things to see if it works. So FYI, tags are still off

Now if only I can figure out why the scrolling in the ACP site in FF in Linux is so slow…

and if it wasn’t so damn cold as well…

Broken Popularity

Hmmm, it seems that a part of the popularity contest plugin has broken too much for my limited coding capabilities to fix. I tried modifying a few entries but it did not work very well. Oh well, I’ll just wait until the newer version. Until then, just don’t expect to see the most popular posts by category 😉

I just hope that the version of the plugin I am using will be updated accordingly or at least that the original author will take this opportunity to implement the changes Richard made so that it can work with WP-Cache from now on.

Lost categories

Ok, I think I know what has happened with the upgrade to 2.3. Apparently, my wp_categories table has been renamed to wp_terms and nobody bothered to update the WP knowledge base about this little fact (at least not yesterday that I was looking for it). Good job![1]

I guess something like that must have happened since I was looking at my MySQL tables and I got a bit panicked when I noticed my wp_category and wp_post2category tables missing. I upgraded another WP installation I have for testing and noticed the change.

Now, for my problem with the “Zoulapia” error (which is part of my modified theme), I’ve managed to find the solution myself. I just needed to change the following in the function call.

("SELECT cat_ID FROM " . $wpdb->categories . " WHERE cat_name='" . $hemingwayEx_options['asides_category'] . "'")

to

("SELECT term_ID FROM " . $wpdb->terms . " WHERE name='" . $hemingwayEx_options['asides_category'] . "'")

And you can see it worked 🙂

Now I need to find out how to modify the popularity contest plugin so that it can search in the correct table when taking the popular category :-/

Oh, also the 2.3 feature that supposedly would use the previous tags you had, did not work. UTW has a (apparently) scary function to import them to [tag]Wordpress[/tag] db, but I’d rather wait a bit for that.

[1] UPADE: It seems they did mention it here