Archive for January, 2008

Amazon EC2 Disk Speeds of m1.small and m1.large

Thursday, January 24th, 2008

I have been running a two node cluster on EC2 and for the past week or so my database writes have been totally bogged down. After some tests it looked like we’re hitting the disk I/0 bottleneck. To my surprise Disk I/0 was 5-6 times faster on the m1.large instance type.

I ran a cheap command to time the creation of a 1GB file. Here are the results. In both the situations the small test was run on /mnt which is considered to be a dedicated spindle.

On m1.small

[root@]# time dd if=/dev/zero of=testfile count=1 bs=1024M
1+0 records in
1+0 records out
real 0m11.298s
user 0m0.000s
sys 0m3.390s

On m1.large


[root@]# time dd if=/dev/zero of=testfile count=1 bs=1024M
1+0 records in
1+0 records out
real 0m2.982s
user 0m0.000s
sys 0m2.350s

Read about the various EC2 instance types here

As Blogosphere explodes, Blog search implodes

Sunday, January 20th, 2008

Blog search engines are tracking billions of blog posts. Some posts are mindless, some are fun and some are purely spam. As the size of blogosphere grows the quality of discoverable content from the blogs through the search engines is falling way behind. We saw a similar problem with the regular search before Google came up and wooed the online users away from Altavista. I recently searched on blog posts tagged as “digg”. Majority of them were spam. Some were good but they were beyond the first few results pages.
mindless_technorati2.jpg

PHP-JSON on Amazon EC2 Fedora Core4 AMI

Saturday, January 19th, 2008

I have been using a modified version an old FC4 public AMI, which is too good to be deserted with all the software I have installed. For a project, I needed support for JSON. Javascript Object Notation or JSON is a way of passing string representation of Javascript objects to the user-agents. Straight-through serialization of Javascript objects and transmittal of such is much more compact than passing XML and then converting them to Javscript objects.

On the server-side you have to create a string representation of a Javascript object and then return it to the caller. This is very similar to formatting data in XML and then sending the XML back to the requesting clients. JSON takes away the overhead of XML (no parsing, DOM walking etc. instead you get a first-class Javascript object). In PHP you can create a JSON string by passing a PHP variable into an encoder function.  In PHP 5.2.0 JSON is natively compiled, it was contributed by Omar Kilani who wrote the php-json extension.

You may skip the rest of the post if you already have PHP 5.2.0. Keep on reading if you have PHP 5.0/5.1 on Fedora Core 4 and want JSON functionality.

Good news is that the php-json has an RPM available in fedora-extras. You don’t need do any thingamagic of installing the RPM by hand. Instead use yum to install it seamlessly from the fedora extras repository

(Assuming that You have su privileges)

Step1. Navigate to the /etc/yum.repos.d directory. Check if you have a file called fedora-extras.repo. This file contains the required information for yum to look up the extras repository

Step 2. If you do not have the file then create the file with the following text:

[extras]
name=Fedora Extras $releasever - $basearch
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/extras/$releasever/$basearch/
mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-extras-$releasever
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
gpgcheck=1

If you have the file then make sure the “enabled” flag is set to 1. Extras are normally disabled.

Step 3.  Run a yum search command as “yum search php-json”. If your fedora-extras.repo is set correctly then you will see a matching result as:

php-json.i386                            1.1.0-1.fc4            extras
Matched from:
php-json
php-json is an extremely fast PHP C extension for JSON (JavaScript Object
Notation) serialisation.
http://www.aurore.net/projects/php-json/

Step 4. If all looks good, run the install command as yum install php-json. That’s it. Have fun with JSON. Read the PHP Manual for usage.

Hello WordPress!

Saturday, January 19th, 2008

For the past 4 years I have been blogging using MovableType — It is a fantastic product with fantastic set of features. I have been thinking of migrating to WordPress due to the 500 Internal Server Errors, which have reduced my ability to blog. MT was solid, stable platform until their 2.4.x release. Things started going south since then. Another reason for the migration was my lack of PERL knowledge (I have tried, but can’t fathom the depth the language has to offer). The hacker in me has already tinkered around with WordPress, which allowed me to complete my import from MT to WP (esp. preserving the numerical IDs for .htaccess forward from MT).