Killing off PHP

Do you know why Apache processes get stuck and stop responding when serving pages on a WordPress site?

I’ve seen this happen here and on my previous host on a regular basis. I don’t know what happens. It can’t be a PHP script gone into an infinite loop because the normal Apache timeout should kill it. It’s not MySQL as a quick inspection of the process list usually shows it’s empty.

It could be plugins, some of them haven’t been written to the high standards that is expected in WordPress core. It could be some strange interaction between plugins and core code and memory limits and PHP extensions.

Whatever causes it, this will fix it. It’s brutal, it’s crude, but it’ll stop the load average going up on your box and it will ensure that every Apache child process is listening and responding. Add this to the crontab of your nobody or www-data user. Pick whichever user runs the webserver because you want to limit the damage in case something bad happens and the command malfunctions!
*/10 * * * * ps auxw|grep apache2| awk '$10 !~ /0:00/ {print $2":"$10}'|awk -F ':' '$2 !~ 0 {print $1}'|xargs kill -9 2> /dev/null
What this does is it uses the ps, grep, and awk tools to find processes that are using anything more than the minimum CPU time. It is very crude, but it works.

If you use Litespeed, then replace “apache2” with “lsphp”. I have found that this is very necessary as those processes get stuck quite often, especially in low memory situations.

Where's the evil in top posting?

Where is the evil in top posting when replying to a message on a mailing list? It’s something I’ve never understood, even after reading the many “why top posting is evil” posts and FAQs around the interweb.

Inspired by yet another email complaining about a top post to the GIMP mailing list I briefly searched Google, the source of all information in the world, and found this enlightening page on the evils of top-post complaints.

Regardless, top-posting flame wars are always fun to watch from the sidelines. People on both sides of the arguement will fight for their own side in what is a subjective matter and way of writing. Flame away!

I'll be there too

See you tomorrow at BarCamp Ireland! There’s going to be a big crowd and great speakers. Tom will be there and he has volunteered to speak twice. I won’t be talking, but come up to me and ask me about WordPress MU and wordpress.com, I’ll be the one wearing the WordPress tshirt!

I see that the wiki has been updated with the following message:

All attendees, whether you have signed up already or not, please send your contact email address to barcampireland at gmail dot com. Thanks.

It’s a public wiki and I haven’t seen the same message on the BarCamp Ireland Blog so maybe hold off sending that email until there’s a similar announcement tomorrow. Me paranoid? Never!

While I’m here, blogging at 23:30, this will be of interest to the rest of Automattic and anyone else who works at home – Myths About Working From Home. You never really leave the job do you? (via)

Drowning in the flood

I have noticed a strange thing in the past week or so. Google has referred legitimate looking browser user agents to this blog and In Photos.org and within seconds that browser tries to download all my feed links, and several months of my archives. I have a little flood protection built in and it stops them with a 403 after several of these requests but it’s annoying. It’s some sort of pre-fetching plugin to “speed up” browsing isn’t it? Firefox has a similar thing in the form of the “Fasterfox” extension if memory serves. Ben Metcalfe has a good write up on the evils of pre-fetching. It could kill your database or use all your credits in online stores!

Whatever you’re using, welcome to my kill file.

64.136.27.227 … “GET /index.php?tag=suicide-girls HTTP/1.1” 200 36422 “http://www.google.com/search?q=suicide+girls&hl=en&lr=&start=20&sa=N” “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)”
64.136.27.227 … “GET /wp-content/plugins/widgets/rss.png HTTP/1.1” 200 3341 “https://inphotos.org/index.php?tag=suicide-girls” “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)”
64.136.27.227 … “GET /feed/atom/ HTTP/1.1” 200 35775 “https://inphotos.org/index.php?tag=suicide-girls” …
64.136.27.227 … “GET /feed/ HTTP/1.1” 200 35449 …
64.136.27.227 … “GET /feed/rss/ HTTP/1.1” 200 4636 …
64.136.27.227 … “GET /wp-content/themes/whiteasmilk/style.css HTTP/1.1” 200 9639 “-” …
64.136.27.227 … “GET /xmlrpc.php HTTP/1.1” 200 42 …
64.136.27.227 … “GET /2006/07/ HTTP/1.1” 200 68150 …
64.136.27.227 … “GET /2006/09/ HTTP/1.1” 200 68150 …
64.136.27.227 … “GET /2006/08/ HTTP/1.1” 200 68150 …
64.136.27.227 … “GET /2006/06/ HTTP/1.1” 200 68150 …

