Docsity

A system design from scratch, Schemes and Mind Maps of Design

Toggle sidebar
bg1
Cloud-Based Data Processing
Assignment 2 - A system design from scratch
Handout: 17th November 2020
Due: 24th November 2020 by 6pm
Discussions: 18th and 25th November 2020 in the tutorial
1 Introduction
This exercise aims to teach you how to design a system from scratch. It consists of two parts.
1. Give a simple system design for an url shortening service like TinyURL.
2. Compare your design to a model solution.
Note, you are asked to draw a systems diagram as the last exercise of Part 1. We recommend completing
this diagram bit by bit while you complete the other exercises.
Furthermore, we recommend arguing your design in terms of the requirements identified in the first two
questions. If you notice that you are missing some requirements as important constraints for a later
decision, add them and shortly consider if that changes your design up to that point.
Finally, we recommend not to read the model solution before completing Part 1.
Part 1: Design an URL shortening service
The task is to propose a high-level system design for an url shortening service. Examples for these
services can be found online, e.g. TinyURL, bit.ly, goo.gl or qlink.me. If you have never used one of
these, we recommend taking a moment to try one.
URL shortening services create smaller aliases for urls, e.g. https://de.wikipedia.org/wiki/Cloud_
Computing to https://bit.ly/35p91vt. This saves a lot of space when the URL is displayed, printed,
messaged or tweeted.
1.1 List the main functional requirements.
Hint: start with around 4 and prioritize them.
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download A system design from scratch and more Schemes and Mind Maps Design in PDF only on Docsity!

Cloud-Based Data Processing

Assignment 2 - A system design from scratch

Handout: 17 th^ November 2020 Due: 24 th^ November 2020 by 6pm Discussions: 18 th^ and 25th^ November 2020 in the tutorial

1 Introduction

This exercise aims to teach you how to design a system from scratch. It consists of two parts.

  1. Give a simple system design for an url shortening service like TinyURL.
  2. Compare your design to a model solution.

Note, you are asked to draw a systems diagram as the last exercise of Part 1. We recommend completing this diagram bit by bit while you complete the other exercises.

Furthermore, we recommend arguing your design in terms of the requirements identified in the first two questions. If you notice that you are missing some requirements as important constraints for a later decision, add them and shortly consider if that changes your design up to that point.

Finally, we recommend not to read the model solution before completing Part 1.

Part 1: Design an URL shortening service

The task is to propose a high-level system design for an url shortening service. Examples for these services can be found online, e.g. TinyURL, bit.ly, goo.gl or qlink.me. If you have never used one of these, we recommend taking a moment to try one.

URL shortening services create smaller aliases for urls, e.g. https://de.wikipedia.org/wiki/Cloud_ Computing to https://bit.ly/35p91vt. This saves a lot of space when the URL is displayed, printed, messaged or tweeted.

1.1 List the main functional requirements.

Hint: start with around 4 and prioritize them.

1.2 List the main non-functional requirements.

Hint: start with around 4 and prioritize them.

1.3 Capacity estimations

Assume that the service has a read to write ratio of 100:1, and an estimated load of 500 million newly registered URLs per month, which expire after 5 years. Please give a formula and a final estimate for the following operations and report the estimate in full hundreds or thousands:

  1. Estimate the expected load in number of queries per second. Differentiate between read and write queries.
  2. If we assume 500 bytes per record, how much storage do we need? How much bandwidth should the whole system support?
  3. Assume that our workload follows the 80-20 rule. That means that 20% of the stored aliases make up for 80% of our traffic, or in other words, 80% of all incoming redirection requests ask for only 20% of all aliases stored. These 20% are called the hot records. How much memory is needed to cache the hot records?

1.6 Deleting keys on expiration

As stated in the Capacity estimation exercise (Section 1.3), we expire aliases after 5 years. Describe a system component that can do this. Hint: you might notice that incorporating this into your design from the beginning could influence it a lot.

  1. How many aliases does this component need to delete per day?
  2. How will this component find the keys to delete?
  3. Give a high-level description on how you would build this component.

1.7 Give a partitioning for your database scheme.

Generally, there are two kinds of partitioning used in practice: range partitioning and hash partitioning. Which one is more suitable?

1.8 (Optional) How to generate aliases?

The generated aliases should be as short as possible. The aliases should be human-readable and look like a normal url. Therefore, you should use Base64 encoding. This encoding uses 64 different characters: [A-Z, a-z, 0-9, +, /] and each character is encoded using 6 bits. Some background reading: https: //en.wikipedia.org/wiki/Birthday_attack

  1. How short can you make your aliases? Do all aliases need to have the same length?
  2. Give an algorithm or describe a component which allows generating aliases at a high enough rate.

1.9 (Optional) Caching

Previously, we made the assumption that the 80-20 rule applies to our workload and hinted that it could be used for caching.

  1. Which cache eviction policy would you use?
  2. How would you update the cache? When are new entries added to the cache?

Do not read past here, before completing Part 1.

Part 2: Comparision with a model solution

You should read this part after finishing Part 1.

We are not the first to ask others to design a url shortening service. A well-written model solu- tion can be found at https://www.educative.io/courses/grokking-the-system-design-interview/ m2ygV4E81AR. This is a system design exercise, there is no single correct answer. So do not worry if you came up with a different design. Please read the model solution and write a brief comparison to your design. All components of the model solution are shown in Figure 1. We did not discuss load-balancers, so it is normal that your design does not cover them.

Figure 1: Detailed component design for URL shortening