Developing Distributed Web Applications, Where does REST fit in?<br />Dr. Srinath Perera<br />Senior Software Architect, W...
What is a Distributed Web Application?<br />Users access a one server (or he thinks he does) while really the app is compo...
Google as a Distributed Web Application<br />Google crawls the Web and stores all  (well most of ) the Web<br />It builds ...
Programming Distributed Web Applications<br />Essentially (Web) applications  deal with state (data) and operations (execu...
SOA (Service Oriented Architecture)<br />There are many stateless processing units (often grouped as services)<br />Users ...
ROA (Resource Oriented Architecture)<br />There is a resource structure<br />Each resource supports four operations, PUT, ...
ROA vs. SOA<br />There are lots of fights, which I am not going to discuss in detail. <br />Argument is Web uses ROA, and ...
REST (Representational State Transfer)<br />ROA is realized with REST services or HTTP services (Good intro to REST, http:...
Example: Web App to Manage a Network<br />Assume we want to build a Web app to manage networks. Users can view, query, and...
With SOA<br />Architecture will include a database to hold network data and services supporting following operations<br />...
With REST<br />Give everything a ID (URI)<br />http://uom.lk/Networks<br />http://uom.lk/Networks/ENT<br />http://uom.lk/N...
With REST (Contd.)<br />Resources can return multiple formats<br />Results can return multiple formats, XML, Jason, Binary...
Implementing REST Services<br />Define the resources structure <br />Define many URLs for different types of resources<br ...
REST Anti-patterns<br />Verbs in URLs<br />http://uom.lk/SearchNetworks?pattern=foo<br />This is doing SOA using HTTP, not...
REST, is it the Architecture to solve them all?<br />Does the REST a silver bullet for all problems<br />This is the sourc...
So when to use it?<br />Use when REST is the natural choice <br />It is very good at representing resources <br />Not that...
Conclusion<br />What is a Distributed Application? <br />SOA and ROA as solutions <br />Detailed looked at ROA with a Exam...
For more information<br />Stefan Tilkov: A Brief Introduction to REST, http://www.infoq.com/articles/rest-introduction<br ...
Questions?<br />
Upcoming SlideShare
Loading in …5
×

Developing Distributed Web Applications, Where does REST fit in?

8,920
-1

Published on

Published in: Technology, Sports
2 Comments
6 Likes
Statistics
Notes
  • amazing slide bravo (clap) it cleared up my mind after weeks of researching and i think i found a architectural principle for my self use ROA for outer world use SOA for inner world of your system make your system service based deal with clients resource based. What is your opinion for this idea?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Did this talk in INET Colombo yesterday
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
8,920
On Slideshare
0
From Embeds
0
Number of Embeds
15
Actions
Shares
0
Downloads
115
Comments
2
Likes
6
Embeds 0
No embeds

No notes for slide

Developing Distributed Web Applications, Where does REST fit in?

  1. 1. Developing Distributed Web Applications, Where does REST fit in?<br />Dr. Srinath Perera<br />Senior Software Architect, WSO2 Inc.<br />Visiting Faculty, University of Moratuwa<br />
  2. 2. What is a Distributed Web Application?<br />Users access a one server (or he thinks he does) while really the app is composed of many machines. <br />Why “Distributed”? <br />for scaling. Single machine can not handle the load<br />High availability <br />photo by arvindgrover on Flickr, http://www.fotopedia.com/items/flickr-3154212659<br />
  3. 3. Google as a Distributed Web Application<br />Google crawls the Web and stores all (well most of ) the Web<br />It builds indexes for included words and incoming links for each document<br />When a user sends a query, it applies the Page Rank Algorithm and returns the most relevant results. <br />It is a distributed application that built using few 100k servers<br />
  4. 4. Programming Distributed Web Applications<br />Essentially (Web) applications deal with state (data) and operations (executions or processing units)<br />Users talk to applications and either retrieve data or make changes to the current state. <br />There are two primary architectural models<br />SOA (Service Oriented Architectures) : based on processing units (verbs)<br />ROA (Resource Oriented Architecture): based on data(nouns)<br />photo by QolePejorian on Flickr, http://www.fotopedia.com/items/flickr-184160623<br />
  5. 5. SOA (Service Oriented Architecture)<br />There are many stateless processing units (often grouped as services)<br />Users provide data to processing units, and they either return data after processing or change the system wide state (e.g. stored in the database).<br />A SOA based architecture includes a main storage (e.g. database) and many stateless processing units, and an application combines and composes those processing units together. <br />E.g. Google has its indexes etc., and one main operation “search” that accepts a search query as a input and returns matching documents. <br />Also implementation has many internal services <br />photo by L. Marie on Flickr, http://www.flickr.com/photos/lenore-m/312319615/<br />
  6. 6. ROA (Resource Oriented Architecture)<br />There is a resource structure<br />Each resource supports four operations, PUT, GET, POST, DELETE<br />Users retrieve information through GET and change system state through POST, DELETE, and PUT<br />The architecture is based on resources (nouns) and processing is represented through four verbs on the resource. <br />photo by Svadilfari on Flickr, http://www.flickr.com/photos/22280677@N07/2435832518/ (CC)<br />
  7. 7. ROA vs. SOA<br />There are lots of fights, which I am not going to discuss in detail. <br />Argument is Web uses ROA, and it works. <br />SOA is much closer to the programing models we used to with languages like C or Java. So that is natural to us. <br />I would say, they are two useful styles, and we have to know both and use them where it naturally fits. <br />I will focus more on ROA for this discussion. <br />photo by hans s on Flickr, http://www.flickr.com/photos/archeon/2359334908/<br />
  8. 8. REST (Representational State Transfer)<br />ROA is realized with REST services or HTTP services (Good intro to REST, http://www.infoq.com/articles/rest-introduction)<br />Main principles of REST<br />Give everything an ID (URI)<br />Things (resources) refer to each other <br />All interactions are done through four verbs (PUT, GET, DELETE, POST) on resources<br />Photo by paraflyer on Flickr, http://www.fotopedia.com/items/flickr-386529128<br />Resources can return multiple formats (choosed based on content negotiation) <br />All communication are stateless (each request has all the information need to serve the request)<br />
  9. 9. Example: Web App to Manage a Network<br />Assume we want to build a Web app to manage networks. Users can view, query, and change the network configurations through this Web App. <br />Lets see how this would look with both SOA and REST<br />Photo by sylviaduckworth on Flickr, http://www.geograph.org.uk/photo/956353<br />
  10. 10. With SOA<br />Architecture will include a database to hold network data and services supporting following operations<br />ListNetworks()<br />NetworkDataGetNetworkData()<br />ApplyNetworkData(NetworkDataquearyParams)<br />SearchNetworks(String queryParams)<br />Notice Each operation is a Verb, users combine those verbs to do what he needs<br />Message formats are defined through a WSDL and each service supports one message format. <br />
  11. 11. With REST<br />Give everything a ID (URI)<br />http://uom.lk/Networks<br />http://uom.lk/Networks/ENT<br />http://uom.lk/Networks/Civil<br />Things (resources) refer to each other <br />Retrieving a network will return something like <br /><Networks><br /><cse ref=“http://uom.lk/Networks/CSE”/><br /> ….<br /></Networks><br />All interactions are done through four verbs (PUT, GET, DELETE, POST) on resources<br />GET on http://uom.lk/Networks/CSE : Getting network data <br />POST on http://uom.lk/Networks/CSE: update the network config.<br />DELETE on http://uom.lk/Networks/CSE can delete the network etc. <br />
  12. 12. With REST (Contd.)<br />Resources can return multiple formats<br />Results can return multiple formats, XML, Jason, Binary or several XML formats etc. <br />Clients send the header Accept: text/json, text/xml+foo defining supported formats, and the server returns result in a format client supports. This means a resource can support multiple formats at the same time. Also we can use this to support new formats later. <br />All communication is stateless – this is same for SOA and ROA<br />System can use HTTP style caching <br />
  13. 13. Implementing REST Services<br />Define the resources structure <br />Define many URLs for different types of resources<br />Use a REST engine to attach code to each URL patterns, they support four verbs (e.g. see http://www.sinatrarb.com/intro)<br />Code segment is for URL, verb, content type<br />Example<br />http://…/Networks:<br />On GET text/xml do<br />….<br />end<br />Photo by Kevin Dooley on Flickr, http://www.flickr.com/photos/pagedooley/2201791390/<br />
  14. 14. REST Anti-patterns<br />Verbs in URLs<br />http://uom.lk/SearchNetworks?pattern=foo<br />This is doing SOA using HTTP, not REST<br />Ignoring status codes on responses <br />Not including references in responses <br /><Networks><br /> <cse><br /> <nodeCount>..</nodeCount><br /> <subnetmask> ..</subnetmask><br /><cse><br /></Networks><br />Use references whenever that makes sense, do not copy data in to response. Remember the underline linked resource structure. <br />
  15. 15. REST, is it the Architecture to solve them all?<br />Does the REST a silver bullet for all problems<br />This is the source for most fights, the answer looks “No”. Some examples.<br />It does not have a contract (Lack a WSDL) <br />Messaging – does not talk about eventing/ messaging aspects. May be need a SUBSCRIBE verb added. <br />Asynchronous invocations and reliability<br />What about composition and transactions etc. mostly things come from WS-* <br />Does error messages are enough? <br />Photo by Playaduraon Flickr, http://www.flickr.com/photos/playadura/1401756881<br />
  16. 16. So when to use it?<br />Use when REST is the natural choice <br />It is very good at representing resources <br />Not that good with processes/ executions <br />Same for SOA<br />Is it OK to mix it? <br />I would say yes, but not too much<br />WSO2 use REST for registry API, while SOA for many other places. <br />Photo by QUEEN YUNA on Flickr, http://www.flickr.com/photos/queenyuna/5710802864/ (CC)<br />
  17. 17. Conclusion<br />What is a Distributed Application? <br />SOA and ROA as solutions <br />Detailed looked at ROA with a Example<br />It is the architecture that solves everything? “Look like we need both”<br />
  18. 18. For more information<br />Stefan Tilkov: A Brief Introduction to REST, http://www.infoq.com/articles/rest-introduction<br />Stefan Tilkov: REST Anti-Patterns, http://www.infoq.com/articles/rest-anti-patterns<br />More articles here http://en.wikipedia.org/wiki/Representational_State_Transfer<br />SanjivaWeerawarana: WS-* vs. REST: Mashing up the Truth from Facts, Myths and Lies, http://wso2.org/library/2818<br />
  19. 19. Questions?<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×