Thursday, February 28, 2013

REST and HTTP : Origin of REST continued ...........



Continuing from the last page REST and HTTP ......

Roy Fielding's New Web Architecture

  • Client - Server -  See REST and HTTP
  • Uniform Interface - See REST and HTTP
  • Stateless - All exchanges/communication between a client and server are stateless in nature. That is, each request contains all of the information necessary for a connector to understand the request, independent of any requests that may have preceded it. This restriction accomplishes four functions: 
    • It removes any need for the connectors to retain application state between requests, thus reducing consumption of physical resources and improving scalability; 
    • It allows interactions to be processed in parallel without requiring that the processing mechanism understand the interaction semantics;
    • It allows an intermediary to view and understand a request in isolation, which may be necessary when services are dynamically rearranged. It thus induces visibility
    • It forces all of the information that might factor into the re-usability of a cached response to be present in each request. 
        However this constraint imposes a trade-off. It decreases network performance by increasing      the repetitive data exchange. Also placing the application state in the client-side redues server's control over management of application state.
  • Cache - This constraint requires that the data send by the server in the response be explicitly tagged as cacheable or non-cacheable.If the response is cacheable then the client gets the right to re-use the data to serve subsequent requests.It improves efficiency, scalability and user-perceived performance by reducing the average latency of a series of requests. However the disadvantage is that it decreases reliability, when the cached data becomes stale and does not match the data on the server. This may occur when the resource on the server gets modified while the cache is still awaiting to be updated with the current resource state on the server.
  • Layered System - The layered system constraints enable network-based intermediaries such as proxies and gateways to be transparently deployed between a client and server using the Web’s
    uniform interface. Intermediate layers can  be used to improve system scalability by enabling load balancing of services across multiple networks and processors.The combination of layered system and uniform interface constraints induces architectural properties similar to those of the uniform pipe-and-filter style . Intermediary components can actively transform the content of messages because the messages are self-descriptive and their semantics are visible to intermediaries.
  • Code-On-Demand - This constraint allows clients to download code, scripts or plugins from the server , which then can be executed by the client. This simplifies clients by reducing the number of features required to be pre-implemented. However, it also causes technology coupling between client and server as the client must have the expertise to execute the downloaded code.

REST 

The above Web Architectural Style composed of the constraints already outlined, was named
and described by Fielding in his Ph.D. dissertation as “Representational State Transfer” (REST) .


Wednesday, February 27, 2013

REST and HTTP : Origin of REST



REST  an acronym for 'Representational State Transfer' seems to the latest sensation for web services development. With 'World Wide Web' expanding to gigantic proportions, better and ever expanding internet bandwidth speed, exponential surge in the mobile users across the globe, all of which have propelled companies to move from 'Product' paradigm to a 'Cloud' deployment paradigm.

Evolution of REST as web services concept has its root in inception of 'World Wide Web' and hence evolution of HTTP itself.

Tim Berners-Lee's 'World Wide Web'

 

Way back in 1990 Tim Berners-Lee envisaged -
"The WorldWideWeb (W3) is a wide-area hypermedia information retrieval initiative
aiming to give universal access to a large universe of documents."
 This project, he named, 'WorldWideWeb' , for sharing of knowledge and data between sever and client. Within a year he has implemented a new web architecture :
  • The Uniform Resource Identifier (URI), a syntax that assigns each web document a unique address
  • The HyperText Transfer Protocol (HTTP), a message-based language that computers could use to communicate over the Internet
  • The HyperText Mark-up Language (HTML), to represent informative documents that contain links to related documents
  • The first web server
  • The first web browser, which Berners-Lee also named “WorldWideWeb” and later renamed “Nexus” to avoid confusion with the Web itself
  • The first WYSIWYG§ HTML editor, which was built right into the browser.
Web traffic, over the time , started expanding exponentially, outgrowing the then Internet infrastructur. Web protocols, particularly support for caches, were not used to their optimum capacity. Web's scalability problem eventaully became a cause of worry among the concerned people.

Roy Fielding's New Web Architecture

 

 Roy Fielding, co-founder of the Apache HTTP Server Project, project a new Web Architecture with following constraints while leaving the implementation free to design
  • Client - Server - This assigns a separate and independent roles to client and server. This separation allows clients and servers to remain 'detached' from each other. They would rather interact with each other through a common interface. This 'Uniform Interface' would give flexibility to the server so that applications could be deployed across different machines with different technologies.
  • Uniform Interface - Interaction between client , server and any intermediate application would take place through a 'Uniform Interface'. This decouples the different web components and allows them to grow independently. This is defined by four constraints 
    • Indentification of Resource and Resource identifiers - A resource is an abstract word to represent a node of information that can be accessed and/or modified by a web component, such as a client.For e.g it could be a file, document  or a collection of othere resources. "More precisely, 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. The values in the set may be resource representations and/or resource identifiers ".             For example, the "get the last entry of my collection" is a mapping whose value ( last entry ) changes over time, assuming 'my collection' gets modified over time, whereas a mapping to "No of years Mahatma Gandhi lived" is static. Resource Identifiers  is an URI ( Uniform Resource Identifier )  to identify a particular resource on the server.
    • Resource Representation - Clients perform actions on a resource by using a representation of the resource. This representation is the intended/desired state required by the client. A representation consists of  data or message, which is a sequence of bytes, together with the metadata to describe those bytes.A resource may have multiple representation. A HTML document, a PDF document or an Image file, etc are some examples for different resource representation
      • Control data - It defines the purpose of the message such as the action being requested or request parameters to override some default behaviour. E.g cache-control
      • Resource Representation Metadata - This defines additional information for different resource representation, send in the request by the client or send in the response by the server. HTTP headers are used to represent  the metadata like content-type of the data, language, media type
      • Resource Metadata - This defines additional information for resource which is different from the Resource Representation, such as Location, source link, date
    •  Connectors - Connectors manage network communications for a web component. They encapsulate the activities of accessing resources and transferring resource representations.Different connector types are :
      • Client - This initiates a communication by making a request
      • Server - This listens to the requests from different client and sends a response
      • Cache - This  saves cacheable responses to current interactions so that they can be reused for later requested interactions. They are located on either the client interfaces or the server.
      • Resolver - A resolver translates partial or complete resource identifiers into the network address information needed to establish an inter-component connection, such as  DNS resolvers. 
      • Tunnel - This simply relays communication across a connection boundary, such as a firewall or lower-level network gateway.

                      >> page 2                                                        >> page 2