Tag Archive for 'Development'

OpenCoffee with an Amazon Web Services Evangelist

I met Amazon’s Web Services Evangelist Mike Culver at this week’s OpenCofee meetup. Mike visited as part of his tour of Australia and New Zealand.

Mike talked to us about Amazon Web Services and took questions from the group.

I gave Mike feedback on my experience with EC2. In the early days we used EC2 for hosting Gleemy, and it was great. We could start and stop a few Linux boxes as needed and we only paid for the time we used. For a small startup, that’s good news. When Flexiscale launched however, we couldn’t help but switch to it. I explained why to Mike:

  • The biggest point of pain with EC2 is the risk of losing data. When an EC2 instance terminates or crashes, the disk is erased and any data you haven’t stored elsewhere is lost. Typically, you’d need to use a redundant server or periodically backup your data to S3. On Flexiscale, your virtual hard disk is stored on a SAN. This means your data persists after your instance goes down. Moreover, if a disk on the SAN goes down, it can be swapped for a new one without the need to power down your instance (and without you even knowing about it.) Mike told us this is a common complaint, and to expect EC2 to change accordingly sometime soon.
  • Each time you start an EC2 instance, you are given a different public IP address. You need to use a system like dyndns for maintaining a domain name. Flexiscale gives you a static IP address which you don’t have to worry about changing.
  • On Flexiscale, you can vary the parameters of your virtual host (memory configuration, hard disk size, OS) and pay accordingly. With EC2, you choose from one of 3 pre-configured instances.

Keep in mind, EC2 absolutely excels with distributed computing applications. Read their blog for some pretty amazing stories.

Device detection with DetectRight

Recently, I read about DetectRight over at Jason Delport’s Mobile Observations. DetectRight is a web service for device detection; their API allows you to supply HTTP headers (or a user agent string), and query which device your mobile visitor is using.

Device detection is something we tried to tackle early on. Our first approach was to use the open source effort WURFL. Our use of WURFL didn’t last long when we noticed data for a few popular handsets was either incomplete or just wrong. (Note: this was almost a year ago, so things may have improved.)

In the end, we chose to prompt the user to select their device from a list when downloading. It’s an extra step, but it still allows us to deliver applications optimized for whichever handset you use.

Our evaluation of DetectRight is underway, and I thought I’d share our experiences.

DetectRight offers both php and SOAP APIs. Since Gleemy is written with Java on the server side, we started with the SOAP API.

To consume a web service with Java, you start by generating a client stub from the WSDL file describing the web service.

The Java API for Web Services sounded like a good place to start, but alas no luck. (What does “[ERROR] undefined simple or complex type 'SOAP-ENC:Array'” mean?)

WSDL2Java (part of the Apache Web Services project) turned out to be a lot friendlier. Running:

java -cp axis.jar;commons-discovery.jar;commons-logging.jar;jaxrpc.jar;saaj.jar;wsdl4j.jar org.apache.axis.wsdl.WSDL2Java http://www.mpwservices.net/MPWServices/soap.php?wsdl

produces a Java callable interface to the DetectRight web service, in the form of 5 java files. Awesome. Here are a few good methods from the stub:

public Hashtable getProfile(

String licence,

String manufacturer,

String model,

String schemaName

)

public Hashtable getProfileFromUA(

String licence,

String HTTPUserAgent,

String HTTPAccept

)

public Hashtable getProfileFromHeaders(

String licence,

Hashtable serverVars

)

This enables you to do things like:

profile = getProfile(myLicenseKey, userAgentString, null);

where profile is a hash table containing all known properties of the client device. Each call is marshaled across the Internet to the DetectRight servers.

You can print the profile like this:

private static void dumpHashtable(Hashtable h)
{
String[] keys = h.getKeys();
String[] values = h.getValues();
int i;


System.out.println(keys.length + " keys, " + values.length + " values");
for (i = 0; i < keys.length; i++)
{
System.out.println(keys[i] + ": " + values[i]);
}
}

I tested with popular user agents we’ve seen, and every time the API worked as expected.

We’re still playing with it. As part of any evaluation, you need to consider things like cost (DetectRight is a commercial service), license terms, level of service and so on.