Three reasons that REST is not RPC

I've gotten several comments saying that, at the end of the day, REST is just RPC. That's wrong, for at least 3 very reasons:

1) Each unique state in your protocol state machine has its own URI. That's different from an RPC endpoint that maintains a black-boxed state machine at a single endpoint. Being able to do state transition processing at disparate locations is hugely powerful. Watch the URLs you are navigating through as you browse, shop and checkout at Amazon. A single process can span machines offering differing levels of scalability, reliability and security.

RPC doesn't do that. You could conceivably build an RPC system that did do that, but if that happens it is a very rare occurence indeed. The more likely solution would be to have multiple RPC interfaces to the different machines involved in the process and then tie their protocols together. The application in the middle would have to understand how to mix the two protocols, passing data from one into the other, and back the other way. Yes, you can make it work, but it bakes a lot of protocol detail into the application mixing the calls, creating a much more complex solution.

2) With transition URIs embedded in the representations of states, it's easier to transition between states in the protocol. All of the URIs are accessed the same way, there is no separate interface per endpoint because the each endpoint represents the transition to an individual states, not all of the transitions required by a protocol. Again, technically this is doable with RPC, but nobody does it this way and solutions are more complex as a result.

3) The messages aren't interpreted as serialized call-stacks. The purpose of RPC is to copy a stack frame from one process to another, where it exists for the duration of a method call. That makes RPC very natural to anyone used to invoking a method, but it also makes it very hard to alter one side of the system without altering the other. While HTTP-based systems still use request/response messages, they aren't call-stacks. The fact that WS tools want to treat them that way is one of the reasons they have so much trouble handling large binary data, e.g., JPEG.

None of this is to say that RPC isn't useful. A couple people have mentioned callbacks to clients behind NAT based firewalls, a problem that RPC based on WCF duplex channels are very good at solving (protocols like XMPP and plain old TCP work well too). My system uses both RPC and REST. But it's a mistake to say that REST is RPC just because HTTP is request/response, we often use XML to represent state, and there are tools to map XML to and from callstacks. I made that mistake for a long time, until I realized what REST really is.


Posted Apr 28 2007, 07:01 PM by tim-ewald

Comments

Hugo wrote re: Three reasons that REST is not RPC
on 04-29-2007 9:55 AM
'what REST really is'.

Seems to me like three reasons REST is:

- HTTP
- HTML
- and browsers/docs

But under 'architectural style', anything in this world is possible.

And being of 'of Web', someone tell IBM, makes no difference when it ducks in solving the problem of hammering everything on its path (including the network and all participants of it).
Tim wrote re: Three reasons that REST is not RPC
on 04-29-2007 10:39 AM
I think the question of how far you can go with XML and other data consumed by apps other than the browser is a fascinating one. It's easy to say that REST is just those things, but I think we're missing a big opportunity when we say that. Especially if the RPC model is what we embrace instead.

H wrote re: Three reasons that REST is not RPC
on 04-29-2007 3:28 PM
Will accept it is always easy to say rather than do, and in that fashion XML text encoding, today's runtime and service bloat, shared state in databases, state overhead going back and forth and RPC are useless the same.

I am always fascinated how quick and selective we all are in forgetting how brittle this whole idea the 'new generation' of developers (I mean inventors everywhere) are hoping for in new apps, new Web and XML. All while ads are the only resource generating revenue..

Isn't their WPF killing their CPU? Haven't they had BizTalk load problems? Isn't that Java or ASP.NET or SQL taxing like there is no tomorrow? How are they navigating all the complexity of WebSphere and BEA that brings so much?

We have all been re-inventing routers, Web and dealing with limitations of HTTP and prop encoding since 1997 (meanwhile network, name resolution and addressing infrastructure are changing under our noses).

It is an incredible penalty paid for each and all above, and they are everywhere. REST I doubt brings anything new on that front.

XML made it worse in some cases (sure it retains promising layering we never saw in action). And state problem as representation transfer needs work of differential and appropriate public messaging infrastructure kind (for ages).

Blogs decentralised list servers, yet Web and blogging centralised itself on the next big thing while kids with their own OSes are pushing Internet fast forward..
Ebenezer wrote re: Three reasons that REST is not RPC
on 04-30-2007 6:43 PM
Another way to solve some of these problems is to focus on the messages passed and not on interfaces. What dictates that my endpoint must expose multiple interfaces? Who says that my SOAP message could not have a link to another endpoint. Afterall, with REST, I still have to "consume" other endpoints that may exist in the response. I am not critiquing the REST approach at all, in fact, I've used it and I think it can be very powerful in solving certain problems. I think these discussions should shift their focus to that i.e. what problems do REST architectures solve etc.
Christopher Steen wrote Link Listing - April 30, 2007
on 04-30-2007 6:46 PM
Using enterprise architecture framework to map services and set their granularity [Via: nattYGUR ] Silverlight...
John wrote re: Three reasons that REST is not RPC
on 05-02-2007 5:35 AM
> Each unique state in your protocol state machine has its own URI <

No it doesn't, because state is a function of (wall) time, and URIs don't model time.

Fielding says it himself in his dissertation:

"a resource R is a temporally varying membership function MR(t), which for time t maps to a set of entities, or values, which are equivalent."

If you are going to stick by your assertion, then you are going to have to admit that you've redefined the term 'state' with respect to what it's taken to mean per REST.

The problem with REST as described by Fielding is that it assumes that time and URI uniquely determine a state, whereas in the real world content available via HTTP varies by cookie context, and cookies are used because HTTP auth doesn't model 'sessions' (though that's not the exclusive use of cookies, as they also persist 'values' rather than just 'identities'; e.g. "use a green font" vs. "I'm in session 37").

There are various means of working around the fact that REST doesn't admit of entity representations varying by context other than time and URI, but they're hacks (e.g. javascript) and defeat the purpose in my view.
Erik Johnson wrote re: Three reasons that REST is not RPC
on 05-04-2007 7:15 AM
John,

I agree with you about having a different meaning for "state" than in the Fielding paper, which is one reason I try to stay away from the term "REST". Why do you say that any other representation tactic is a hack? Are you just thinking about "HTML content" over HTTP? For XML data, wouldn't something as simple as a version stamp suffice to disambiguate states?
Tim wrote re: Three reasons that REST is not RPC
on 05-08-2007 4:32 PM
John,

You're right, I didn't bring the time or other context into it. I was trying to simplify for the purpose of diffentiating from RPC.

I don't have a problem with not aligning with REST as defined by Fielding. What I'm really after is a model based on the Web, which works, whether it is true to Fielding's model or not.

Tim-

Add a Comment

(required)  
(optional)
(required)  
Remember Me?