Thursday, March 24, 2011

Simply SaaS (Part 1)

This is part one of a multi part series where I will talk about what it means to develop and deliver a Software-as-a-Service application. I'll be trying to strike a balance between the technical aspects of bringing an app into the cloud and the advantages of using the SaaS approach as an Independent Software Vendor (ISV). I am NOT an expert in SaaS by any means...I'm writing this to educate myself and hopefully any reader that has the same curiosity. Your mileage may vary.

I think it's an understatement to say that the cloud computing term is overused. What does it really mean to deliver an application in the cloud? In recent years developers put together a web application or solution by marrying a database with a development framework and an application server resulting in a technology stack (e.g., LAMP, etc). Once the application was developed using these components it was deployed to a hosted environment or installed on premise to be part of a private enterprise. Ongoing maintenance for the application involved generating patches to fix bugs and supply enhancements. Sounds familiar and perhaps a little boring right? Around 1999 this guy, named Marc Benoiff took a sabbatical from his day job at Oracle (and by sabbatical I mean he was in Hawaii for 3 months and then in India "finding himself" for another 2 months) and started Salesforce.com. This, for historical purposes and to the best of my knowledge, was the start of the cloud buzz.

Marc wanted to offer easy to use enterprise software that didn't cost organizations an arm and a leg to implement and support. He did this by creating a pioneering CRM application that was nothing more than a web application / site that provided access via the Internet instead of the Intranet. Brilliant! Needless to say the application was a huge hit and later spawned the Platform-as-a-Service (PaaS) offering known as force.com.

To me, delivering a SaaS application seems like a smart move for an ISV. You have a low barrier to entry to get started, you can pass on that cost savings to customers, and you don't necessarily need to worry about supporting the infrastructure that runs your app at the end of the day. At a high level this seems like nirvana but you'll quickly find that it's difficult to understand what technologies you should be concerned with (as a developer) and how you will handle the subscriptions (as an ISV). I hope to fill in some of the blanks to developing and delivering a SaaS application by documenting the process I follow as I take an (albeit trivial) app from inception to delivery.

I'm a developer, what tools or frameworks exist to help migrate my project into the cloud?
First off there is a general distinction we need to make. SaaS is a type of software not a technology in particular. There exist a few "on demand" concepts that enable SaaS application developers. These concepts would be Infrastructure-as-a-Service (IaaS) and Platform-as-a-service (PaaS). Think of IaaS as Amazon EC2 - you get access to a hosted virtual machine where you can deploy your application. As your application grows and requires more resources, you can add more iron in your equation to get you that extra horse power. The application developer is still responsible for worrying about things like load balancing and clustering. An example of a PaaS would be force.com. If you haven't looked at this already it's worth signing up for the free developer account and poking around the documentation. Basically force.com allows developers to build apps with a domain specific language (DSL) known as APEX. You build your app using APEX and as you scale your app to customers you are charged a metered rate. Force.com also recently bought Heroku...this is a ruby on rails based PaaS. You build your app in rails, deploy it to the cloud using Heroku gem, and you are billed for your usage as your application scales to meet demand. There are too many PaaS offerings to mention in one post but hopefully you get the idea.

