CSE Roadmap

Core tier · about 4 hours · 10 parts

Part 3 of 10 · 1 min read

Split the web tier from the data tier

Why the database moves to its own machine, and how to choose a type of database.

As users grow, one server is no longer enough. The first step is to give the database its own machine.

Web tier and data tier

The web tier is the group of servers that handle requests from users. The data tier is the group of machines that store the data. A tier is a layer that can be sized on its own.

Example: two machines, one running the website and one running the database.

Splitting lets each tier grow separately. A website that is heavy on calculation needs more web servers. A website with large data needs a bigger database.

Which type of database? There are two big families.

  1. Relational databases store data in tables of rows and columns, and can join tables with a language called SQL. MySQL and PostgreSQL are well known. They have been around for over forty years, and they work well for most needs.
  2. Non-relational databases, also called NoSQL, come in four kinds: key-value, graph, column and document. They usually do not support joins.

A non-relational database may be the right choice if the application needs very low delay, if the data is not tabular, if data only needs to be saved and loaded as it is, or if the amount of data is huge.

Relational database

A relational database stores data in tables whose rows can be linked to rows in other tables, and answers questions in a language called SQL.

Example: a customers table and an orders table, joined by customer id.

Level 2 covers the choice in depth. For now, the rule is: start with a relational database unless there is a clear reason not to.

Check yourself:

  • Why does splitting web and data tiers help with growth?
  • Name one reason to pick a non-relational database.