Design Google Drive/Dropbox

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/10

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:30 PM on 10/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

11 Terms

1
New cards

Functional Requirements

  • Add Files

  • Download files

  • Sync files across multiple devices

  • See file revisions

  • Share files with friends and family

  • Send notification when file is edited, deleted, or shared with you

2
New cards

Non-functional

Available

Scalable

Secure

ACID-ity

Reliable

3
New cards

BOE

50 million signed up, 10 million DAU. Users get 10 GB

Assume users upload 2 files/day, average file size is 500KB

1:1 read write ratio

Total space is 50 million * 10 GB = 500 PB

QPS for upload API: 10 million * 2 / 10^5 is exactly 240 when not rounding secs in day

4
New cards

High Level Design

Block servers
Cloud Storage
Cold Storage
Notification Service

MetaData DB
Offline Backup Queue


<p>Block servers<br>Cloud Storage<br>Cold Storage<br>Notification Service</p><p>MetaData DB<br>Offline Backup Queue</p><p></p>
5
New cards

Block Server

Files split into smaller blocks, each with unique hash value. Store metadata in our metadata db. Blocks stored in S3. Joined to create file. If updated, just do delta of old block. compression for space optimization.

6
New cards

Consistency Requirements

HIGH consistency. Memory cache adopts eventual consistency model. To enforce this strong consistency, INVALIDATE CACHE ON WRITE. Diagram in upload flow

must use relational DB for ACID-ity. Must be ACID for strong consistency.

To prevent sync conflicts, use versioning. Can do timestamp or version number- do version number. Time can be messed up depending on server. Version number uses first to get that version number if conflict occurs.

<p>HIGH consistency. Memory cache adopts eventual consistency model. To enforce this strong consistency, INVALIDATE CACHE ON WRITE. Diagram in upload flow</p><p><strong>must use relational DB for ACID-ity. Must be ACID for strong consistency. </strong></p><p>To prevent sync conflicts, use versioning. Can do timestamp or version number- do version number. Time can be messed up depending on server. Version number uses first to get that version number if conflict occurs.</p>
7
New cards

Uploading flow

User A wants to upload file

  1. send request to add metadata of new file. Stores in metadata DB, then notification service notifies relevant clients

  2. client A uploads file to block servers. Block servers take chunk, compress and encrypt, then upload to cloud. Cloud storage triggers completion callback

  3. File status changed in metadata db. notify the notification service to tell relevant clients.


<p>User A wants to upload file</p><ol><li><p>send request to add metadata of new file. Stores in metadata DB, then notification service notifies relevant clients</p></li><li><p>client A uploads file to block servers. Block servers take chunk, compress and encrypt, then upload to cloud. Cloud storage triggers completion callback</p></li><li><p>File status changed in metadata db. notify the notification service to tell relevant clients. </p><p></p></li></ol>
8
New cards

Download Flow

If client 2 online when file is changed by another user, notification service will inform client that they need to pull data. Otherwise, data will be saved to the cache and when client is online again, they will pull.


<p>If client 2 online when file is changed by another user, notification service will inform client that they need to pull data. Otherwise, data will be saved to the cache and when client is online again, they will pull.</p><p></p>
9
New cards

Notification Service design

Websocket vs long polling. Use long polling, not bi-directional. Websocket better for chat apps. (or uber!) Dropbox uses long polling. When user closes long poll to download data, it reestablishes connection.


10
New cards

Storage space vs versioning (storage space optimizing)

to save space:

  1. only keep certain number of versions

  2. if old versions never used, delete?

  3. move infrequently accessed to cold storage.

  4. de duplicate if same hash.

11
New cards

Random Extras

  • Duplicate block servers in case one fails

  • duplicate S3 buckets in different regions

  • notification service failure- reconnecting all clients from disconnected server. May be very slow, but necessary. Need to have backups

  • Load balancers keep heartbeats. If primary fails, secondary takes traffic

  • Offline backup queues are replicated multiple times. If one fails, user may need to re-subscribe to backup queue