Backend System Design

URL Shortener Non-Functional Requirements

Jem Young
Netflix
Backend System Design

Lesson Description

The "URL Shortener Non-Functional Requirements" Lesson is part of the full, Backend System Design course featured in this preview video. Here's what you'd learn in this lesson:

Jem instructs students to consider non-functional requirements for URL shorteners, covering response time, latency, and URL length. He also discusses setting parameters like maximum URL length and expiration, highlighting impacts on database choices and system efficiency.

Preview

Transcript from the "URL Shortener Non-Functional Requirements" Lesson

[00:00:00]
>> Jem Young: All right, you're all shorter. We did the nonfunctional here and we learned it's a different application entirely. What questions will we ask? Something about performance. What performance do we care about here? How many requests per second? Yeah. We'll say what is the RPS? What is the average RPS? RPS, request per second. We talked about, well, this came up in conversation a little bit, we talked about hashing algorithms, the speed of that is going to matter sometimes, and the lookup, because really what we're doing is there's a short link, we look it up, it leads to something else.

[00:00:55]
Is that something we care about, that response time? Probably because it is a URL that is redirecting. Yeah. Say what is the maximum latency allowed or something like that. Say one more, we talked about this one too, and the functional requirements, but now we get to think about how we implement it. Say what is the maximum length of a URL. And this one's tricky.

[00:01:38]
You could say, is that a functional or nonfunctional? It's probably both, both, yeah, because we care about it. That length affects our database choices and how we think about how to actually do this redirector on the backend. Would the expiration of your route also qualify as like functional or nonfunctional? In the sense that that could determine how we store those URLs.

[00:02:10]
It's kind of both. If they can't expire, then there probably has to be a cleanup process. Otherwise they'll live on forever. When do your URLs expire or do URLs expire? This one's a little trickier because when there's not a clear user in mind, we're just talking about more about the requests and the action. Then the blend of what's functional, what's nonfunctional, is a little murky.

[00:02:43]
But that's okay, because in real life, if you're actually going through these, you're probably asking both questions at the same time, and mentally you're just sorting them out. You know, what's the number one feature this app needs to have, or what are the features? How many users do we expect, you know, we're blending all these together, because again, you're only doing this in 10 to 15 minutes, so you're not going to be like functional, nonfunctional.

[00:03:12]
It's more of a general approach. Okay. We're almost there on the nonfunctional. It's pretty sticky though. It's pretty sticky. Okay. I don't know, we'll make something up. Reader X should happen and no more than 500 milliseconds. We'll be generous. That's a long time for a redirect, but yeah, put our flag in the ground there. Be able to support a million requests per second.

[00:04:07]
System should support. Do we want to set a maximum length on the URL or leave it unlimited? It almost felt functional, because it's just a matter of like, what's the point of a URL shortener if your URL gets long. The browser enforces it. We might have to, I think it's a megabyte. It's getting bigger over the years, but it's slightly more consistent.

[00:04:28]
I like what you said there. Instead of thinking of length, we think of size, because that's really what matters. We don't care about the length, we care about how it's stored. So we'll say URLs can be at most, I don't know, it's a big number, 3 kilobytes. Pretty long URL. But we wouldn't want to leave this open-ended because anybody could submit garbage data, and there is a maximum length depending on the database we're choosing on what can be stored.

[00:05:02]
Object database, not as much a limit, relational database can be a limit. It has to be. And that's how you take down systems really easily if you don't check these sort of things. It's the little things that'll take you down. Is this the length or is this the size of the short URL or the long URL that's mapped to it? Good question. We'll say long URLs.

[00:05:40]
Yeah, we'll say short URLs can be at most, I don't know, 1 kilobyte. Arbitrary. Good question though, yeah. And now it's like, is that a functional or nonfunctional? It's both. 1000 characters. Pretty long. I know 1 kilobyte is pretty generous, but you know, this is the workshop and we're talking about, yeah. But yeah, I like your point, which is like it's not precise.

[00:06:14]
It's, you know, it's a swag. We're making guesstimates here. And yes, maybe 1000 characters too long. Better to underscope it a little bit, and they'll tell you if you're wrong. But if you do it super big, they're going to be like, well, this is the requirement that you wrote. I didn't tell you anything. You said this, so build a system that does this, and you're like, ah, I probably should have cut that down a little bit.

Learn Straight from the Experts Who Shape the Modern Web

  • 250+
    In-depth Courses
  • Industry Leading Experts
  • 24
    Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now