Archive for Architecture

More good news

The future of SaaS is getting brighter by the day. The following three news items are very encouraging and I hope will provide enough momemtum in diminishing the desktop and browser gap.  The day of Linux, Windows, Solaris as the main platform is going to be history and the new platforms will be the browser and the desktop.

#TARGET=desktop

TARGET=browser

./configure –target=$TARGET ….

  1. Intel backs Google’s Chrome OS
  2. Microsoft’s Gazelle
  3. Microsoft to unveil Office web

This is exactly what we need; a good competition to get the best out for the community.  I hope more players join in the competition.

Leave a Comment

The role of Media types

I finally understand how media types should be used in REST<link>. I have not struggled as much to understand any of the REST constraints and principles as much as I had to understand the proper use of media types. Even HATEOAS<link> didn’t cause me such difficulty in understanding (though the ahh!! moment when I finally undetstood HATEOAS is still fresh in my mind). After the insight into HATEOAS, I felt I had mastered REST and went on to design a real application based on REST principles. When I started on the design of the application , I glided through the steps <link> of resource identification , methods supported at each URI’s but soon hit a snag when it came to the use of media types. The major problem or confusion I faced was the increasing number of media types that were getting defined in our application. I then posted a question here<link> and also exchanged few emails with experts<subbu> in the field hoping to understand where or what I was doing wrong. Even though I did get some really good responses to both my question and through emails, I still couldn’t get my head around the confusion. The main reason I never got around to understanding is due to the fact that I had a totally wrong assumption on the role of media types. After spending quite some time researching, trying to figure out where and what I was doing wrong, I think I might have finally found the missing link.
With this post, I hope to get across my understanding of media types and try to clarify the role of media types in REST for those who might have got into similar situation.
First some background, one of the goals of our team was to replace a legacy (proprietary) communication mechanism with standards based communication system. We choose HTTP and also made a conciouse decision to base our architecture on RESTful principles, and thats when we started looking at media types. Our initial understanding of the role of media types were that media types are used to describe the representation of the resources in lieu of a schema language i.e. we thought that each resource should have a media type which defines the processing model, the applicable methods on the resources and also the structure details of the resource representation. This led to us defining a media type for each resource in our application and finally to the realization that we were doing something wrong.
Recently, I came across the statement “media type for helping tune the hypermedia engine, schema for structure” <link> in a blog entry by Jim Webber. I then found this presentation<link> by Ian Robinson of Thoughtworks<link>. This presentation is one of the best that I have come across that provides a very clear understanding of the roles and responsibilities of media types and schema languages (the entire presentation is a treat and I highly recommend for all). Especially lookout for the slides titled “You’ve Chosen application/xml, you b*st*rd.” and “Custom media types”. Ian clearly explains the different roles of the schemas and the media types. In short, this is my take away from Ian’s presentation:
A media type description includes the processing model that identifies hypermedia controls and defines what methods are applicable for the resources of that type. Identifying hypermedia controls means “How do we identify links?” in XHTML, links are identified based on <a> tag and RDF has different semantics for the same. The next thing that media types help identify is what methods are applicable for resources of a given media type? A good example is ATOM (application/atom+xml) specification which gives a very rich description of hyper media controls; they tell us how the link element is defined?  and what we can expect to be able to do when we dereference a URI so it actually tells something about the methods we can expect to be able to apply to the resource.  The structural information of a resource represenation is NOT part of or NOT contained within the media type description but is provided as part of appropriate schema of the actual representation i.e the media type specification won’t necessarily dictate anything about the structure of the representation.
So what does this mean to us? simply that we dont need a separate media type for describing each resource as described here<link>. We just need one media type for the entire application. This could be a totally new custom media type or a custom media type which reuses existing standard media types or better still, simply a standard media type that can be reused without change in our application.
Now, armed with this knowledge, I do hope to progress smoothly in our design and as Jim says, “media type for helping tune the hypermedia engine, schema for structure” is going to be my mantra too.

