Archive for April, 2004

New MySQL Book for the Library

Thursday, April 29th, 2004

High Performance MySQL book coverThe High Performance MySQL book, by Jeremy Zawodny and Derek Balling, finally arrived from Amazon. There’s very few tech books I can read from cover to cover but this is one of them. I’m three chapters into it and I have a decent list of things I want to try/change with our MySQL installation, at work.

Our installation at work is version 3.23 running on an HP UX system (first on the list is upgrading to 4.0). I wouldn’t call our implementation trivial. The alumni database has several tables with over a million records. I inheritated the implementation when I was hired a little over 8 months ago and I’ve been surprised at how fast everything runs. Esspecially since I know there wasn’t any real optimization work done when it was designed and implemented. Our alumni database is merely a copy of the actual one, which is running on an IBM AS/400 DB2 system. Today I was running a few queries comparing data in our tables with the tables on the DB2 system. Most of the queries executed on our system with a few on the DB2 system. Just out of curiosity I decided to reverse the queries, executing them against the DB2 system. The same page (set of queries) loaded about 3 to 4 times faster using our MySQL system. I’m sure the bandwidth limitations between our web server and the DB2 system had something to do with it, but I think it’s still safe to say MySQL outperformed.

Anyway, with all that said there’s a lot of things I’d like to do to increase our performance and reliability. Replication, load balancing, backup and a few other things. The type of things this book was written for. We have another HP UX machine sitting in the datacenter, unused. Perfect for experimenting. If you’re someone like me, who uses MySQL and knows enough to make things work but wants to take it to the next level, this is the book to read. Also, Jeremy has written some good articles on MySQL in Linux Magazine recently that are worth reading.

Excuse Me?

Thursday, April 22nd, 2004

Came home tonight and picked up the mail. Found an envelope addressed to me from “Old American Insurance Co.” Ripped it open and started reading: “Dear Senior Citizen, We are … ” DAMN IT! Come on people, I’m only 25! Perhaps contrary to common belief people really aren’t living longer. Somehow I got on the AARP mailing list also. Nothing makes you feel prematurely old like receiving letters which open with “Dear Senior Citizen.”

Interesting Search Strings

Tuesday, April 20th, 2004

I was looking through some of my web site statistics the other day and found some of the search strings that led people to my site particularly interesting. Here’s a few:

“sony ericsson t226 complaints”
“5 day late am i pregnant”
“a day late am i pregnant”
“dropped my sony ericsson t226 in water”
“hate windows 98″

A few of those I just find unfortunate. The entire list was much longer (over 100+ strings for April so far). Most of them deal with technical stuff and thus aren’t that interesting. I think I’ll be keeping a better eye on that list from now on.

Persistence

Saturday, April 17th, 2004

I’ve gone fishing two times this year and I’ve been shut out both times. Not the way to start the year. Not at all.

Web Services With ColdFusion and PHP

Friday, April 16th, 2004

Web services are really cool. I’ve received a few requests for access to our MySQL database from a few different groups recently. For example, one of the student clubs recently contacted me and told me they wanted to pull a list of their members and use it dynamically on their web site. Problem is they host their site on their own server and I’m not willing to punch holes in the firewall or create MySQL accounts on the server. They left frustrated and I felt guilty that I couldn’t help them out. I kept thinking about it and finally the idea hit me, web services. If this isn’t a perfect example for a web service, I don’t know what is. I’d never developed a web service on Coldfusion before but every thing I’d read indicated it was very simple. So I broke out the developer manual today and started playing around with it. About 30 minutes later it was all done (well, the basics. I plan to add more functionality). Initially I created a plain coldfusion component (CFC) and created a function called “getMembers” (with access=remote) that would return a list of club members. Inside the function I dropped in a simple cfquery tag to pull the list of club members and then return the query. Here’s what the code looks like:

<cfcomponent hint=”Web Service functions for the clubs”>

<cffunction access=”remote” name=”getMembers” returntype=”query” hint=”Returns a list of club members”>

<cfargument name=”user” type=”string” required=”yes” hint=”A valid username to access this resource”>

<cfargument name=”pass” type=”string” required=”yes” hint=”A valid password to access this resource”>



<!— SET THE DEFAULT RETURN VARIABLE TO A NULL STRING —>

<cfset variables.getMembers = “”>



<!— CHECK THE USERNAME AND PASSWORD —>

<cfif arguments.user EQ “SomeUser” AND arguments.pass EQ “SomePassword”>



<!— USERNAME AND PASSWORD ARE VALID, RETRIEVE INFORMATION FROM THE DATABASE

AND SET IT TO THE RETURN VARIABLE —>

<cfquery datasource=”ClubDatasource” name=”variables.getMembers”>

SQL STATEMENT TO RETRIEVE MEMBER LIST GOES HERE
</cfquery>



<cfelse>

<!— USERNAME AND/OR PASSWORD WERE INVALID, THROW AN ERROR —>

<cfthrow detail=”INVALID username AND/OR password” message=”INVALID username AND/OR password”>



</cfif>



<!— RETURN THE RESULT —>

