Skip to content

[Imported] Latency numbers: remove conversion to throughput #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 102 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
c3f080f
Update Japanese translation link (#118)
donnemartin Dec 3, 2017
a4973a0
ja: Fix typo (#119)
koudaiii Dec 8, 2017
748944c
Make some minor wording/formatting changes (#120)
donnemartin Jan 6, 2018
dd124c4
add Twitter Handles 3,000 Images Per Second
fluency03 Jan 6, 2018
11b9d72
Add Netflix in Company Architectures (#122)
fluency03 Jan 21, 2018
8702199
Add Vietnamese translation link (#128)
donnemartin Jan 24, 2018
156a67e
Add Scaling Uber in Company Architecture (#123)
fluency03 Feb 2, 2018
ebcec73
Update master-slave section anchor (#129)
Feb 8, 2018
0263906
Add Facebook Live Streams (#125)
fluency03 Feb 16, 2018
12946d3
Update contributing guidelines - PR squash (#135)
donnemartin Feb 23, 2018
61bc6f7
Update re:Invent url (#137)
hakaari Feb 27, 2018
e86ed77
Merge branch 'master' into add-twitter
fluency03 Feb 27, 2018
9712a12
Add Traditional Chinese translation (#133)
kevingo Feb 28, 2018
82868d3
zh-TW: Add proper line break to links (#139)
kevingo Mar 4, 2018
7272a9b
Add Greek translation link (#140)
donnemartin Mar 6, 2018
de3c13c
Convert all .py files to be valid Python (#98)
Mar 7, 2018
94c158e
zh-Hans: Fix typos (#141)
robertding Mar 8, 2018
7c38532
Add Spanish translation link (#142)
donnemartin Mar 8, 2018
3079562
Add missing colons to class methods (#143)
Mar 18, 2018
d90b562
Add missing self variables to Deck of Cards solution (#145)
Mar 18, 2018
7e316ce
Add deque import to Social Graph solution (#147)
Mar 24, 2018
f552598
Change LARGE to VehicleSize.LARGE in parking lot solution (#146)
Apr 9, 2018
f038dbb
zh-TW: Fix comment format (#155)
htkuan Apr 11, 2018
d7d0e9d
Fix coding errors (#149)
Apr 26, 2018
f05373a
Fix dict KeyError (#152)
hulikau Apr 26, 2018
7a4dbb1
Fix dict KeyError (#153)
hulikau Apr 26, 2018
4a0d7fb
Adding missing self variable (#158)
May 7, 2018
02a20c6
Add missing enum imports (#157)
May 7, 2018
2368ee0
Change variable seller to category in Mint solution (#159)
May 23, 2018
38cb1be
zh-Hans: Fix typo (#161)
b7wch Jun 16, 2018
6ed6521
Replace broken SQL tuning links (#163)
Jun 29, 2018
ded61ab
zh-Hans: Fix PostgreSQL typo (#166)
breakliu Jul 13, 2018
7b20f5c
Fix #148: Add State(Enum) to social_graph_snippets.py (#167)
Jul 15, 2018
8a9cca7
ja: Swap VARCHAR and CHAR translation error (#169)
Jul 15, 2018
4cc5ff4
Add Arabic translation link (#177)
donnemartin Jul 18, 2018
65685dc
Add newlines - PEP8 style (#173)
Jul 19, 2018
6b18bd8
zh-TW: Improve translations (#176)
d12e493 Jul 20, 2018
46eead5
Fix typo in LRU cache solution (#182)
veloxy Jul 23, 2018
be5b372
Fix broken links (#180)
zboigor Jul 25, 2018
21a088d
Add German translation link (#188)
donnemartin Jul 30, 2018
c6ce4e0
Add Thai translation link (#190)
donnemartin Aug 1, 2018
8da1030
Fix broken URL (#194)
RGirish Aug 5, 2018
99aaf14
Fix error in Twitter timeline solution (#196)
Aug 7, 2018
64e1379
Fix wording in call center solution (#197)
HasanAliKaraca Aug 9, 2018
2107618
Resolve #195: Fix broken GitHub URLs (#199)
narenchoudhary Aug 13, 2018
c20f0e4
zh-Hans: Fix typo: 'Twitter' (#200)
meteor199 Aug 14, 2018
0d9a863
Update Twitter/Facebook exercise description (#202)
fabriziocucci Aug 20, 2018
bddaa27
Fix typo in CAP theorem section (#205)
Aug 24, 2018
a57d6a1
Fix broken links (#204)
karoliina Aug 29, 2018
13c6a5b
Fix #126: Update link to Anki decks (#206)
dvanbrug Sep 2, 2018
29ad5b2
Fix typo in Design Pastebin.com exercise (#210)
fabriziocucci Sep 8, 2018
97d8aee
zh-Hans: Fix translation (#208)
uknownothingsnow Sep 14, 2018
78262c0
zh-Hans: Update translation (#212)
xulunfan Sep 15, 2018
adf0b44
zh-Hans: Update translation (#209)
dajiao007 Sep 16, 2018
25d7744
Update Cassandra architecture links (#213)
brunoffsp Sep 19, 2018
2da470f
Update README intro (#216)
donnemartin Sep 24, 2018
ac44939
Resolve #214: Add reference links to message queues section (#218)
IAmPramod Oct 1, 2018
c8e819c
Update Scalability for Dummies link (#224)
Xom Oct 11, 2018
4d50e1e
ja: Fix typo (#226)
masaodev Oct 26, 2018
38f1986
zh-TW: Update index anchors (#227)
reiscigit Oct 31, 2018
c210cfb
Add Link: A 360 Degree View Of The Entire Netflix Stack (#229)
fluency03 Nov 14, 2018
470cb75
Fix #228: Address mutex latency discrepancy (#233)
saurav-2104 Dec 19, 2018
3468768
Add Bengali translation link (#242)
donnemartin Dec 28, 2018
7095562
Add missing word in cache write through discussion (#245)
whoan Jan 5, 2019
05cca98
zh-Hans: Fix typo (#246)
ZJUGuoShuai Jan 20, 2019
b2d08cd
Fix grammar in document store section (#247)
Feb 3, 2019
3d2f11f
Fix typo in Twitter timeline and search solution (#251)
Feb 11, 2019
fc121f9
Update document-store to document store (#255)
t0t07 Feb 28, 2019
25c448f
Enable Python syntax highlighting in Pastebin sample code (#257)
manaskarekar Mar 4, 2019
70f714d
Fix broken SQL link in Scaling AWS exercise (#258)
CodeMySky Mar 18, 2019
5801dee
Add article link: How Twitter Handles 3,000 Images/sec (#124)
donnemartin Apr 10, 2019
df045a4
Update HDFS design link to the latest version (#275)
leontyr May 7, 2019
255dcf8
Enable syntax highlighting in all python code snippets (#268)
manaskarekar May 7, 2019
fc8568a
Translate language list (#252)
spuyet May 11, 2019
3c2b831
Add Ebook generation script (#207)
Skn0tt May 12, 2019
d2384bd
Add availability in numbers section (#237)
mebjas May 12, 2019
9058471
Update language lists in translations (#280)
donnemartin May 14, 2019
f5c39e0
Add Hebrew translation link (#286)
donnemartin May 31, 2019
6a5d2fe
zh-Hans: Translate Pastebin solution (#273)
kevinxuv Jun 16, 2019
014a4a0
ja: Fix typo of Big-O notation in KVS section (#292)
Wintus Jul 6, 2019
9ffe72e
JA: Fix mistranslation in Horizontal scaling section
satob Jul 8, 2019
71f1693
JA: Fix mistranslation in Reverse proxy (web server) section
satob Jul 10, 2019
4956d22
ja: Fix mistranslation in "Horizontal scaling"
satob Jul 26, 2019
06eeeb7
JA: Fix mistranslation in Weak consistency section (#299)
satob Aug 3, 2019
218a23d
JA: Fix mistranslation in Push CDNs section (#300)
satob Aug 3, 2019
87912ed
ja: Fix translation in horizontal scaling section (#301)
donnemartin Aug 3, 2019
316c00c
Merge pull request #302 from satob/ReverseProxy
donnemartin Aug 3, 2019
46634d1
JA: Fix mistranslation in Federation section (#303)
satob Aug 5, 2019
779b466
ja: Fix translation in "Anki flashcards" (#306)
satob Aug 13, 2019
b44a018
ja: Fix translation in “Disadvantage(s): load balancer” (#307)
satob Aug 13, 2019
8bfc344
ja: Fix translation in Service Discovery section (#308)
satob Aug 13, 2019
1972808
Add API security checklist (#328)
duynguyenhoang Nov 3, 2019
ce29593
zh-Hans: Change translation in SQL tuning (#318)
brandonJY Dec 9, 2019
7f56907
ja: Fix mistranslation in SQL tuning section (#305)
satob Dec 9, 2019
24707af
Change raise NotImplemented to raise NotImplementedError (#345)
cclauss Dec 27, 2019
ba69584
Fix broken round robin links (#351)
ygdanchoi Jan 15, 2020
105fa53
Fix broken CAP theorem link (#355)
Jan 21, 2020
e69177f
zh-cn: Sync with upstream to keep it up-to-date (#374)
linhe0x0 Mar 10, 2020
1886ed9
Revert "zh-cn: Sync with upstream to keep it up-to-date (#374)" (#391)
donnemartin Mar 10, 2020
752f6aa
zh-Hans: Translate solutions (#392)
linhe0x0 Mar 30, 2020
53ebbd1
Update "Scaling up to your first 10 million users" link (#411)
userstartupideas May 26, 2020
1f3cd62
Latency numbers: remove conversion to throughput
psanan Jun 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Byte-compiled / optimized / DLL files
*.epub
__pycache__/
*.py[cod]

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Translations to new languages are always welcome, especially if you can maintain
* Invite friends to review if possible. If desired, feel free to invite friends to help your original translation by letting them fork your repo, then merging their PRs.
* Add links to your translation at the top of every README*.md file. (For consistency, the link should be added in alphabetical order by ISO code, and the anchor text should be in the native language.)
* When done, indicate on the PR that it's ready to be merged into the main repo.
* Once accepted, your PR will be squashed into a single commit into the `master` branch.

### Translation template credits

Expand Down
154 changes: 77 additions & 77 deletions README-ja.md

Large diffs are not rendered by default.

135 changes: 65 additions & 70 deletions README-zh-Hans.md

Large diffs are not rendered by default.

1,786 changes: 1,786 additions & 0 deletions README-zh-TW.md

Large diffs are not rendered by default.

228 changes: 135 additions & 93 deletions README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions epub-metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
title: System Design Primer
creator: Donne Martin
date: 2018
40 changes: 40 additions & 0 deletions generate-epub.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#! /usr/bin/env sh

generate_from_stdin() {
outfile=$1
language=$2

echo "Generating '$language' ..."

pandoc --metadata-file=epub-metadata.yaml --metadata=lang:$2 --from=markdown -o $1 <&0

echo "Done! You can find the '$language' book at ./$outfile"
}

generate_with_solutions () {
tmpfile=$(mktemp /tmp/sytem-design-primer-epub-generator.XXX)

cat ./README.md >> $tmpfile

for dir in ./solutions/system_design/*; do
case $dir in *template*) continue;; esac
case $dir in *__init__.py*) continue;; esac
: [[ -d "$dir" ]] && ( cd "$dir" && cat ./README.md >> $tmpfile && echo "" >> $tmpfile )
done

cat $tmpfile | generate_from_stdin 'README.epub' 'en'

rm "$tmpfile"
}

generate () {
name=$1
language=$2

cat $name.md | generate_from_stdin $name.epub $language
}

generate_with_solutions
generate README-ja ja
generate README-zh-Hans zh-Hans
generate README-zh-TW zh-TW
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer-primer)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)."
]
},
{
Expand All @@ -24,9 +24,9 @@
" * Operator, supervisor, director\n",
"* Can we assume operators always get the initial calls?\n",
" * Yes\n",
"* If there is no free operators or the operator can't handle the call, does the call go to the supervisors?\n",
"* If there is no available operators or the operator can't handle the call, does the call go to the supervisors?\n",
" * Yes\n",
"* If there is no free supervisors or the supervisor can't handle the call, does the call go to the directors?\n",
"* If there is no available supervisors or the supervisor can't handle the call, does the call go to the directors?\n",
" * Yes\n",
"* Can we assume the directors can handle all calls?\n",
" * Yes\n",
Expand Down
13 changes: 9 additions & 4 deletions solutions/object_oriented_design/call_center/call_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, employee_id, name):
super(Operator, self).__init__(employee_id, name, Rank.DIRECTOR)

def escalate_call(self):
raise NotImplemented('Directors must be able to handle any call')
raise NotImplementedError('Directors must be able to handle any call')


class CallState(Enum):
Expand Down Expand Up @@ -112,6 +112,11 @@ def _dispatch_call(self, call, employees):
return employee
return None

def notify_call_escalated(self, call): # ...
def notify_call_completed(self, call): # ...
def dispatch_queued_call_to_newly_freed_employee(self, call, employee): # ...
def notify_call_escalated(self, call):
pass

def notify_call_completed(self, call):
pass

def dispatch_queued_call_to_newly_freed_employee(self, call, employee):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer-primer)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)."
]
},
{
Expand Down
11 changes: 6 additions & 5 deletions solutions/object_oriented_design/deck_of_cards/deck_of_cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def add_card(self, card):

def score(self):
total_value = 0
for card in card:
for card in self.cards:
total_value += card.value
return total_value

Expand All @@ -92,7 +92,7 @@ def score(self):

def possible_scores(self):
"""Return a list of possible scores, taking Aces into account."""
# ...
pass


class Deck(object):
Expand All @@ -102,9 +102,9 @@ def __init__(self, cards):
self.deal_index = 0

def remaining_cards(self):
return len(self.cards) - deal_index
return len(self.cards) - self.deal_index

def deal_card():
def deal_card(self):
try:
card = self.cards[self.deal_index]
card.is_available = False
Expand All @@ -113,4 +113,5 @@ def deal_card():
return None
return card

def shuffle(self): # ...
def shuffle(self):
pass
2 changes: 1 addition & 1 deletion solutions/object_oriented_design/hash_table/hash_map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer-primer)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion solutions/object_oriented_design/hash_table/hash_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ def remove(self, key):
if item.key == key:
del self.table[hash_index][index]
return
raise KeyError('Key not found')
raise KeyError('Key not found')
8 changes: 4 additions & 4 deletions solutions/object_oriented_design/lru_cache/lru_cache.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer-primer)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)."
]
},
{
Expand All @@ -21,7 +21,7 @@
"## Constraints and assumptions\n",
"\n",
"* What are we caching?\n",
" * We are cahing the results of web queries\n",
" * We are caching the results of web queries\n",
"* Can we assume inputs are valid or do we have to validate them?\n",
" * Assume they're valid\n",
"* Can we assume this fits memory?\n",
Expand Down Expand Up @@ -84,7 +84,7 @@
" \n",
" Accessing a node updates its position to the front of the LRU list.\n",
" \"\"\"\n",
" node = self.lookup[query]\n",
" node = self.lookup.get(query)\n",
" if node is None:\n",
" return None\n",
" self.linked_list.move_to_front(node)\n",
Expand All @@ -97,7 +97,7 @@
" If the entry is new and the cache is at capacity, removes the oldest entry\n",
" before the new entry is added.\n",
" \"\"\"\n",
" node = self.lookup[query]\n",
" node = self.lookup.get(query)\n",
" if node is not None:\n",
" # Key exists in cache, update the value\n",
" node.results = results\n",
Expand Down
23 changes: 14 additions & 9 deletions solutions/object_oriented_design/lru_cache/lru_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ def __init__(self):
self.head = None
self.tail = None

def move_to_front(self, node): # ...
def append_to_front(self, node): # ...
def remove_from_tail(self): # ...
def move_to_front(self, node):
pass

def append_to_front(self, node):
pass

def remove_from_tail(self):
pass


class Cache(object):
Expand All @@ -24,25 +29,25 @@ def __init__(self, MAX_SIZE):
self.lookup = {} # key: query, value: node
self.linked_list = LinkedList()

def get(self, query)
def get(self, query):
"""Get the stored query result from the cache.

Accessing a node updates its position to the front of the LRU list.
"""
node = self.lookup[query]
node = self.lookup.get(query)
if node is None:
return None
self.linked_list.move_to_front(node)
return node.results

def set(self, results, query):
"""Set the result for the given query key in the cache.

When updating an entry, updates its position to the front of the LRU list.
If the entry is new and the cache is at capacity, removes the oldest entry
before the new entry is added.
"""
node = self.lookup[query]
node = self.lookup.get(query)
if node is not None:
# Key exists in cache, update the value
node.results = results
Expand All @@ -58,4 +63,4 @@ def set(self, results, query):
# Add the new key and value
new_node = Node(results)
self.linked_list.append_to_front(new_node)
self.lookup[query] = new_node
self.lookup[query] = new_node
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer-primer)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)."
]
},
{
Expand Down
52 changes: 38 additions & 14 deletions solutions/object_oriented_design/online_chat/online_chat.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
from abc import ABCMeta
from enum import Enum


class UserService(object):

def __init__(self):
self.users_by_id = {} # key: user id, value: User

def add_user(self, user_id, name, pass_hash): # ...
def remove_user(self, user_id): # ...
def add_friend_request(self, from_user_id, to_user_id): # ...
def approve_friend_request(self, from_user_id, to_user_id): # ...
def reject_friend_request(self, from_user_id, to_user_id): # ...
def add_user(self, user_id, name, pass_hash):
pass

def remove_user(self, user_id):
pass

def add_friend_request(self, from_user_id, to_user_id):
pass

def approve_friend_request(self, from_user_id, to_user_id):
pass

def reject_friend_request(self, from_user_id, to_user_id):
pass


class User(object):
Expand All @@ -25,12 +35,23 @@ def __init__(self, user_id, name, pass_hash):
self.received_friend_requests_by_friend_id = {} # key: friend id, value: AddRequest
self.sent_friend_requests_by_friend_id = {} # key: friend id, value: AddRequest

def message_user(self, friend_id, message): # ...
def message_group(self, group_id, message): # ...
def send_friend_request(self, friend_id): # ...
def receive_friend_request(self, friend_id): # ...
def approve_friend_request(self, friend_id): # ...
def reject_friend_request(self, friend_id): # ...
def message_user(self, friend_id, message):
pass

def message_group(self, group_id, message):
pass

def send_friend_request(self, friend_id):
pass

def receive_friend_request(self, friend_id):
pass

def approve_friend_request(self, friend_id):
pass

def reject_friend_request(self, friend_id):
pass


class Chat(metaclass=ABCMeta):
Expand All @@ -51,8 +72,11 @@ def __init__(self, first_user, second_user):

class GroupChat(Chat):

def add_user(self, user): # ...
def remove_user(self, user): # ...
def add_user(self, user):
pass

def remove_user(self, user):
pass


class Message(object):
Expand All @@ -77,4 +101,4 @@ class RequestStatus(Enum):
UNREAD = 0
READ = 1
ACCEPTED = 2
REJECTED = 3
REJECTED = 3
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer-primer)."
"This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)."
]
},
{
Expand Down
Loading