I'm an ISV what does it mean to build a cloud application?
Low barrier to entry for your customers. SaaS supports the idea of Multi-tenancy that allows you to co-mingle customer data (as long as the law doesn't prevent it) and therefore provides your customer with access with a push of a button. Customers pay for the software with a subscription so that they only get what the need instead of paying for countless licenses that ended collecting dust somewhere.

This is great but what if I already built my application? Do I need to re-develop or re-architect it?
Possibly. Apprenda provides a technology called SaaSGrid that can mostly eliminate that concern provided that you have an existing .NET application. SaaSGrid is advertised as an application framework that allows you to migrate your .NET application from a more traditional application service provider (ASP) model to a SaaS offering. The technology provides things like multi-tenancy so all you need to concentrate on is building your application like you normally would. In my opinion if you have a .NET web application that's worthy of the cloud or know .NET and want to build a new application, you should definitely give Apprenda a glance. You can download an express version that will allow you to install it on a server and see how the whole thing works. While I tend to be more of a Java / Ruby guy I definitely see the value in using something that's .NET based. Many enterprise grade SDK's (I'm thinking of ESRI since I'm a GIS geek) play nicely with .NET and maybe aren't fully featured for integration with other technologies like rails or a PaaS DSL such as APEX. This argument won't hold for forever but seems to be logical for the present.

In the next post I will talk about the application that I'm using as an example for this series and how it will benefit from an "on demand" delivery instead of shipped bits. Stay tuned!

Tuesday, March 15, 2011

Before Using a SDK...

...What types of questions should you try to answer? Here's a short list of evaluators that I've used in the past:
  • How easy is it to find a tutorial? It always makes me feel better when I can produce something with the SDK without having to waste an entire day.
  • When was the last release made? Although it's a generalization, SDK's that have current releases seem to have better support.
  • If the project is open source, how big is the community? If it's not open source, how easy is it to get technical support?
  • Is the SDK developed natively for your target platform? In the age of VM based languages, this questions seems somewhat dated. However, from a maintenance perspective it is easier to integrate an SDK that closely matches the syntactic style for the rest of your project. Additionally, if the language is a translation, you may need to develop wrappers in order to maintain a coherent workflow.
Are there other questions you ask yourself before you download and code?

Thursday, March 03, 2011

Transformations in PostGIS

Lately I've been doing a lot of development centered around PostGIS (http://postgis.refractions.net/) and ran across a problem that has a relatively easy solution (for those well versed in GIS) but finding an answer proved to be somewhat difficult.

Here are the assumptions and the requirements before we look at the problem:

  • A point is defined by a latitude and longitude.
  • A line is a defined by a series of points.
  • A buffer is defined as a shape that envelopes a line. The width of the buffer is specified by the user in meters. The distance value the user supplies is a +/- distance from the supplied line.
  • We are assuming WGS 84 as the target map projection.

PostGIS provides a handy buffer function called ST_Buffer and in order to use this function the geometry supplied to the buffer function along with the desired buffer distance need to be in the same coordinate system. See the problem yet? My coordinates are in decimal degrees (i.e., latitude and longitude) and my buffer distance is in meters. So I need to transform the line into a different coordinate system that will allow me represent my geography based shape in metric coordinates. This transformation is non-trivial since converting meters to decimal degrees relies on the use of a map projection because the world isn't flat (sorry!). Before we go any further let's look at the query I've developed so far:

SELECT ST_Buffer(GeomFromText('LINESTRING(-76.543 42.567, -76.012 42.345, -75.890 42.445, -75.543 42.330)'), 300.0) AS buffer_shape

The query is valid but the buffer distance is thought to be in decimal degrees (i.e., WGS84) with respect to PostGIS and therefore produces a shape that pretty much covers the world. I tried guesstimating the conversion from decimal degrees to meters but quickly realized, at best, a guesstimate would be terribly wrong.

To solve this problem - I employed the Transform function from PostGIS. In order to get this function to work properly I had to determine what coordinate system to transform my geometry into...this is where my Google-fu fell relatively short. Luckily I went to http://gis.stackexchange.com and found a reference to the proj4js.org project. Using proj4js I was able to determine the SRID of the desired metric coordinate system (that SRID is 900913). This coordinate system bases coordinates off of meters instead of decimal degrees. So I changed my original query to be the following:

SELECT Transform(ST_Buffer(Transform(GeomFromText('LINESTRING(-76.543 42.567, -76.012 42.345, -75.890 42.445, -75.543 42.330)'), 900913), 300.0), 4326) AS buffer_shape

The above statement transforms the line from WGS 84 to a Mercator projection, performs the buffer operation, and then does another transformation to project the resulting buffer shape back into WGS 84. Voila! Again, nothing earth shattering here but if you don't speak GIS all day then performing the transformations may not be entirely obvious. In my opinion the PostGIS documentation falls short when mentioning the transformation details.