Representational State Transfer (REST): Web Architecture Style

Understand the constraints of REST architecture style and its purpose.

Motivation

In December 1990, Tim Berners-Lee had a vision for information sharing and started a World Wide Web (or simply the web) project. Initially, during the World Wide Web’s design phase, the web was for a limited number of people; however, when it was opened to the public, the number of users started multiplying and increased to 40 million within five yearsMasse, Mark. REST API Design Rulebook.O'Reilly Media, 2011.. Due to the increasing number of users, the web was on the way to collapse because the users' traffic was outgrowing the capacity of the Internet infrastructure. This behavior forced the software architects to design an efficient web architecture to make the web flexible, performant, and scalable to handle ever-increasing traffic. In this regard, the REST architecture style was proposed, and it plays a vital role in designing a scalable system.

Note: “All design decisions at the architectural level should be made within the context of the functional, behavioral, and social requirements of the system being designed, which is a principle that applies equally to both software architecture and the traditional field of building architecture.”

— Roy Fielding (The author of the Ph.D. dissertation that originally presented REST.)

Representational state transfer (REST)

REST is a well-known web architecture style proposed by Roy Fielding in 2000Roy Fielding originally presented REST in his Ph.D. dissertation. [R. T. Fielding, Architectural Styles and the Design of Network-based Software Architectures. University of California, Irvine, 2000.] to solve the web's scalability problem. Roy Fielding identified that the web's scalability could be directed by certain key constraints. These constraints are collectively called the web's architectural style. Further, these constraints also act as a backbone for designing REST APIsAn API that follows the REST constraints is called REST or RESTful API..

Hence, in order to scale the Internet, a pragmatic approach is adopted to satisfy all the following constraints:

  • Client-server

  • Cache

  • Stateless

  • Uniform interface

  • Layered system

  • Code-on-demand

We explain each constraint in detail below.

Client-server

Client-server is the most commonly employed architectural style for network-based applications. A server componentIn an architecture style, clients, servers, and other intermediate entities are considered components. that provides several services listens for a request for those services. The client communicates with the server via the Internet (connector), waiting for a request to be processed by the service. The client's request is either rejected or fulfilled by the server, which is communicated back to the client via a response.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.