Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

How the parts of a web app fit

After this lesson: I can sketch how the parts of a simple web app fit together.

45 min lessonNo commands

Friday night at the takeaway

A takeaway's ordering site works well all week. On Friday at 7pm, 2,000 people open the menu at once. The site becomes very slow.

The code is fine. The problem is how the parts fit together. Engineers sketch those parts as boxes and arrows before they change anything.

By the end of this lesson

Note

I can sketch how the parts of a simple web app fit together.

Key words

WordWhat it means
Clientthe app or browser a person uses
Serverthe computer that runs the backend
Databasewhere data is stored for good
Cachea fast, short-term copy of data that is read often
Queuea waiting list of jobs to do later
Workera program that takes jobs from a queue and does them

The cells students fill in are left blank in this preview.

Every web app has three core parts

The client is what the customer holds: a phone app or a browser. It sends requests.

The server runs the backend. It checks each request and decides the answer.

The database keeps the data: menus, orders, customers. The client never talks to the database directly. It always goes through the server.

A cache saves work, a queue delays it

The menu changes once a day but is read 2,000 times a minute. A cache keeps a copy in fast memory, so the database is not asked every time.

A receipt email is slow to send, and the customer should not wait for it. The server puts it on a queue and answers at once. A worker sends it a moment later.

Worked example: a Friday order

StepPartWhat happensTime taken
1ClientOpens the menuInstant
2CacheSends the menu copy2 ms
3Server and databaseChecks and saves the order40 ms
4QueueHolds the email job1 ms
5WorkerSends the receipt later800 ms, nobody waits

The cells students fill in are left blank in this preview.

A common mistake

Warning

Many people think a cache is where data is stored. A cache can be emptied at any moment. Keep the real data in the database, and only copy into the cache what you can rebuild.

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.