I finally understand how media types should be used in REST. I have not struggled as much to understand any of the REST constraints and principles as much as I had to understand the proper use of media types. Even HATEOAS didn’t cause me such difficulty in understanding (though the ahh!! moment when I finally undetstood HATEOAS is still fresh in my mind). After the insight into HATEOAS, I assumed that I had mastered REST but my fallacy was exposed when I went on to design a real application based on REST principles.  When I started on the design of the application , I glided through the steps of resource identification , supported methods, etc… but soon hit a snag when it came to the use of media types. The major problem or confusion I faced was the increasing number of media types that were getting defined in our application. I then posted a question here and also exchanged few emails with experts in the field hoping to understand where or what I was doing wrong. Even though I did get some really good responses to both my questions and through other channels, I still couldn’t get my head around the confusion. The main reason I never got around to understanding is due to the fact that I had a totally wrong assumption on the role of media types. After spending quite some time researching, trying to figure out where and what I was doing wrong, I think I might have finally found the missing link.

With this post, I hope to get across my understanding of media types and try to clarify the role of media types in REST for those who might have got into similar situation.

First some background, one of the goals of our team was to replace a legacy (proprietary) communication mechanism with standards based communication system. We choose HTTP and also made a conscious decision to base our architecture on RESTful principles, and thats when we started looking at media types. Our initial understanding of the role of media types were that media types are used to describe the representation of the resources in lieu of a schema language i.e. we thought that each resource should have a media type which defines the processing model, the applicable methods on the resources and also the structural details of the resource representation. This led us to defining a media type for each resource in our application and finally to the realization that we were doing something wrong.

Recently, I came across the statement “media type for helping tune the hypermedia engine, schema for structure” in a blog entry by Jim Webber. I then found this presentation by Ian Robinson of Thoughtworks. This presentation is one of the best that I have come across that provides a very clear understanding of the roles and responsibilities of media types and schema languages (the entire presentation is a treat and I highly recommend for all). Especially lookout for the slides titled “You’ve Chosen application/xml, you b*st*rd.” and “Custom media types”. Ian clearly explains the different roles of the schemas and the media types. In short, this is my take away from Ian’s presentation regarding media types:

A media type description includes the processing model that identifies hypermedia controls and defines what methods are applicable for the resources of that type. Identifying hypermedia controls means “How do we identify links?”, in XHTML links are identified based on <a> tag and RDF has different semantics for defining links. The next thing that media types help identify is what methods are applicable for resources of a given media type? A good example of these can be seen in the ATOM (application/atom+xml) specification which gives a very rich description of hyper media controls; they tell us how the link element is defined?  and what we can expect to be able to do when we dereference a URI so it actually tells something about the methods we can expect to be able to apply to the resource.  The structural information of a resource represenation is NOT part of or NOT contained within the media type description but is provided as part of appropriate schema of the actual representation i.e the media type specification won’t necessarily dictate anything about the structure of the representation.

So what does this mean to us? simply that we dont need a separate media type for describing each resource as described here. We just need one media type for the entire application. This could be a totally new custom media type or a custom media type which reuses existing standard media types or better still, simply a standard media type that can be reused without change in our application.

Now, armed with this knowledge, I do hope to progress smoothly in our design and as Jim says, “media type for helping tune the hypermedia engine, schema for structure” is going to be my mantra too.

Comments (2)

The Chrome OS as the SaaS enabler

I am really excited about the announcement from google regarding their new OS. I was kind of expecting something similar to come out of Google after Chrome browser. I do see a lot of potential in a  browser based OS. For starters, the distinction between desktop apps and browser based apps is going to blur in future. It is also encouraging for SaaS consumers since the Chrome OS addresses aspects core to SaaS like providing iinstant access to information from anywhere and everywhere, non intrusive and simple, enhanced security, removing the complexities involved in software upgrades, hardware configuration etc.. Imagine such an environment where the OS boots up and presents a browser and enables you to use the browser as your complete desktop (access to spreadsheets and other apps, the location bar acting as your command line etc..) , it enables the web to be your desktop and gives you immense freedom and possiblities.
The reason I say I was kind of expecting this from google is that after looking at Chrome and using it for almost from the day of its release, I naturally got a feeling that the Web is going to be next desktop platform. Chrome gives you an idea of the immense possibiliies and benefits of bringing the web and the desktop together. I have been a huge fan of the Chrome browser from the day I started using it, even though currently there are many short comings such as lack of extensions, themes etc.. (I really do miss the mouse gestures extension for Firefox though I haven’t touched Firefox or any other browser after my Chrome experience)  However, I feel these things and many more things will get addressed soon and I am bearing this inadequacies for the simple reason that Chrome is one browser which hides itself and lets you concentrate on things that you really care. When using Chrome, I rarely feel that I am  using a browser and I already get a feeling of working on the desktop with Chrome. It is blazingly fast and absolutely non intrusive and this is one of main reason I feel that Chrome OS is going to change the game, forever. I hope others will soon follow suit and we may ultimately be able to blur the distinction between Browser based apps and Desktop apps.

