../

System Design

Table of Contents

How is a webpage accessed?

  1. Use browser to access a domain name through a Domain Name Service (DNS). DNS returns IP address.
  2. Use IP address to request webpage from HTML server via Hypertext Transfer Protocol (HTTP).
  3. Web server returns HTML page or JSON.

Databases

Web server might separately need a server for storing database. Web server can read from the database server, write to the database server. Database can be relational or non-relational. When should you use a non-relational database?

APIs

Most commonly, HTTP methods to interact with APIs. A typical API request might look like:

GET https://api.example.com/call

Here, GET is an HTTP method, https specifies the transfer protocol, api.example.com is the server address of the API, and /call is some path on the server (API endpoint). There are other ways to interact with APIs (like WebSockets), but HTTP/HTTPS is quite universal.

Other HTML methods include POST, PUT, DELETE, PATCH, etc.

HTTP Responses

Clients make requests by calling HTTP methods. Servers response using HTTP status codes. An example response could be:

HTTP/1.1 302 Found
Location: https://example.com/long-url

Here, the 302 status code corresponds to a temporary redirect response. This triggers the client (a browser, maybe) to make another request to the address specified by the Location header.

Example

Design a system for a URL shortner.