Simple UTW Performance Boost

The Ultimate Tag Warrior plugin for WordPress is a great plugin. It does the job of handling tags rather well. I’ve noticed many hits from Google searches that go to a tag page instead of a category page of the same name so there’s something there that Google likes. I love it! Christine Davis did a super job filling a niche with the “ultimate” tool that anyone could want.
Unfortunately what isn’t so good is what goes on behind the scenes:

  1. UTW ignores your default category when saving your posts. Why ignore the default category when that is probably the subject you care most about? On my photoblog, In Photos.org my default category is “photos” and I certainly want people to find my images.
  2. UTW does an expensive SQL JOIN when it can’t find any tags for a post. Remember what I said about the default category? If you primarily post to your default category then every time someone sends you a request your server will get bogged down trying to find a non-existant record. It’s really bad when you have several years of posts and thousands of records in there.
  3. If you’re not going to use the fancy AJAX tag search then don’t load the associated Javascript. It saves an extra request on the first page load, and the browser doesn’t have to process the file.

Here is a patch that addresses those issues. It needs to be edited before you use it because you have to add a default tag. Here’s how to install it:

  1. Decide on a useful default tag. For this blog I use “holy-shmoly”. Open your WordPress database with phpmyadmin and look in wp_post2tag (the name may be different depending on your prefix). If you have already used the tag then find it and note down the tag_id of that tag. Otherwise, add your tag and note the new tag_id.
  2. Edit utw-patch.diff and look for the strings DEFAULT_TAG_NAME and DEFAULT_TAG_ID and replace with the name and id you picked out in the last step.
  3. To apply the patch, copy it into your wp-content/plugins/UltimateTagWarrior/ directory and run the following command.

    patch -p0 < utw-patch.diff

  4. If you don’t have access to patch, then open utw-patch.diff in your favourite editor and make as much sense of it as you can. It’s not hard once you have the source files open as well.

I’ve noticed a significant drop in server spikes since I made those changes. It takes a while for the default tag to be populated as it’s done when posts are visited but once it’s finished you should see a marked improvement. Oh, and install WP-Cache 2.0 as well. That’ll help you ride out the occasional digg!

Download the patch: utw-patch.diff for UTW 3.14159 for WordPress 2.0

By request, here are the modified files. Rename .txt to .php and copy them into your plugins/UltimateTagWarrior/ directory, overwrite the originals:

  1. ultimate-tag-warrior-actions-wordpress2.txt
  2. ultimate-tag-warrior-actions.txt
  3. ultimate-tag-warrior-core.txt

News overload again

You go away for a few days and come back to a news aggregator that’s just brimming with posts and articles and teasing you with nuggets of information that you really don’t have time to read. 10 posts there, 20 here, 200 in boingboing. Time to be selective, I really should prune the number of blogs I’ve subscribed to. How many do you read? I have 190 feeds, plus about 10 feeds related to me, wordpress and Automattic. *phew*

It was worth it however. We were in Dingle for an extended weekend. Despite the warnings of a hurricane it only rained on us once on Saturday morning. For the rest of the time we could have been somewhere exotic under blue skies and fluffy white clouds. The number of tourists from the US and Canada was great to see. The price of the US Dollar in Euros certainly makes it expensive to visit here for Americans and the Canadian Dollar isn’t doing too well either. I can’t wait to get cracking on the photos I took. Check out my photoblog, In Photos.org, over the next week for those!

Hammond may have brain damage

Richard Hammond, one of the presenters on BBC’s Top Gear, crashed in a jet powered dragster while trying to break the British land speed record of 300.3mph. He had reached 300mph on his first go, and was doing a final run when, “one of the parachutes had deployed but it went on to the grass and spun over and over before coming to a rest about 100 yards from us.”

Sky news updated their news story about the accident a few minutes ago. Richard Hammond suffered a “significant brain injury” but they’re hopeful he will make a good recovery. Watching them do crazy things on Top Gear from time to time it’s easy to forget that they’re actually taking risks. Unfortunately this time something went wrong.

Hope you recover soon Richard!

Much later.. News is getting better.

Clarkson revealed he had made Hammond smile during the visit by calling him “a crap driver”.

He told The Sun: “He was lying peacefully with a black eye but didn’t react so I tried something else.

“I said, ‘The reason you’re here is because you’re a crap driver’. He then smiled at me. It was an amazing moment, very moving.”

Later.. I just watched the final episode of the last series of Top Gear. That’s the one with the white vans. In a final race against Stig in a police car, Richard tipped over the small van he was driving when he tried to take a corner too fast. The van skidded a few feet before coming to a stop and he climbed out safely. I wonder did what Jeremy and James say come back to haunt them when they joked, “Richard might be dead. If you want a job in Top Gear send your application to I’m better than Richard Hammond..”

The Wikipedia page on Richard Hammond has a summary of events including the good news,

In the early hours of 22 September, Hammond took his first steps, just 30 hours after the crash, according to Jeremy Clarkson, and was moved to a general ward on 23 September.

Jeremy Clarkson responds in his usual way, making fun of and light of what happened. I don’t doubt that they did as much as they could to make his land speed attempt safe but reading Jeremy’s quote below, one has to wonder how many children does it take to force a man to consider his fate? Obviously not two, maybe three? No, probably four children.

I have too many children these days to put myself voluntarily in harm’s way. Hammond, however, isn’t there yet.

Top Gear is a great show but when Jeremy Clarkson’s flippant attitude strays towards serious matters it really irks me. Thank God, Richard Hammond is well on his way to recovery.

TCAL has photos taken from Sky News of the crash. Looks bad. Lucky man to walk away from that!

Richard Hammond Crash

Buying a house in Ireland

2006-08-20_p1060569-thumb.jpg

Buying a house will probably be the biggest purchase most people will make in their lives. The process is littered with the baggage of ages, you have to get your own engineer, a solicitor must check the title of the land even though it may be a new estate, money goes here, money goes there and it’s all very stressful.

I went through that hell almost 2 years ago but it was brought to mind again recently when I was asked for advice on the subject. I’m no auctioneer or lawyer but here is a list of what I think you need to do when making a house purchase. The list is tailored towards the first time buyer because that’s exactly what I was when I bought. If you already have a property you have the headache of selling that too.

How big is your mortgage?

Finding the best mortgage is a tricky problem and there are a number of options – go directly to a bank or go through a broker. Hopefully your broker will be independent and will give you the best mortgage he can find but seems unlikely in light of the fact that brokers receive varying commissions from different banks and lending institutions. Brendan Burges answers frequently asked questions about mortgages on the askaboutmoney.com forums covering topics as diverse as mortgage repayment protection, tax relief and insurance.

Budget

You have your mortgage but besides the cost of the house, there are fees for all the services you must use to make the purchase. A solicitor will normally charge 1% or even 1.5% of the house price for their services. An engineer will charge anything from €400 and up depending on the size and condition of the property. You’ll also have to set aside money to purchase furniture and all those things your parents had in the kitchen that you took for granted. I have to admit I completely misjudged how much this would cost. If you like spending money though, buying for your home can be as satisfying as buying the latest gadget or a new pair of shoes!

Hire a solicitor

Look up the Golden Pages and point your finger at the page and you’ll find a solicitor. Some are better than others, some are more paranoid and careful. You want the paranoid one on your side. Ask friends or family for recommendations. If you’re in Cork, email me and I’ll recommend the solicitor I used.

Find your dream home

It may seem strange that this is not top of the list but it’s useless dreaming about owning a mansion if you can’t afford it. Getting mortgage approval first and finding out what your budget is will help bring your dreams more in line with reality and possibly down to earth with a crash. Use myhome.ie, and use Google to find local auctioneers. Examine the prices in the area you’d like to live. If you are really diligent, go down to City Hall or the local council and find out what developments are in store for your area in the next five years. You don’t want a sewage plant opening next door.

