SYSTEM DESIGN - EX2

1. Mint.com

1.1. Requirement & scope

// Use cases
User: connects to a financial account
Service: extracts transactions from the account
Service: recommends a budget
Service: high availability

// Out of scope
Service performs additional logging and analytics
// Assumptions
Not even traffic
Update for active accounts (30 days)
Asynchronous budget notifications

10M users
30M financial accounts
100M budget items = 10 budget categories per user
50K sellers (determine transaction category)
5b transactions / month
500M read / month
10:1 write to read ratio (write-heavy)

1.2. Calculation

8B user_id

5B created_at

32B seller

5B amount

Total size = ~50B

1.3. Design

1.4. Core

1.4.1. Use case: User connects to a financial account

1.4.2. Use case: Service extracts transactions from the account

Category service

seller-to-category dictionary = 50,000 sellers (each < 255 bytes) = 12MB

1.4.3. Use case: Service recommends a budget

1.5. Scale

1.5.1 Recent transactions in Cache

2. Data structures for social network

2.1. Requirement & scope

2.2. Calculation

2.3. Design

2.4. Core

2.4.1 User searches for someone & the shortest path.

BFS: solve unweighted shortest path

shard users @ user DB

2.5. Scale

400 read / second = [1] person data @ Cache [2] relation @ Cache [3] BFS in Cache

A search limit => asking the user if they want to continue => search or stop

Graph DB: Neo4j or GraphQL language

3. key-value cache to save the results of the most recent web server queries

3.1. Requirement & scope

3.2. Calculation

Key

Value

50B query

20B title

200B snippet

Total size = ~270B

3.3. Design

3.4. Core

3.4.1 User request -> cache hit

reduce read latency & avoid overloading DB

least recently used (LRU) to expire older entries.

When to update the cache (1) contents change (2) added / removed page (3) rank changes => TTL

3.5. Scale

Last updated

Was this helpful?