Who decides if you scored?
You play a football game online with nine other people. You press the shoot button.
Your phone shows the ball moving at once. But who decides if it is a goal? Your phone? Or a computer far away that sees all ten players?
Splitting work between your device and a distant computer is a key design choice.
Key words
| Word | What it means | Example |
|---|---|---|
| Local | Done on the user's own device. | reading a button press |
| Remote | Done on another computer. | sharing all player positions |
| Network | Computers joined together so they can send data to each other. | |
| Remote call | A request that one computer sends to another to do a job and answer. | |
| Latency | The delay between sending a request and getting the answer. | 50 milliseconds |
| System boundary | The line that shows what is inside your system and what is outside. | |
| External system | A system run by someone else that yours connects to. | a sports data feed |
| API | A set of rules that lets one program ask another for data or a job. |
The cells students fill in are left blank in this preview.
Local or remote?
Some jobs must be local. They must be fast, and only your device needs them. Reading a button press is local.
Some jobs must be remote. They need data from many people, or the result must be trusted. The score of a multi-player game is remote, so nobody can cheat.
Every remote job adds latency. That is a delay.
Quick check: local or remote?
Have a go
Quick check: local or remote?
3 questionsA system boundary
flowchart LR
subgraph ours[Inside our system]
subgraph device[Player device: local]
input[Read buttons]
draw[Draw the screen]
end
subgraph server[Game server: remote]
rules[Check the rules]
share[Share positions]
end
end
feed[(External sports data feed)]
input -->|move request| rules
rules -->|result| draw
share -->|positions| draw
feed -->|real squads| rules
What sits where, and why
| Part | Where it is | Why |
|---|---|---|
| Read buttons | Local | Must feel instant |
| Draw the screen | Local | Your device has the screen |
| Check the rules | Remote | The result must be trusted |
| Share positions | Remote | Needs data from all players |
| Sports data feed | External | Run by another company; we only connect to it |
The cells students fill in are left blank in this preview.
How are they connected?
Data moves between local and remote parts over a network. The type of network matters. Home Wi-Fi is fast. Mobile data can be slow or stop working. A college network may block some data.
Often your design combines networks. A phone uses Wi-Fi at home, mobile data on a bus, and then the internet to reach the server.
Quick check: the network
Have a go
Quick check: the network
3 questionsMatch each term to its meaning
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
A remote call over time
sequenceDiagram
participant P as Player phone
participant S as Game server
participant F as Sports data feed
P->>S: start a match
S->>F: ask for this week's real squads
F-->>S: squads
S-->>P: teams ready
P->>S: shoot request
S-->>P: goal or no goal
Plan which jobs run local or remote
A game has jobs. For each job you know two facts: does it need data from other players, and must the result be trusted? Write three functions. The first says "local" or "remote" for one job. The second makes a plan for all jobs. The third counts the remote jobs. Press Run Tests.
def where_runs(needs_other_players, must_be_trusted):
# A job runs "remote" (on the server) if it needs data from other players
# or if the result must be trusted (so nobody can cheat).
# Otherwise it runs "local" (on the player's own device).
return None
def make_plan(jobs):
# jobs is a dictionary: name -> (needs_other_players, must_be_trusted)
# Give back a dictionary: name -> "local" or "remote".
return None
def count_remote_calls(plan):
# How many jobs in the plan run "remote"?
return None
Make a free account to save your work, or press Start lab to work through the whole lesson.
Draw the calls in order
A fan opens a football app. The app asks our server for live scores. The server asks an outside data feed. The feed answers the server. The server answers the app. Finish the sequence diagram. Add the missing messages.
sequenceDiagram
participant A as Fan app
participant S as Our server
participant F as Outside data feed
A->>S: ask for live scores
%% Add: the server asks the feed.
%% Add: the feed answers the server.
%% Add: the server answers the app.
Make a free account to save your work, or press Start lab to work through the whole lesson.
Draw the app's system boundary
Draw the system boundary for the same football app. Put the fan app and our server inside the boundary. Put the data feed outside it. Label every arrow with the data that moves.
flowchart LR
subgraph ours[Inside our system]
app[Fan app]
end
%% Add the server inside the boundary.
%% Add the outside data feed.
%% Add labelled arrows between them.
Make a free account to save your work, or press Start lab to work through the whole lesson.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Exit quiz
Have a go