Hire an engineer

Your broker or bank, or solicitor, or somebody will recommend an engineer or architect. He’s important because he’ll spot the damp wall that means you may have to spend thousands on a new heating system. It’s also a formality too because he can only do a visual inspection unless he rips up floor boards, moves built-in storage out of the way and peels back wallpaper. There will be things he misses that you’ll curse him for months later. You’ll have signed his disclaimer form so just live with it. The banks want someone qualified to certify that the building you’re spending their money on is something they can sell in the event that you default on the mortgage. Why the buyer can’t hire an engineer and provide that report to each buyer is beyond me, but that’s “how it’s done” here.

House Valuation

The bank will send someone out to value the house, but guess who pays? It’ll cost you, the buyer, about €100.

Haggle and Bargain

By the end of the process, you will regard auctioneers as the lowest form of … Let’s just say, they probably squeezed you for every penny you’re worth didn’t they? If you’re a first time buyer the auctioneer is going to love you. You can be a quick sale, he gets his commission and deal’s done. Use that when you’re haggling over the price of the property. I’m not very good at this, if you aren’t either, it might be worth doing some research and practicing. It could save you a few thousand Euro. You do not not sign a contract yet.

House Insurance

Why do I need house insurance before I’ve bought the house? It’s because you have an interest in the property. You will also want to have the house insured the moment you sign on the dotted line. What if someone burns down your new home the same day you buy it? It’s another requirement that you have house insurance before the bank releases the funds for your mortgage. You can buy from the bank or broker providing you with the mortgage, but you probably shouldn’t. Shop around. 123.ie is one site that springs to mind but almost every insurance company has a website these days where you can get an online quote.

Mortgage protection policy

Nobody likes to think about death but a life assurance policy is another of the bank’s requirements before you can get a mortgage. If you die, the bank wants the loan they made to you paid off quickly and without fuss. A life assurance policy does that. Like the purchase of house insurance, you should shop around. Rates and options can vary wildly, but the cheapest policy is one that covers only death, and where the amount paid out decreases with the life of the policy, in line with the mortgage value.

Sign on the dotted line

Once your mortgage has been finalised, your house insurance bought and all the land registrary checks made by your solicitor, then you can sign the contract to buy the house. If your mortgage isn’t ready, and on the off chance that something goes wrong (perhaps a problem with your life assurance?) that makes buying a mortgage impossible, the seller could sue you or make life very difficult for you by looking for the agreed price of the property. If all goes according to plan then well done, you’re on the property ladder! You’ll owe the bank a huge sum of money every month for the foreseeable future “but at least you own your own home”! I owe the bank a big fat mortgage too so I’m in the same boat. 800 mortgages are issued every day in Ireland and despite the rise in interest rates that doesn’t look like it’s going to slow down any time soon.

Related Links

  1. Your local library will have a booklet called “Using the Internet for… Buying a home”. It’s part of the Life Steps Government scheme and the contents are available online too. Their quick guide is an excellent collection of links to sites such as Oasis.gov.ie, moving.ie and the independent Irish Financial Services Regulator (ifsra) who are an excellent source of advice.
  2. The mortgages and home buying forum on askaboutmoney.com is worth a visit too if you have questions to ask.

If you have any suggestions for improvements to this list don’t hesitate to leave a comment below. Thanks Mel for reviewing my original list and making suggestions!

PS. The bungalow pictured above is in Blarney, I won’t say where but the list price on the auctioneer’s website was €330,000. Apparently it finally sold for €375,000!

If you are selling a house, about.com have a guide on how to prepare your house for the sale and showing it off. This might be useful too when you’re buying. You’ll spot the tricks!

Kathy Foley warns that you may be paying too much for conveyancing. She advices that by shopping around you should be able reduce your bill to less than €1,800.

So I shouldn’t have to pay more than €1,200 or €1,300 if I go for the best deal?

You should be able to get the conveyancing done for this amount, although you might have to pay up to €1,800. “If you pay more than €1,000 plus Vat and outlays for a standard conveyancing, you are paying too much,” said Leonard.