Skip to content
HLD Learn/Three-Tier Architecture & Scaling Up
Browsing as a guest. Sign in to save your progress and earn XP as you complete chapters.

Presentation, Logic, and Data Tiers

5 min read

You'll learn to

  • -Name the three tiers and say what each one is responsible for, using the hotel picture
  • -Trace one request through all three tiers and say where a business rule belongs
  • -Explain why separating the tiers lets each one change and scale independently
  • -Explain, with numbers, why the slowest tier sets the throughput of the whole system

Tip: the highlighter is on - just select any text below to mark it. Use the highlighter button up top to change color or turn it off. Highlights are saved on this device only. Log in to save them to your account instead.

Once a client and a server can exchange HTTP requests, the next question is where things live. A small project often runs as a single program that draws the screen, applies the rules and talks to the database all at once, and that is a perfectly good way to start. The trouble comes as it grows: changing the color of a button should not risk breaking billing, and a rush of shoppers should not force you to copy your entire application just because one part of it is busy. Almost every application, from a side project to a huge social network, solves this the same way, by splitting itself into three layers called tiers. This chapter explains what each tier is for, and why the split is the starting point for nearly everything else in the course.

An Analogy: A Hotel

Think of a hotel. The front desk is where guests ask for things: a room, a late checkout, a wake-up call. The manager decides whether the answer is yes: is a room free, is this guest allowed to extend their stay, does the corporate discount apply. And the reservation ledger in the back office is where the facts are written down, so that they survive a shift change, a power cut or a new manager. Each has a different job, and the arrangement only works because they stay separate. The front desk does not make policy, the manager does not keep the only copy of the bookings in their head, and the ledger does not decide anything: it simply remembers.

  • -The front desk is the presentation tier: what the user sees and touches, such as a browser page or a mobile screen. Its job is to show information and collect requests, not to decide anything.
  • -The manager is the logic tier (also called the application tier): the servers that apply the business rules, such as can this user afford this item, or is this password correct.
  • -The ledger is the data tier: the database that stores facts durably, so they outlive any single request and any server restart.

In a diagram, a request flows down through the tiers and the answer flows back up:

Presentation
Logic
Data

The three tiers: presentation, logic, and data.

One Request Through the Tiers

Follow one purchase, a customer buying two of item 42:

  • -Presentation: the page shows the item and the customer taps Buy. The browser sends: item 42, quantity 2.
  • -Logic: the server checks the customer is logged in, looks up the real price, confirms there is stock, applies any discount code, and decides whether the order is allowed.
  • -Data: the server asks the database to reduce the stock by 2 and record the order. The database does exactly that and reports back; it does not question the decision.
  • -Logic: the server builds a confirmation out of what the database returned.
  • -Presentation: the page shows Order confirmed.

Now ask where a rule like no more than 5 of an item per customer belongs. Not in the presentation tier: anyone can bypass a browser, as the last module showed. It belongs in the logic tier, the one layer you fully control and which can see everything it needs to decide. The data tier can enforce simple integrity rules, for example that a stock count never drops below zero, but business rules change often and need context, so they live above it.

Why Separate Them: Independence

The payoff is independence. You can redesign the screens without touching a single business rule. You can change the database engine without rewriting the screens. And, most importantly for this course, each tier can scale on its own schedule, driven by its own bottleneck: a flash sale might need ten times as many logic servers while the database needs nothing new.

The Weakest Tier Sets the Ceiling

Scaling separately does not mean any tier can be ignored, because every request passes through all of them. Here is a throughput example with made-up but realistic round numbers. Suppose each logic server handles 500 requests per second and you run 10 of them, so the logic tier can take 5,000 requests per second. Each request makes 4 database queries, and the database can answer 5,000 queries per second. Divide: 5,000 queries a second at 4 per request supports only 1,250 requests a second. Add more logic servers and nothing improves, because the database is the bottleneck. A chain is only as strong as its weakest link, and a system is only as fast as its slowest tier.

A Bottleneck in Numbers (illustrative)
5,000 req/s
What 10 logic servers could handle on their own
1,250 req/s
What the database allows: 5,000 queries per second divided by 4 queries per request
1,250 req/s
The real ceiling of the whole system, set by the slowest tier

The three-tier model has one landmine baked in from the start: the data tier is usually a single database, which becomes both a single point of failure and the hardest tier to scale. Nearly every topic for the rest of this course is, in one way or another, about relieving pressure on that one box.

In one line: three tiers, each with one job (show, decide, remember), so each can change and scale on its own; and because they work as a chain, the slowest tier, usually the single database, sets the ceiling for everything.

Interview Signal

Why not just put everything (UI logic, business rules, and data access) in one program?

Weak Answer

"Separation of concerns is a best practice."

Strong Answer

"Because each tier fails and scales differently. A traffic spike means I need more web servers, not more database copies. A schema change shouldn't require redeploying the UI. And if the data tier is compromised, the presentation tier being a separate, dumber layer limits the blast radius. Coupling them means every change (and every failure) has to be reasoned about across the whole system instead of one tier at a time."

Check Yourself1 / 5

Which tier is responsible for enforcing business rules like "can this user afford this item"?

Discussion0

Join the Discussion

Sign in to leave comments, reply to others, or like insights.

Sign In to ScaleDojo

No comments yet. Be the first to start the thread!