<cfreturn variables.getMembers>

</cffunction>

</cfcomponent>

I wrote a quick test.cfm page to call the web service to see if it worked and it did. The Coldfusion code to invoke such a web service is:

<cfinvoke

webservice=”https://WEBSERVERURL/xml/clubs.cfc?wsdl”

method=”getMembers”

user=”SomeUser”

pass=”SomePassword”

returnvariable=”variables.query”

>



<cfoutput query=”variables.query”>

#clubId# #Name#<br/>

</cfoutput>

That only solved half the problem. I knew how to call and use the web service using Coldfusion, but I knew the club was using PHP on their server. The next step was figuring out how to call a web service using PHP. PHP doesn’t have any built in web service functions (yet), but you can download the NUSOAP library which makes it remarkably easy to use web services in PHP. Here’s the quick PHP script I wrote:

<?php

require_once(’nusoap.php’);

$wsdl=new soapclient(’https://WEBSERVERURL/xml/clubs.cfc?WSDL’);

echo
$wsdl->call(’getMembers’,array(’user’=>’SomeUser’,'pass’=>’SomePassword’));

echo ‘Response: <xmp>’.$wsdl->response.’</xmp>’;

?>

I loaded the page and it worked like a charm. There in front of me was a nice, XML formatted member list from our clubs database. Obviously I still have some work to do, like checking the username and password against our authentication database and such, but for the most part the hard part is done. This little project has got me thinking about what else we can use XML and web services for. I think my next step project will be generating an RSS feed for our news release site.

UPDATE* Coldfusion exhibits some strange caching behavior with web services. After I made my web service and tested it, I added a few more arguments to it. I changed my test invoking method and it said it couldn’t find a matching method with the parameters I passed. Remarkably enough php still worked fine (using the new arguments) but the test.cfm file did not. I did some searching and came across this message thread. It appears the only way to get rid of the cached version is to login to the Coldfusion Administrator, click on web services, delete the appropriate entry and reload the cfm page. So basically you have to do this anytime you add a web service function/method or change the arguments of a function/method. It’s a little annoying.

While looking around in web services in the Coldfusion Administrator I also noticed you can assign a username and password to each web service directly instead of imbedding them in the function like I did. If you want to keep authentication simple that’s a good way to go.

Tech Conference Decision

Friday, April 16th, 2004

Each year I can attend one conference. Last year I attended the Macromedia MAX conference in Salt Lake City (its close proximity had a lot to do with that decision). I need to decide which conference I’m going to attend this year, but I’m having some trouble deciding. I thought about the MySQL Users Conference, but since it ends tomorrow it’s not an option. I’m considering attending the Macromedia MAX Conference again (in New Orleans this year) and it seems to be the logical choice.

My development team spends about 90% of their time developing on ColdFusion using Macromedia products. Some might ask why that’s the case. It has a lot to do with the environment I work in. My development team is made up entirely of students, which usually means they don’t have advanced technical/programming skills when they start (that’s why they’re in school). Also, they’re not long term employees. Generally if they stick around more than 2 years I consider myself lucky. The combination of high turnaround and unskilled applicants means we need to use something that’s easy and quick to learn. Coldfusion fits that need fairly well. More so than Java, PHP and other development languages (that I might prefer more).

Anyway, back to the original subject, what conference should I attend? Like I said, the Macromedia conference is the only one I’m considering at the moment but I’m open to any other recommendations.

Finicky IE for Mac

Thursday, April 15th, 2004

I received an email the other day at work notifying me that our home page didn’t look very good on Internet Explorer for Macintosh. I pulled it up and sure enough it was just a jumble of garbage. This confused me because I use a Mac and I was sure I’d looked at it on IE, although I knew it was quite a while ago (I usually only use Mozilla or Safari).

Anyway…I noticed when I commented out a few javascript functions that dynamically manipulated a table the page looked fine (from what I’ve read, javascript support is awful on IE for Mac). That would seem to indicate the problem was with the javascript, however the exact same javascript was being used on other pages and worked just fine. I decided to rebuild our homepage starting from scratch, adding things in piece by piece. I discovered a few tables and other tags that weren’t properly closed. When I was finished the page was working on IE for Mac. However…I decided to reload the page a few times just to be sure and was disgusted by what happened. On average if I loaded the page 10 times, 9 times it looked just fine and 1 time it was a jumble of garbage. So, it seems to work 90% of the time. From a computing perspective I’m confused. IE is receiving the exact same code each time but it seems to randomly interpret it differently. Odd.

Add a New Weblog to the List

Tuesday, April 13th, 2004

I setup a new weblog for Dave (author of themoviereview.net) the other day. He called me and asked me to set it up for him. I was just about to ridicule his request, since he hasn’t update themoviereview.net since August, when he reminded me that I’m not really in any position to speak about not neglecting your weblog. So, I wisely chose to stay off my high horse and set it up for him.

It should be good reading. For those of you who don’t know. Dave is currently in law school at the University of Idaho (thus the reason he hasn’t seen many movies and hasn’t updated his movie weblog). Anyway, check it out.