I am really excited about the announcement from google regarding their new OS. I was kind of expecting something similar to come out of Google after their Chrome browser. I do see a lot of potential in a  browser based OS. For starters, the distinction between desktop apps and browser based apps is going to blur in future. It is also encouraging for SaaS consumers since the Chrome OS addresses aspects core to SaaS like providing instant access to information from anywhere and everywhere, non intrusive and simple, enhanced security, removing the complexities involved in software upgrades, hardware configuration etc. I do feel that this new OS is going to do a lot good for SaaS consumers and might in fact play a big role as a SaaS enabler. Imagine such an environment where the OS boots up and presents a browser and enables you to use the browser as your complete desktop (access to spreadsheets and other apps, the location bar acting as your command line etc..) , it enables the web to be your desktop and gives you immense freedom and possiblities.

The reason I say I was kind of expecting this from google is that after looking at Chrome and using it for almost from the day of its release, I naturally got a feeling that the Web is going to be next desktop platform. Chrome gives you an idea of the immense possibiliies and benefits of bringing the web and the desktop together. I have been a huge fan of the Chrome browser from the day I started using it, even though currently there are many short comings such as lack of extensions, themes etc.. (I really do miss the mouse gestures extension for Firefox though I haven’t touched Firefox or any other browser after my Chrome experience)  However, I feel these things and many more things will get addressed soon and I am bearing this inadequacies for the simple reason that Chrome is one browser which hides itself and lets you concentrate on things that you really care. When using Chrome, I rarely feel that I am  using a browser and I already get a feeling of working on the desktop with Chrome. It is blazingly fast and absolutely non intrusive and this is one of main reason I feel that Chrome OS is going to change the game, forever. I hope others will soon follow suit and we may ultimately be able to blur the distinction between Browser based apps and Desktop apps.

Leave a Comment

Multi tenancy vs Single tenancy

I often come across the debate whether SaaS should provide mult-tenancy or not. My personal take on this is that SaaS should mean multi-tenancy;or else it is not SaaS, may be ASP but not SaaS. The whole reason why ASP failed in the past and why now SaaS model is being proclaimed as the best bet in the future for software delivery model is the because of its ability to provide multi tenancy. A SaaS offering without multi-tenancy is no different from traditional ASP i.e multi tenancy is the differentiating factor for SaaS when compared to ASP. A multi tenant architecture allows all users and applications to share a single common infrastructure (Database, application etc..) that can be maintained centrally. For me the biggest advantage of multi-tenancy is the single codebase that eliminates the maintanance nightmare.
Of course the technical challenges of implementing Multi-tenant architecture is complex (partitions, security etc..) compared to Single tenant architecture but I feel the tradeoff here is beneficial in the long run.

I often come across the debate of Multi-tenancy vs Single-tenancy and  I feel both have their place and have their own advantages and disadvantages but when it comes to SaaS, I feel that SaaS should mean multi-tenancy;or else it is not SaaS, may be ASP but not SaaS. The whole reason why ASP failed in the past and why now SaaS model is being proclaimed as the best bet in the future for software delivery model is the because of its ability to provide multi tenancy. A SaaS offering without multi-tenancy is no different from traditional ASP i.e multi tenancy is the differentiating factor for SaaS when compared to ASP. A multi tenant architecture allows all users and applications to share a single common infrastructure (Database, application etc..) that can be maintained centrally. For me the biggest advantage of multi-tenancy is the single codebase that eliminates the maintanance nightmare.

Of course the technical challenges of implementing Multi-tenant architecture is complex (partitions, security etc..) compared to Single tenant architecture but I feel the tradeoff here is beneficial in the long run.

UPDATE:

Just after posting this, I found this nice presentation which talks about the business case of multi tenancy in SaaS. Very informative.

Leave a Comment

