HTTP is one of my favourite things and I want to see it everywhere

15 July 2010

First things first: I like HTTP. I really like HTTP. The other day I got to think­ing about the ar­chi­tec­tural ben­e­fits of REST, and how many of the ad­van­tages seem to apply just as much to com­mu­ni­ca­tion between the com­po­nents of an ap­pli­ca­tion as between clients and server that com­mu­ni­cate over the network. What are the im­pli­ca­tions of using HTTP (to pick the most common REST transport) for in­ter­nal com­mu­ni­ca­tion between components, as al­ter­na­tive to straight­for­ward func­tion calls?

There’s some obvious disadvantages, so let’s get those out of the way:

Against this, the advantages:

Using REST for in­ter­nal com­mu­ni­ca­tion might ini­tially seem like a strange idea, but for the reasons de­scribed above, I think it’s one that makes sense. None of REST’s constraints and guiding principles are vi­o­lated if there’s no network involved, which I think is es­pe­cially in­ter­est­ing con­sid­er­ing that REST was ex­plic­itly for­mu­lated by Roy Field­ing as a so­lu­tion to the prob­lems faced by ex­ist­ing network-based soft­ware architectures.

There’s a few frame­works and li­braries out there that go so way toward treat­ing HTTP—both in­ter­nal and external—as a fundamental, first class protocol. Kohana 3.0 has some­thing called HMVC, and I’ve also done a proof of concept version of this feature for Zend Framework. Both allow you to create a stan­dard HTTP client that is able to route and dis­patch HTTP re­quests internally. Are there any other frame­works (in any language) with strong support for HTTP? I asked a related question on Stack Over­flow re­cently but didn’t get many responses.

Finally, even if the dis­ad­van­tages of per­va­sive HTTP out­weigh the ad­van­tages for many applications, I think it’s in­ter­est­ing to imagine what it would be like to design an ap­pli­ca­tion with per­va­sive HTTP. For one thing, it helps clarify the dif­fer­ence between REST and RPC systems like SOAP—whilst there’s never any reason to use SOAP for in­ter­nal calls, there may be reasons to use HTTP.