LESSON 01 · Scope and scale

Define the promise and estimate demand

A tiny link hides a read-heavy system with a durable mapping.

SYSTEM VIEW

The system

Diagram view
Writes—
Redirects—
Mappings—

Watch one link get created and opened, then scale both actions to 30 million links a day.

  1. A creator posts a long URL to the Create service. It stores one mapping, a record pairing short key x7Kp2Qa with that URL, in the Mapping database and answers 201 with the short link.

    What changed

    • Mapping x7Kp2Qa
    • Creator has the short link
  2. A visitor opens the short link. The Redirect service reads mapping x7Kp2Qa from the same Mapping database and sends the visitor on to the long URL. One stored mapping serves every later open.

    What changed

    • Visitor and Redirect service
    • GET /x7Kp2Qa
    • Sent to the long URL
  3. The link contract shapes storage, redirects and abuse controls. Each open question sits on its part: allowed schemes such as https and custom aliases on the Create service, lifetime and edits on the Mapping database, click counting on the Redirect service.

    X’s t.co
    screens, counts clicks
    Bookmark tool
    needs neither

    What changed

    • Link contract questions
    • Shapes storage and redirects
  4. Now suppose, as an example, 30 million links a day. Spread over the 86,400 seconds in a day, that is about 350 writes a second into the Create service, each adding one mapping to the Mapping database.

    What changed

    • 30 million links a day
    • About 350 writes/s
  5. Each link is opened 25 times, so 750 million opens a day make about 8,700 redirects a second. In the traffic shown, one creation passes for every 25 redirects. The system is read-heavy.

    What changed

    • 25 opens per link
    • About 8,700 redirects/s
  6. Traffic isn’t flat across the day. If the busiest hour runs at three times the average, the Redirect service must handle about 26,000 redirects a second. Plan capacity for that peak, not the 8,700 average.

    Average
    8,700/s
    Busiest hour, 3×
    26,000/s

    What changed

    • Busiest hour: 3× average
    • About 26,000 redirects/s
  7. Thirty million links a day for five years makes about 55 billion mappings. At 120 bytes of destination text each, that is about 6.6 TB of raw text, before keys, indexes, metadata, replicas and overhead. These figures are an example, not a measurement.

    Per URL
    120 bytes
    Kept
    5 years

    What changed

    • About 55 billion mappings
    • About 6.6 TB of raw text
    • Overhead comes on top
  8. The same sums can rule complexity out. At 500 links a day, an internal tool’s load, mappings stay under 2 million in ten years and fit one Postgres instance. Sharding and a dedicated key service would only add cost. Switch to 30 million to compare.

    500 a day
    < 2 million, 10 years
    30M a day
    about 55 billion, 5 years
    Links a day

Space plays · ← → step · Home resets

THE IDEA

How it works

A shortener has two core actions: accept a long URL and return a short link, then resolve that link to the original destination. Agree on allowed schemes (the part before the colon, such as https), link lifetime, whether a destination can change, custom aliases, and whether click analytics matters. These choices affect storage, redirects, and abuse controls. X’s t.co, for instance, wraps links so it can screen them and count clicks, which a private bookmark tool does not need.

Suppose the service creates 30 million links each day and each is opened 25 times. Average creation traffic is about 350 writes per second; redirects average about 8,700 reads per second. If the busiest hour runs at three times the average, plan for about 26,000 redirects per second. Five years yields about 55 billion mappings, where a mapping is one stored record pairing a short key with its destination. At 120 bytes of destination text each, that is about 6.6 TB of raw URL text, before identifiers, indexes, metadata, replicas, and overhead. These figures are an example, not a measurement of any real service.

The same arithmetic can talk you out of complexity. An internal company tool creating 500 links a day reaches under two million mappings in ten years, which fits comfortably in one Postgres instance. Sharding (splitting data across databases) and a dedicated key service would only add operational cost there.

DECISION POINT

A team says “make links as short as possible” but also wants five years of retention. What do you clarify first?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Define the link contract before choosing a key algorithm.
  • Keep units, time horizon, peak factor, and storage overhead visible.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
ApplyQUESTION 01

A smaller shortener creates 20 million links a day, and each is opened ten times. About how many redirects per second is that on average?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.