Event based interaction in REST

I am currently struggling with a design issue involving REST. The application I am designing has a requirement to send out events and also support pub/sub style of interaction. I am unable to come up with a design to provide these interaction style without breaking the REST’s “Stateless interaction” constraint. I am not against polling as some people seem to be (polling sucks) , but my application demands a event based and pub/sub style of interaction (polling is not an option for me). So, my question is can I design a RESTful application that supports event based and pub/sub interactions without breaking the REST contraint? is REST style suitable for this kind of interaction style? I have seen many discussion on this topic and especially one from Roy Fielding in his blog entry . Though Roy makes interesting observation and provides alternatives to the friendfeed problem, he doesn’t say much about  eventing or pub/sub interaction without breaking REST constriants. I only seek this answer to make sure I haven’t missed out anything and unnecessarily break an important  REST constraint. However, if there is no way of doing this kind of interaction and also be RESTful, then I dont mind breaking the stateless interaction constraint and be less RESTful.

Update: I have posted this question at stackoverflow

Leave a Comment

Space Based Architecture

Some time back , I stumbled upon  Space Based Architecture (SBA) and found it to be very interesting architecture to build highly scalable applications. SBA based applications are inherently scalable than their counter parts i.e tier based architectures. Now that I am looking at REST, SBA seems to adopt few properties of REST, though not intentionally i guess(Note: I am not drawing pararelles between REST and SBA, only looking at few similarities). I find the following similarities b/w SBA and REST

  1. Uniform Interface (PUT,TAKE,NOTIFY,..)
  2. Stateless interaction
  3. Highly scalable arch style

In SBA, a space is shared between multiple services which is used as place to store data and behaviour which can be accessed by multiple services.  The Master-Worker pattern which is most commonly associated with space based programming shows the true power of spaces by making it possible to pass behaviors and state between masters and workers and thus enabling simplified parallel processing. This pattern suits problem domains where either a problem is highly parallelizable or if there are a set of tasks that can be be performed by any set of workers.  Imagine a SOA based or traditional client-server based system where a client accesses a piece of functionality on a remote server which is executed in place on the remote server and result delivered back to the client. In SBA, the same client-server or SOA paradigm shifts the processing to the client, i.e a client picks a piece of business logic from the shared space, executes it locally on the client thus reducing the the complexities involved in load balancing, horizontal scaling on the server. To achieve this, SBA requires that functionalities exposed by services or servers be self-sufficient unit. I think SBA achieves the first law of distributed object design perfectly well.

There are some criticism of SBA where people say it is just a new name for shared database.  However, I feel that comparing spaces to databases might not be entirely right. Shared database works like persistent memory where databases are used as shared memory and the primary purpose here is to place some data into a shared environment as a layer of interoperability between applications. However spaces brings not only data but behavior and distributed aspect to sharing.  So looking at spaces as just another object repository is missing out on the aspects such as parallelism and distributed behavior. 

The space programming model associated with SBA is supported by Tuple Spaces, JavaSpaces, GigaSpaces. Tuple space can be thought of as distributed shared memory where programs can read and write entries. JavaSpaces provides distributed object exchange and coordination mechanism for Java objects. JavaSpaces supports the following interfaces to interact with the space:

  • write(): Writes new objects into a space
  • take(): Retrieves objects from a space
  • read(): Makes a copy of objects in a space
  • notify: Notifies a specified object when entries that match the given template are written into a space

Gigaspaces develops upon JavaSpaces and adds extensions like update operation to update an object in the space at finer granularity than write(). write() in JavaSpaces replaces the entire object. With JavaSpaces, the only way to update a small part of an object is to first take() the entire object out of the space, modify the object and write back the object to the space. Gigaspaces also adds .NET, C++ and Java interoperability, support for JMS, queries etc..

Overall, I feel SBA has a lot of potential for solutions demanding high degree of linear scalability, distributed objects and pararllelism. I have played around with JavaSpaces and found it be very simple to get started with. Blitz is another open source toolkit that further claims to simplify the development of applications based on space programming model. Gigaspaces provides both commercial as well as an open source platform for utilizing space programming model. A white paper by Nati Shalom of Gigaspaces explains the benefits of SBA as compared to tier based architecture. A good read if you are looking at SBA seriously.

Leave a Comment