State-based streaming emerges as REST development alternative

Developers are looking to increase Web application performance with alternatives to REST development approaches.

It wouldn't be going too far to suggest that some software development community members embrace the idea of Representational State Transfer (REST) with almost a religious zealousness. Colloquially referred to as RESTafarians, one wouldn't normally suggest to these people that developing a service-oriented architecture (SOA) with something other than REST development would be a good idea.

However, more and more often, architects who design SOA-based systems at an enterprise scale discover that many problems are best solved by putting Web pioneer Roy Fielding's dissertation on the topic aside and, instead, searching out alternatives to REST. As high-frequency sites address the challenges of massive volume coupled with an often unreliable network, the state-based streaming pattern is becoming a viable REST development alternative.

"People generally use REST for everything," said Sean Bowen, CEO of Push Technology Ltd., a London-based developer of software to increase performance of Web apps. "People think REST does everything. But looking at what you're building and looking at whether or not REST is an actual fit is important."

Streaming patterns are a more natural fit for the architectures of the modern, Internet-connected world.

Peter Hughes,
lead engineer, Push Technology Ltd.

That's not to suggest that developers should go back to the bad old days of simply sending verbose XML over HTTP or create a host of SOAP-based endpoints. But for solving some of the most challenging enterprise software problems, new patterns are emerging that challenge fundamental tenets of Fielding's REST dissertation.

Moving beyond REST-based Web services

To understand how newer alternatives fly in the face of what RESTafarians believe to be truest, one must first appreciate the most fundamental REST-based principals, one of which is that all network-based transactions should be stateless.

Attempts to shackle state on top of HTTP have often resulted in systems that were difficult to write and impossible to scale; so, as a general rule, managing state outside of a service is the right thing to do. But in some situations, the refusal to maintain any client state on the server is precisely the problem that hampers scalability.

Take an example of a system that looks at bank account statements. An initial request might return the latest 50 transactions. At worst, refreshing this data requires re-requesting the last 50 transactions, which may not return new data and, subsequently, wastes bandwidth and clock cycles on both the client and server. At best, a prompt might be sent to the server indicating the ID of the last record the client has, asking the server to return any new records. But even in this latter case, a needless request-response cycle occurs if there are no new records, and if there are new records, a full database query ensues.

Does a better solution exist?

This type of approach to developing SOA is messy and might severely limit the system's ability to scale, especially if the back end being queried isn't a relational system at all. Pushing, streaming and event-based programming all might be better approaches to dealing with this particular use case, and each of these solutions means entertaining the idea of managing client state on the client server side.

"You've got all of these back-end enterprise systems and MQ products and people are trying to build systems on top of them using REST -- and maybe a better solution exists that is more lightweight and more in tune with what people are doing," said Bowen. For high-volume, high-bandwidth and highly interactive systems, the idea of stream-based patterns -- such as what Typesafe does with Akka's Actors model and what Netflix achieves with Reactive Extensions -- is simply a better way to architect a modern, SOA-based solution, Bowen added.

"So many companies have been demonstrating over the past couple of years that when it comes to high-volume and high-frequency data, streaming patterns help not just make it easier for the developer, but they help alleviate some of the things you have to deal [with] over the Internet, like latency," said Peter Hughes, lead engineer at Push Technology Ltd. "Streaming patterns are a more natural fit for the architectures of the modern, Internet-connected world."

When designing a modern enterprise system, always explore your options and don't fall into the trap of believing that REST-based Web services is the only way to go.

How have your architectures evolved beyond REST development? Let us know.

Dig Deeper on Software development best practices and processes

App Architecture
Software Quality
Cloud Computing