Ticker

6/recent/ticker-posts

Representational State Transfer (REST) in Cloud Computing

Representational State Transfer (REST)

  • APIs are for software components; a way for software to interact with other software.
  • Web Services are a set of rules and technologies that enable two or more components on the web to talk to each other.
  • Not every API is a web service.
  • REST API is a web service.
  • REST API is an API that follows the rules of REST specification.
  • A web service is defined by rules:
    1. How software components will talk?
    2. What kind of messages they will send to each other?
    3. How requests and responses will be handled?

HTTP and REST

  • HTTP is an application layer protocol for sending and receiving messages over a network.
  • REST is a specification that dictates how distributed systems on the web should communicate.
  • REST is a way to implement and use the HTTP protocol.

REST and Systems of Systems

  • SOA focuses on loosely coupled software applications running across different administrative domains, based on common protocols and technologies, such as HTTP and XML.
  • SOA is related to early efforts on the architecture style of large scale distributed systems, particularly Representational State Transfer (REST).
  • REST still provides an alternative to the complex standard-driven web services technology.
  • Used in many Web 2.0 services.
  • REST is a software architecture style for distributed systems, particularly distributed hypermedia systems, such as the World Wide Web.

Applications:
  • Google, Amazon, Yahoo, Facebook and Twitter

Advantage:
  • Simplicity
  • Ease of being published and consumed by clients.

A simple REST interaction between user and server in HTTP specification
A simple REST interaction between user and server in the HTTP specification

REST Principles

The REST architectural style is based on four principles:
  1. Resource Identification through URIs
  2. Uniform, Constrained Interface
  3. Self-Descriptive Message
  4. Stateless Interactions

Resource Identification through URIs

  • The RESTful web service exposes a set of resources which identify targets of interaction with its clients.
  • The key abstraction of information in REST is a resource.
  • Any information that can be named can be a resource, such as a document or image or a temporal service.
  • A resource is a conceptual mapping to a set of entities.
  • Each particular resource is identified by a unique name, or more precisely, a Uniform Resource Identifier (URI).
  • URI is of type URL, providing a global addressing space for resources involved in an interaction between components as well as facilitating service discovery.
  • The URIs can be bookmarked or exchanged via hyperlinks.
  • URIs provide more readability and the potential for advertisement.

Uniform, Constrained Interface

  • Interaction with RESTful web services is done via the HTTP standard, client/server cacheable protocol.
  • Resources are manipulated using a fixed set of four CRUD (create, read, update, delete) verbs or operations:
    1. PUT
    2. GET
    3. POST
    4. DELETE
  • PUT creates a new resource.
  • The resource can then be destroyed by using DELETE.
  • GET retrieves the current state of a resource.
  • POST transfers a new state onto a resource.

Self-Descriptive Message

  • A REST message includes enough information to describe how to process the message.
  • This enables intermediaries to do more with the message without parsing the message contents.
  • In REST, resources are decoupled from their representation so that their content can be accessed in a variety of standard formats
  • Eg:- HTML, XML, MIME, plain text, PDF, JPEG, JSON, etc.
  • REST provides multiple/alternate representations of each resource.
  • Metadata about the resource is available and can be used for various purposes.
    • Cache control
    • Transmission error detection
    • Authentication or authorization
    • Access control.

Stateless Interactions

  • The REST interactions are “stateless”
  • The message does not depend on the state of the conversation.
  • Stateless communications improve visibility, reliability and increase scalability
  • Decrease network performance by increasing the repetitive data

REST - Advantages

  • RESTful web services can be considered an alternative to SOAP stack or “big web services
  • Simplicity
  • Lightweight nature
  • Integration with HTTP