views:

73

answers:

3

My next project involves the creation of a data API within an enterprise framework. The data will be consumed by several applications running on different software platforms. While my colleagues generally favour SOAP, I would like to use a RESTful architecture.

Most of the applications will only need a few objects at every call. Other applications will however sometimes need to make several sequential calls each involving thousands of records. I'm concerned about performance. Serialization/deserialization & network usage are where I fear to find a bottleneck. If each request involves a large delay, all of the enterprise's applications will be sluggish.

Are my fears realistic? Will serialization to a voluminous format like XML or JSON be a problem? Are there alternatives?

In the past, we've had to do these large data transfers using a "flatter"/leaner file format such as CSV for performance. How can I hope to achieve the performance I need using a web service?

While I'd prefer replies specific to REST, I'm interested in hearing how SOAP users might deal with this as well.

+1  A: 

One advantage of REST is that you are free to use whatever media type you like. Why not continue to use text/csv? You could also enable HTTP compression to further reduce bandwidth consumption.

REST services are great for taking advantage of all different kinds of data formats. Whatever format fits your scenario best.

Darrel Miller
One disadvantage of REST is that someone is free to use whatever media type they want. ps :soap also allow gzip compression. Personally i think that REST generate fancy url and that's it, fine for the customer (if they really care) but a pain in the *ss for the developer.
magallanes
@magallanes You are correct, choice is a double edged sword, but when you choose wisely it is a powerful weapon. Unfortunately, due to marketing reasons, the mainstream understanding of REST is far from reality. I can assure you that what you think it is, it is not.
Darrel Miller
While I think Manuel's reply more directly answers the question, I really like your suggestion and am looking into implementing it. Thanks!
Mr Grieves
A: 

I'd like to offer three guidelines:

  1. one is the observation that there are many SOAP Web services out there (especially built with .NET 2.0 "ASMX" technology) that send down their data transfer objects serialized in XML. There are of course many RESTful services that send down XML or JSON. XML serialization/deserialization is rarely the constraining factor.
  2. one common cause of bottlenecks in Web services is an interface that encourages client applications to get data by making those thousands of sequential calls (there is a term for it: a chatty interface). This is what you should avoid when you design your Web service's interface, regardless of what four-letter acronym you decide to go ahead with.
  3. one thing to remember about REST is that it (partially) stands for a transfer of state, which may be ill-suited to some operations where you don't want to transfer the state of a business object from the server to a client application. In those cases, a SOAP Web service (as suggested by your colleagues) is more appropriate; or perhaps a combination of SOAP and REST services, where the REST services would take care of operations where the state transfer is appropriate, and the SOAP services would implement the rest (pun unintended :-)) of the operations.
azheglov
I am intrigued by your definition of "state". How is the state of an object transferred any differently using a RESTful web service vs a SOAP one?
Nemi
+1  A: 

We offer both XML and JSON. Your mentioned rendering time really can be an issue. On server side we have JAXB whose standard sun-implementation is somewhat slow, when it comes to marshall XML. XML has the disadvantage of verbosity, but is also nice in interoperability and has schema + explicit versioning.

We compensated the verbosity in several ways (especially limiting the result-set):

  • In case you have a container with items in it, offer paging in your xml response (both page-size and page-number, e.g. /items?page=0&size=3) . The client can itself reduce the size by reducing the page-size.
  • Offer collapsing elements, for instance several clients are only interested in one data field of your whole item. Do this with a parameter (e.g. /items?select=name), then only the nested element 'name' is included inline of your item element. This dramatically decreases size.

Generally give the clients the power to use result-set limiting. They will definitley use it, because it speeds up response time also on their side :)

Also use compression, it reduces verbose XML extremely (in our case the payload got 10 times smaller). From client side you can do it by header 'Accept-Encoding: gzip'. If you use Apache, server configuration is also straight-forward

manuel aldana