Bugpit

Lessons › Design skills

Ask before you build

An interviewer says: design a link shortener. You ask, and learn it gets 5,000 req/s, and people open links about 99 times for every link they create.

Play this level

Part of Bugpit Pro. It runs in your browser: build the design, press Run, and watch what breaks.

The lesson

The worst way to start is by drawing boxes. "Design X" is vague on purpose, and the first job is to find out what X has to do.

Functional requirements say what the system does: make a short link, and send people to the long one. Non functional requirements say how well: how fast, how many people, how reliable.

The answers decide the design. Almost every request here is a read, and the same popular links are opened again and again, so a cache will do far more than a bigger database.

What you have to achieve

5,000 requests a second at the busiest hour, 1% of them writes.

What you learn

You let the requirements choose the design. Two questions told you this is a read heavy system, and that made the cache the obvious first move.

Check yourself

The interviewer has just said "design a link shortener". What do you do first?

Show the answer

Ask what it must do and how much traffic it gets. Requirements come first. Without them you can't know whether a design is too small, or far too big.

Which of these is a non functional requirement?

Show the answer

99% of redirects finish within 100 ms. Functional means what the system does. Non functional means how well it does it, like speed and reliability.

People open links 99 times for every link made. What does that tell you?

Show the answer

Design for reads first. A read heavy system gets the most from caches and replicas, so that's where to spend effort.

Try it yourself

More in Design skills

← Go worldwide Do the maths first →