Skip to content

Commit

Permalink
🎉auto update by Gmeek action
Browse files Browse the repository at this point in the history
  • Loading branch information
LeadTechInterview committed Jan 16, 2025
1 parent fabe4a5 commit f7b1106
Show file tree
Hide file tree
Showing 8 changed files with 608 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lead Tech Interview :link: https://leadtechinterview.github.io
### :page_facing_up: [16](https://leadtechinterview.github.io/tag.html)
### :page_facing_up: [17](https://leadtechinterview.github.io/tag.html)
### :speech_balloon: 0
### :hibiscus: 70422
### :alarm_clock: 2025-01-16 04:39:39
### :hibiscus: 73305
### :alarm_clock: 2025-01-16 09:02:37
### Powered by :heart: [Gmeek](https://github.com/Meekdai/Gmeek)
81 changes: 81 additions & 0 deletions backup/System Design Strava.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Requirements (5 mins):

## Functional Requirements

> Identify core features (e.g., "Users should be able to post tweets"). Prioritize 2-3 key features.
1. users can start/stop/pause their activity (runs/rides)
2. users should be able to check the activity data (route, distance, time etc) when running /riding
3. users should be able to check history records, including friends

## Non-Functional Requirements

> Focus on system qualities like scalability, latency, and availability, consistency, security, durability, fault tolerance. Quantify where possible (e.g., "render feeds in under 200ms").
1. the system should be highly available
2. the app should work offline when no Internet
3. the stats should be accurate
4. should support 10m concurrent users

## Capacity Estimation

> Skip unnecessary calculations unless they directly impact the design (e.g., sharding in a TopK system).
route GPS data estimation: 100m DAU, 10m concurrent users, collect interval 5 secs, 30 min activity per day will generate 30 x 60 / 5 = 360 records, so around 36,000m records per day, each record we have around 40 Byte.

Storage: 36,000m x 40 = 1440GB per day. 1500G x 360 = 180000x3G = 540000 GB = 540 TB

QPS 3600m / 100k = 36k

## Core Entities (2 mins)

> Identify key entities (e.g., User, Tweet, Follow) to define the system's foundation.
- user
- activity
- route
- friend

# API/System Interface (5 mins)

> Define the contract between the system and users. Prefer RESTful APIs unless GraphQL is necessary.
- POST /activity -> Activity, create an activity, body {type}
- PATCH /activity/id, change status, body { status}, start, stop, pause, complete
- POST /activity/id/route, update route geo tracking { geolocation}
- GET /activities/page?mode=user|friend&page=

# [Optional] Data Flow (5 mins)

> Describe high-level processes for data-heavy systems (e.g., web crawlers).
# High-Level Design (10-15 mins)

> Draw the system architecture, focusing on core components (e.g., servers, databases). Keep it simple and iterate based on API endpoints.
![image](https://github.com/user-attachments/assets/68ced8bb-4916-49f8-a3cd-8d56576a1688)


# Deep Dives (10 mins)

> Address non-functional requirements, edge cases, and bottlenecks. Proactively improve the design (e.g., scaling, caching, database sharding).
## No internet connection

We can save data in local db and sync to server later

## Support 100 DAU, 10m concurrent users

storage: 540TB/year

- purge old storage of route date
- shard data by time
- use cold storage to save cost
- compress the date

QPS: 40k

- use nosql database, time series database more specific
- clients aggregate the data and use longer intervals if not in realtime view
- shard the data by user id, activity id to distribute the load across servers

2 changes: 1 addition & 1 deletion blogBase.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ <h1>
<div id="content">
<div style="margin-bottom: 16px;">Preparing for the Big Leap</div>
<nav class="SideNav border">
<a class="SideNav-item d-flex flex-items-center flex-justify-between" href="post/Coding%20question-%20Happy%20Number.html">
<a class="SideNav-item d-flex flex-items-center flex-justify-between" href="post/System%20Design%20Strava.html">
<div class="d-flex flex-items-center">
<svg class="SideNav-icon octicon" style="witdh:16px;height:16px"><path class="svgTop0" d=""></path>
</svg>
<span class="listTitle">System Design Strava</span>
</div>
<div class="listLabels">

<span class="Label LabelName" style="background-color:#54E34A"><object><a style="color:#fff" href="tag.html#system design">system design</a></object></span>
<span class="Label LabelTime" style="background-color:#0969da">2025-01-16</span>
</div>
</a><a class="SideNav-item d-flex flex-items-center flex-justify-between" href="post/Coding%20question-%20Happy%20Number.html">
<div class="d-flex flex-items-center">
<svg class="SideNav-icon octicon" style="witdh:16px;height:16px"><path class="svgTop0" d=""></path>
</svg>
Expand Down Expand Up @@ -234,17 +245,6 @@ <h1>
<span class="Label LabelName" style="background-color:#54E34A"><object><a style="color:#fff" href="tag.html#system design">system design</a></object></span>
<span class="Label LabelTime" style="background-color:#0969da">2025-01-10</span>
</div>
</a><a class="SideNav-item d-flex flex-items-center flex-justify-between" href="post/Creating%20Back%20of%20Envelope%20Quizzes%20for%20Tech%20Interviews%20using%20AI.html">
<div class="d-flex flex-items-center">
<svg class="SideNav-icon octicon" style="witdh:16px;height:16px"><path class="svgTop0" d=""></path>
</svg>
<span class="listTitle">Creating Back of Envelope Quizzes for Tech Interviews using AI</span>
</div>
<div class="listLabels">

<span class="Label LabelName" style="background-color:#54E34A"><object><a style="color:#fff" href="tag.html#system design">system design</a></object></span>
<span class="Label LabelTime" style="background-color:#0969da">2025-01-10</span>
</div>
</a>
</nav><nav class="paginate-container" aria-label="Pagination">
<div class="pagination"><span class="previous_page" aria-disabled="true">上一页</span>
Expand Down
13 changes: 12 additions & 1 deletion docs/page2.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ <h1>
<div id="content">
<div style="margin-bottom: 16px;">Preparing for the Big Leap</div>
<nav class="SideNav border">
<a class="SideNav-item d-flex flex-items-center flex-justify-between" href="post/Simplified%20Back-of-the-Envelope%20Calculation%20Cheat%20Sheet.html">
<a class="SideNav-item d-flex flex-items-center flex-justify-between" href="post/Creating%20Back%20of%20Envelope%20Quizzes%20for%20Tech%20Interviews%20using%20AI.html">
<div class="d-flex flex-items-center">
<svg class="SideNav-icon octicon" style="witdh:16px;height:16px"><path class="svgTop0" d=""></path>
</svg>
<span class="listTitle">Creating Back of Envelope Quizzes for Tech Interviews using AI</span>
</div>
<div class="listLabels">

<span class="Label LabelName" style="background-color:#54E34A"><object><a style="color:#fff" href="tag.html#system design">system design</a></object></span>
<span class="Label LabelTime" style="background-color:#0969da">2025-01-10</span>
</div>
</a><a class="SideNav-item d-flex flex-items-center flex-justify-between" href="post/Simplified%20Back-of-the-Envelope%20Calculation%20Cheat%20Sheet.html">
<div class="d-flex flex-items-center">
<svg class="SideNav-icon octicon" style="witdh:16px;height:16px"><path class="svgTop0" d=""></path>
</svg>
Expand Down
Loading

0 comments on commit f7b1106

Please sign in to comment.