Photo by bruce mars on Unsplash

The Constraints of REST

Bivás Biswas
Jun 27, 2019 · 9 min read

The Early Internet and Its Problems

What is the operating system of the Internet? There isn’t one. But, there is an architecture that the Internet follows so it can operate and achieve a massive amount of scale for millions and millions of …make that billions of users. That Architecture is called REST which stands for Representational State Transfer.

Why is REST Important

In the early 90s, the web started expanding. Like the Big Bang Theory, once it started it was unstoppable. It grew exponentially. Within the first 5 years of the Internet, the number of users grew to 40 million.

  1. Uniform Interface
  2. Layered System
  3. Cache
  4. Stateless
  5. Code-on-demand

What is REST API

The REST API is an Application Programming Interface that allows a client to access resources sitting on a server. These resources, at any given time, holds an accurate description of the system’s state.

I. Client-Server

The client and the server can have their own technology stack. How the server gets the job done is of no concern to the client and vice versa. When we flip the light switch we expect there to be light without concerning ourselves about how the electricity is being generated and being delivered to our homes. This is borrowed from the Software Engineering principle named Separation of Concerns. Wikipedia defines it as so-

In computer science, separation of concerns (SoC) is a design principle for separating a computer program into distinct sections, so that each section addresses a separate concern.

Separation of concerns allows for loose coupling. If a server goes down the request can be routed to a backup server and the client doesn’t need to know. The client and the server can continue to work together through this loose coupling as long as they adhere to the uniform interface.

II. Uniform Interface

Every resource on the internet can be accessed by a unique identifier. Like every home has a unique address in our world. In the digital world of information, every resource has a unique address.

The WorldWideWeb is a wide-area hypermedia information retrieval initiative aiming to give universal access to a large universe of documents

There are additional things that can be done while looking up a resource via its unique identifier.

a. Identification of Resources

Tim Berners Lee’s vision is that every data in that universe can and should be referenced directly. Every resource should have a Universal Resource Identifier (URI). Tim Berner’s Lee wrote these two axioms for the URI, which is also commonly referred to as the URL (Uniform Resource Locator)-

Axiom 0: Universality 1

Any resource anywhere can be given a URI

Axiom 0a: Universality 2

Any resource of significance should be given a URI.

URIs are divided into schemes like HTTP, FTP, telnet, etc. Each one of these schemes has its own specifications. These specifications determine what kind of resources can be accessed via these schemes.

b. Manipulation of resources through representation

The representation which is the format of the resource and the resource itself are two separate things. Each resource can be represented in different ways. This separation allows different clients to request the resource in a way that is usable for them.

Axiom: Opacity of URIs

The only thing you can use an identifier for is to refer to an object. When you are not dereferencing, you should not look at the contents of the URI string to gain other information.

-Tim Berners Lee

c. Self-descriptive messages

Clients and Servers talk to each other using messages. The client makes a request. The server sends a response. Each request is a message and each response is a message.

III. Layered System

The layered system constraint allows the architect to inject layers of service between the server and the client to efficiently serve the client request while the layering remains transparent to the client.

Source: Wikimedia Commons

IV. Cache

Caching reduces latency and the load on the server. It increases the availability and reliability of the application.

V. Stateless

This constraint allows the web to handle the massive scale of the internet.

VI. Code-On-Demand

This is an optional constraint. The reason this is optional is that this constraint increases coupling between the client and the server.

Summary

We studied the evolution of REST and how they play an instrumental role in providing scalability to the web.

Future Vision

A publication centered around high quality storytelling

Bivás Biswas

Written by

Harvard Business School. Former VP Engineering for AR startup. Former Computer Scientist for US Defense projects. www.PicturePerfectEgg.com

Future Vision

A publication centered around high quality storytelling

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade