What happens when you open an app

0/3
☰
Fundamentals · system design

Opening an app is a relay race: find the address, open a private line, ask, and get an answer back — and almost every speed trick is about running fewer laps, or shorter ones.

+ The whole system in one paragraph

When you open an app, your phone first looks up where the app lives (DNS), opens a private connection to it (TCP and TLS), sends the request and waits. Each trip across the network costs a round trip, so the big wins are fewer trips and shorter ones: a copy of the answer close to you (a CDN).

In this lesson

3 chapters · ~5 min · a quick check in each

Everything is on this page — just scroll down ↓

New to this? Warm up first+ optional
1
Requirements

What every request needs — and how well

Start here. Yellow notes are the four jobs every request needs done; blue ones are what 'good' means. Each piece of the trip exists for one of these.

ⓘ Details & sources

Yellow = what has to happen. Blue = how well.

Find the addressfrom a name.Open a privateconnection.Send the request,get the answer.Keep working if aserver dies.Fast: as few roundtrips as possible.Close: answer fromnear you.Private: encryptedon the way.Resilient: onlyhealthy servers.
2
At a glance

Words you'll meet

Skim these now and come back whenever one shows up.

ⓘ Details & sources

The terms, in plain words.

IP addressA server's number on the internet, like astreet address.DNSThe internet's phone book: turns a name into anIP address.ResolverThe DNS server you ask first; it finds theanswer and caches it.TTLHow long an answer may be cached before askingagain.Round trip (RTT)The time for a message to reach the other sideand a reply to come back.TCPThe protocol that delivers bytes in order andresends lost ones.TLSThe encryption layer that makes HTTPS private;it starts with a handshake.QUIC / HTTP/3A newer transport that sets up the connectionand the encryption together.HTTP / GETThe language of the request: GET /feed means'give me the feed'.CDNServers in many cities that keep copies ofanswers close to users.EdgeA CDN server near you, at the edge of thenetwork.Load balancerThe front door that spreads requests acrosshealthy servers.Health checkA small test request the load balancer sends tosee if a server is alive.
Chapter 1 of 3

The whole trip

3
Up close

Try it: where do the milliseconds go?

Flip the switches: an open connection skips the lookup and the handshake; a CDN copy near you makes every round trip short. Times are illustrative; the 150 ms ocean trip is real.

ⓘ Details & sources

Every trip across the network costs a round trip. Fewer trips, or shorter ones, is the whole game.[7]

Follow one requesttap a hop · flip the switches belowConnectAsk505 msyou feel this waitDNS · find the address30 msConnect · TCP + TLS 1.3300 msAsk · the request + answer150 msServer · app + database25 msIllustrative times; far = 150 ms, a trip across the ocean and back.
4
Sequence

One request, in time order

The same trip as a timeline. Each arrow is a message; each pair of arrows is one round trip. Count them: that's most of the wait.

Your phoneDNS resolver1. Where is the app?DNS resolverYour phone2. Its IP addressYour phoneCDN / server3. TCP: can we talk?CDN / serverYour phone4. TCP: yesYour phoneCDN / server5. TLS hello + my keyCDN / serverYour phone6. Keys agreedYour phoneCDN / server7. GET /feed (encrypted)CDN / serverYour phone8. The answer

8 steps. Follow the flow one step at a time — what happens first, and what comes next.

5
Architecture

The whole trip, on one page

Top: finding the address. Middle: the request's path, from the edge near you to a server in the data center. Right: where the answer comes from.

ⓘ Details & sources

Click a box to see what it does and why; play a flow to follow one request.[1][6][8][9]

Watch it happen:
where is it?1234455Your phone: Where it starts: the app needs something from a server far away.Your phonethe appDNS resolver: The phone book you ask first: it finds the server's address for you.DNS resolverprovider's or publicThe app's DNS: The server that holds the official answer for this app's name.The app's DNSknows the real addressCDN edge: A server in or near your city that keeps copies of popular answers.CDN edgea copy near youLoad balancer: The front door of the data center: sends each request to a server that's up.Load balancerpicks a healthy serverApp server: Runs the app's code for your request.App serverruns your requestApp server: An identical copy, so one can fail and the app keeps working.App serversame code, a spareCache: Answers asked for a lot, kept in memory so the database isn't asked every time.Cachehot answers in RAMDatabase: Where the app's data really lives, saved on disk.Databasethe real data
youyour system dashed = our simplification
12345
Step 1 of 5

Your phone asks the DNS resolver for the app's address.

Quick check

A CDN keeps a copy of the answer in a server near you. What does that change on the trip?

Pick one — or just keep scrolling, it's not graded.

Keep going — it's free

Create your free account to unlock the rest of this lesson, keep your progress and pick up right where you left off.

  1. 2Step by step
  2. 3When it's slow
Questions & comments

Ask anything about this system, or share how you'd design it.

Log in to join the conversation