One server runs everything
Every system you have heard of, Google, Netflix, WhatsApp, started as one program on one computer. This course grows that one computer into a planet-scale system, one problem at a time.
You already hold the prerequisites. From How the Internet Works you know a browser sends an HTTP request and gets back a response. From backend basics you know a server is a program listening on a port. From SQL you know a database stores rows in tables.
Our starting point, and the anchor picture for the whole course, is the simplest real architecture:
- One machine in a data center (engineers call it a box)
- The app process: your backend code, running on that box
- The database: running on the same box
Plenty of profitable products run exactly this. Never add complexity before the simple version breaks.
The life of one request
When a user taps Load feed:
- The browser sends
GET /feedacross the internet to your box (DNS and TCP, exactly as in How the Internet Works) - The app process runs your handler code
- The handler queries the database:
SELECT * FROM posts WHERE ... - The database reads rows from disk and returns them
- The app turns rows into JSON and responds
Total time is a few milliseconds of app code plus tens of milliseconds of database and network time. One box can do this thousands of times a minute without strain.
How much traffic is that in real units? The number system designers care about is requests per second, written RPS. Let us compute it.
Code exercise · python
Run this traffic calculator. It converts users per day into average requests per second, the basic unit of load. Notice how small the number is for 2,000 users.
Code exercise · python
Your turn. The app got popular: 50,000 users now make 20 requests each per day. Compute and print the same two lines: requests per day, then the average per second rounded to 2 decimals.
Quiz
A one-box app averages under 1 request per second, yet it crashes every evening at 8 pm. What is the most likely reason?