As this ebook edition doesn't have fixed pagination, the page numbers below are hyperlinked for reference only, based on the printed edition of this book.
Symbols
.META. server 103
A
access control service 263
authentication flow 279 , 280
authorization flow 280 , 281
caching and performance 284
database design 283
designing 277 , 279
permission management 281 , 282
permissions revoking 282 , 283
ACID (Atomicity, Consistency, Isolation, and Durability) 74
adaptive capacity 94
working 94
alerting
best practices 162
designing, considerations 161
in distributed system 161
open-source tools 162
Alertmanager 162
algorithms 6 , 7
factors, for selecting 7
algorithms, load balancing
consistent hashing algorithm 65
IP hash algorithm 65
least connections algorithm 65
least response time algorithm 65
round-robin scheduling 64
URL hash algorithm 65
weighted round-robin 65
Amazon DynamoDB 33
Amazon Kinesis 144
Amazon Web Services (AWS) 71 , 90 , 144
Analytics and Reporting Service 300
Apache Cassandra 97
Apache HBase 97
characteristics 98
data, reading 105
data, writing 104
features 98
META table 101
region flush 104
RegionServer components 102
Apache HBase, servers
HBase Master 100
RegionServer 99
Zookeeper 101
Apache Kafka 140 , 141
concepts 140
significance, in distributed systems 141 , 142
Apache ZooKeeper 33 , 101
API design 3
API functions 91
API gateway 204 , 235 , 262 , 299
API keys 155
API security 154
authentication 155
authorization 155
rate limiting 156
secure communication 156
application gateways 68 , 69
capabilities 69
features 69
application programming interfaces (APIs) 6 , 7 , 149
factors, for designing 7 , 8
application servers 299
architectural patterns
client-server 5
event-driven 5
microservices 5
monolithic 5
Attribute-Based Access Control (ABAC) 155
attributes/fields 75
authentication 155
versus authorization 154
authorization 155
availability 16 , 27
availability and partition tolerance (AP) 26
B
Billing and Subscription Service 300
Bloom filters 41 - 43
use cases 42 , 43
Brewer’s theorem 26
bursting 93
Byzantine fault 36
Byzantine fault tolerance (BFT) 36
Byzantine generals problem (BGP) 25 , 34 , 35
solutions 35
C
cache 114
cached data 114
cache eviction 114 , 120
cache eviction policies 120
cache hit 114
cache miss 114
caching 113 , 263 , 271 , 272
benefits 272
CAP theorem 26 , 27
centralized logging 157
benefits 157 , 158
open-source tools 158
Chaos Automation Platform (ChAP) 34
client APIs 172 , 173
client applications 299
client-server architecture 5 , 204 , 235 , 262
cloud-native implementations 71
code optimization 6 , 8
code optimization techniques
loop unrolling 8
memorization 8
parallelism 8
refactoring 8
collaboration service 263
collaboration flow 274 , 275
designing 273 , 274
error handling and resilience 276
integration services 276
OT algorithms 275
presence management 276
scalability and performance 276
security considerations 277
co-located cache solution 123
advantage 123
challenge 123
co-located/standalone cache
selecting, considerations 124 - 126
column-family databases 77 , 96
characteristics and concepts 96 , 97
Command Query Responsibility Segregation (CQRS) 324
components
selecting, for use case 335 - 338
composite key 92
consistency 27 , 272
consistency and partition tolerance (CP) 26
consistency, DNS 60
consistency level (C) 28
consistency models 13
eventual consistency 14 - 16
strong consistency 14
types 13
consistent hashing 38 - 41 , 82
content delivery networks (CDNs) 2 , 38 , 285 , 292 , 317 , 336
adaptive bitrate streaming 320
architecture 317 , 318
content distribution 318
content security 320
Digital Rights Management (DRM) 320
integrating, with components of Netflix-like platform 321
request routing and video streaming 319 , 320
coordinator node 84 , 85
Count-min sketch 43 - 46
Create, Read, Update, and Delete (CRUD) 192
customer relationship management (CRM) 76
D
Daily Active Users (DAU) 185
database design 3
database management system (DBMS) 107
databases 74 , 75 , 174 , 264
need for 74
types 75
Datadog 160
data duplication strategies 83
peer-to-peer model 84
primary-secondary model 83
data flow 4 , 5
factors, for designing 5
data ingestion 5
data model 257
designing, for Instagram-like service 231 , 232
designing, for Netflix-like service 293
designing, for Twitter-like service 199 , 200
relationships 258
relationships, for Netflix-like service 295
data model, key entity
CollaboratorPermission entity 257
Comment entity 231 , 257
Document entity 257
FolderDocument entity 257
Folder entity 257
Follow entity 231
Revision entity 257
Suggestion entity 257
User entity 231 , 257
data processing 5
data retrieval 5
data storage 5
data store
selecting, for use case 332 , 333
data structures 6 , 7
factors, for selecting 7
selecting, for use case 334 , 335
Denial of Service (DoS) 156 , 336
design patterns 324
destination (dst) 109
detailed design 3
Digital Rights Management (DRM) 320
distributed cache
designing 118
functional requirements 119
non-functional requirements 119
distributed cache, design journey 119
cache eviction policies 120
co-located cache solution 123
data structure for cache 119
design evaluating against requirements 126
LRU cache, designing 121 - 123
standalone cache solution 124
distributed cache solutions 126
Memcached 127
Redis 127
distributed caching 114
use cases 116
using, benefits 116 , 117
using, challenges 117 , 118
versus regular caching 114 - 116
Distributed Hash Table (DHT) 79
Distributed Lock Managers (DLMs) 341
distributed logging
implementing, best practices 158
distributed queue
advantages 132
architectural considerations 134 , 135
designing 132 , 133
implementing 133
features 133 , 134
distributed software system 2 , 3
distributed system attributes
availability 16 , 17
consistency 13
durability 20
fault tolerance 21
hotel room booking example 12 , 13
latency 19 , 20
partition tolerance 17
reliability 20
scalability 21 , 22
distributed systems
alerting 161
evolution 132
Kafka, significance in 141 , 142
key-value stores, using 79
key-value stores, using reasons 79
logging 157
metrics 159
queue, designing 132
queue, using advantages 132
tracing 163
distributed tracing 163
open-source tools 164
DNS caching 58
DNS querying 56
caching 59
iterative queries 56
recursive queries 57 , 58
document-oriented databases 77
document service 263
API endpoints 265
data model 266
designing 265
document creation flow 266 , 267
document deletion flow 270
document history retrieval flow 271
document retrieval flow 268
document update flow 268 , 269
Domain Name System (DNS)
architecture 54
caching 55
consistency 60
exploring 54 - 56
global server load balancing (GSLB) 64
hierarchy 55
name server hierarchy 55
name servers 54
reliability 60
resource records (RRs) 54
scalability 59
Domain-Specific Language (DSL) 142
durability 20
dynamic algorithms 65
DynamoDB 90
API functions 91
data, partitioning 91
no fixed schema 90
primary key types 92
secondary indexes 92
throughput allocation 92 , 93
E
Elasticsearch 224
else (E) 27
entity-relationship diagram
key points 284
ERP (enterprise resource planning) 75
error handling 272
event-driven architecture 5 , 324
eventual consistency
techniques 14
Extract, Transform, and Load (ETL) 143
F
failure detection
ring membership promotion 88 , 89
fault tolerance 4 , 6 , 21
file-sharing service
access control service 263
caching 263
collaboration service 263
databases 264
document service 263
monitoring and logging 264
NoSQL database 264
notification service 263
real-time communication 264
relational databases 264
revision service 263
security and privacy 264
storage system 264
file-sharing system
Continuous Integration and Continuous Deployment (CI/CD) 286
data consistency and concurrency 285
fault tolerance and resilience 285
performance optimization 284 , 285
scalability and elasticity 285
First in, First out (FIFO) 120
first relationship ID (first_rid) 109
FLP impossibility theorem 37 , 38
Fluentd 158
functional requirements 171 , 179 , 228 , 254 , 255
direct messaging 229
news feed 228
notifications 229
photo upload and sharing 228
search and discovery 229
user interactions 228
user registration and authentication 228
G
get operation
implementing 84 , 85
global admission control 94
global server load balancing (GSLB) 63
Google Cloud Platform 71
Google File System (GFS) 33
Google Spanner 34
Grafana 162
graph-based databases 77 , 106
graph-based NoSQL databases
characteristics and concepts 106 , 107
Graphite 160
graph modeling 109
versus relational modeling 109
Graylog 158
gRPC APIs 151
advantages 152
design principles 151
disadvantages 152
use cases 152
versus Representational State Transfer (REST) 152 - 154
H
Hadoop Distributed File System (HDFS) 97 , 303
HAProxy 71
HBase Catalog table 101
HBase Master 100
responsibilities 100
high availability, in DynamoDB 95
read availability 95
write availability 95
high-level design 3 , 234 , 261
API gateway 235
client-server architecture 235
exploring 203 , 204
load balancer 235
microservices architecture 236
high-level solution architecture 178 , 179
high-level system design 4
data flow 4 , 5
fault tolerance 4 , 6
scalability 4 , 6
system architecture 4 , 5
hinted handoff 87
horizontal scaling 6 , 23
advantages 23
considerations and challenges 23
hotel room booking application
request flow 12 , 13
hotspots 82
HyperLogLog 46 - 49
Hypertext Transfer Protocol Secure (HTTPS) 156
I
Instagram-like service features
explore and discover features 250
hashtag functionality 250
internationalization and localization 250
monetization and business model 251
monitoring, metrics, and observability 251
spam and abuse prevention 250
integration services 272
interview session, tips 326
problem, breaking down 327
problem statement, understanding 327
solution, communicating 329 , 330
steps to follow 327 , 328
iterative DNS queries 56
J
Jaeger 164
JSON Web Signature (JWS) 155
JSON Web Token (JWT) 155 , 215 , 280
K
Kafka Streams 142
features 142 , 143
processing topology 143
use cases, example 143 , 144
key performance indicators (KPIs) 251
key-value database 79
key-value stores 76 , 79
designing 80
designing, strategies 89
functional requirements 80
non-functional requirements 80
permanent failures, addressing 87 , 88
temporary failures, managing 86 , 87
using, in distributed systems 79
Kinesis 144 , 145
components 144
Kong 71
Kubernetes
environments 71
L
Last in, First out (LIFO) 120
latency 19 , 20 , 28
techniques and strategies, to mitigate 19
leaky bucket algorithm 156
Least Frequently Used (LFU) 120 , 211
Least Recently Used (LRU) 102 , 120 , 211
load balancers 60 , 204 , 235 , 262
advantages 62 , 63
algorithms 64 , 65
deployment 67
implementing 68
placing 61 , 62
stateful, versus stateless 66
static, versus dynamic algorithms 65
load balancing 60 , 61
at different OSI model layers 66
global server load balancing (GSLB) 63
local load balancing 63
load balancing as a service (LBaaS) 63
logging 264 , 301
Logstash 158
loop unrolling 8
low-level design 238 , 265
access control service, designing 277 - 279
document service, designing 265
News Feed Service 241
Photo Upload Service, designing 238
User Service 244
low-level system design 6
algorithms 6 , 7
APIs 6 - 8
code optimization 6 , 8
data structures 6 , 7
low-level system design, Netflix-like service 301
caching 311
caching and content delivery 306 , 307
database 311
Recommendation Service 312
security and privacy 311
user authentication and authorization 308 - 310
user profile management 310 , 311
User Service 307 , 308
video encoding and transcoding 304
Video Service 301 , 302
video streaming 305
video upload and storage 303
LRU cache
designing 121 - 123
M
many-to-many relationship 258
Memcached 127
community and support 128
scalability 128
selecting, considerations 128
use cases 127
memorization 8
Merkle trees 88
advantages 88
disadvantage 88
functioning 88
Message Authentication Code (MAC) 155
Message Queue 300
META table 101
structure 102
metrics
implementing, best practices 160
in distributed system 159
open source tools 160
types 159
microservices architecture 5 , 70 , 204 - 206 , 236 , 263 , 324
asynchronous processing 237
content delivery network (CDN) 237
database and caching 236
direct messaging service 236
interaction service 236
news feed service 236
object storage 237
photo upload service 236
security and privacy 237
user service 236
Microsoft Azure 71
modern BFT 36
monitoring 264 , 301
monolithic architecture 5
MRU 120
N
Neo4j graph database 107 , 108
characteristics 107 , 108
features 107 , 108
Netflix-like service
data model, designing 293
functional requirements 289 - 291
high-level design 298 - 301
low-level system design 301
non-functional requirements 291 , 292
scale calculations 295
network partition 17 , 18
News Feed Service 241
feed synchronization 243 , 244
news feeds, generating 242
real-time updates 243
NGINX 71
node
adding, to existing graph 110
node store 111
non-functional requirements 172 , 179 , 229 , 255 , 256
availability 230
performance 230
reliability 230
scalability 229
usability 230
NoSQL databases 76 , 77 ,
advantages 77 , 78 , 90
disadvantages 78
types 76
notification service 243 , 263
O
OAuth 155
one-to-many relationship 258
on-premises environments 71 , 72
OpenTelemetry 164
Operational Transformation (OT)algorithms 263 , 275
P
PACELC theorem 27 , 28
Paxos 28 , 29
Raft 31
PagerDuty 162
parallelism 8
partition key 92
partition tolerance 17 , 19 , 27
Paxos 28 , 29
components 29
protocol steps 29 , 30
use cases 31
variants and optimization techniques 30
peer-to-peer model 84
performance 272
Photo Upload Service 238
API endpoints 238
caching and content delivery 241
designing 238
photo retrieval 240 , 241
photo upload flow 238 , 239
Practical Byzantine Fault Tolerance (PBFT) protocol 36
preference lists 84
presence management 276
primary-secondary model 83
priority-based eviction 211
Prometheus 160
Prometheus with Alertmanager 162
PromQL 160
protocol
selecting, for use case 339 , 340
Protocol Buffers (protobuf) 151
proximity services 131 , 181
client APIs, need for 184 , 185
estimates and calculations 185
functional requirements 183
non-functional requirements 183
use cases 182 , 183
pub/sub system 131
characteristics 136 , 137
design considerations 137 - 139
designing 135
put operation
implementing 84 , 85
Q
quadtree
using 187
Quality of Service (QoS) 136
quorum 86
quorum-based system 86
R
Raft 31
challenges and considerations 33
components 32
practical applications 33 , 34
protocol steps 32
read capacity units (RCUs) 92 , 93
read flow 121
read RPS 174
real-time communication 264
real-world use cases, URL shorteners
functional requirements 171
non-functional requirements 172
Recommendation Service 300 , 312
API endpoints 312
evaluation 317
model training and deployment process 315 , 316
monitoring 317
performance 316
recommendation generation flow 313 , 314
scalability 316
user event recording flow 314
record/tuple 75
recursive DNS queries 57
Redis 127
community and support 127
scalability 127
selecting, considerations 128
use cases 127
refactoring 8
RegionServer 99
regular caching
versus distributed caching 114 - 116
relational database management systems (RDBMS) 76
relational databases 75 , 76 , 264
advantages 77
characteristics and concepts 75 , 76
disadvantages 78
relational modeling
versus graph modeling 109
relationships
many-to-many relationship 258
one-to-many relationship 258
relationship store 111
reliability 20 , 21
reliability, DNS 60
remote procedure calls (RPCs) 2
replication group 95
requirements analysis 3
REST APIs 150
advantages 151
design principles 150
disadvantages 151
use cases 151
versus Google Remote Procedure Call (gRPC) 152 - 154
revision service 263
ring membership promotion
for failure detection 88 , 89
Role-Based Access Control (RBAC) 155
r variable
using 85 , 86
S
scalability 4 , 6 , 21 , 22 , 272
boosting 81
horizontal scalability 6 , 23
vertical scalability 6 , 22 , 23
scalability, DNS 59
scale calculations 233 , 234 , 259
assumptions 233 , 259
bandwidth considerations 260
bandwidth requirements 234
processing requirements 234 , 261
storage requirements 233 , 259 , 260
scale calculations, for Netflix-like service 295
assumptions 295
bandwidth estimation 296
processing estimation 297 , 298
storage estimation 296
Search Service 221 , 300
API endpoints, exposing 222
data flow and indexing 222 , 223
relevance scoring and ranking 224
search query processing 223 , 224
security and privacy 264
server hierarchy, DNS
authoritative name servers 55
root-level name servers 55
top-level domain (TLD) name servers 55
Service-Oriented Architecture (SOA) 324
size-based eviction 211
sliding window algorithm 156
software system 1
solution
selecting, for core challenge 340 , 341
source (src) 109
splitting for consumption 94 , 95
standalone cache solution
advantage 124
challenge 124
stateful load balancers 66
stateless load balancers 66
static algorithms 65
storage system 264
Structured Query Language (SQL) 76
system architecture 4 , 5
factors, for designing 5
system design 1 , 3 , 174 , 186
benefits 8 , 9
challenge 187
challenge, solving options 187 - 192
core challenges 174
database choice 178
high-level solution architecture 178 , 179 , 192 , 193
high-level system design 4 , 186
low-level system design 6
practical examples 9
requirements verification 193 , 194
system design challenges
counters approach 176
database, selecting 178
distributed counters approach 176 , 177
MD5 hash 175
random URL, generating 174 , 175
system design cheat sheet
components, selecting for use case 335 - 338
data store, selecting for use case 332 , 333
data structure, selecting for use case 334 , 335
protocol, selecting for use case 339 , 340
solution, selecting for use case 340 , 341
system design interview
structure 332
system design interviews preparation, tips 323
communication skills, honing 326
designing systems, practicing 325
fundamental concepts, understanding 324
online resources, learning 325
performance, reflecting 326
performance, reviewing 326
system design patterns, learning 324
system design process
API design 3
database design 3
detailed design 3
high-level architecture design 3
requirements analysis 3
user interface design 3
T
term frequency, inverse document frequency (TF-IDF) 224
throughput 92
throughput allocation 92 , 93
throughput optimizations, in DynamoDB 92
adaptive capacity 94
bursting 93
global admission control 94
splitting for consumption 94 , 95
Timeline Service 218
API endpoints, exposing 218
data flow 218 , 219
push-based updates 221
timeline retrieval flow 219 , 220
Time to Live (TTL) 211
token bucket algorithm 156
token bucket system 93
tracing
implementing, best practices 165
in distributed system 163
Transport Layer Security (TLS) 156
tweets 195
Tweet Service
API endpoints 207
caching 210
caching strategies 210
data storage 207
designing 206 , 207
eviction strategies 211
implementation considerations 211 , 212
tweet creation flow 208
tweet retrieval flow 209
Twitter-like service
additional considerations 224 , 225
data model 199 , 200
functional requirements 196 , 197
high-level design, exploring 203 , 204
microservices 204 - 206
non-functional requirements 198
scale calculations 201 , 202
Search Service 221
User Service, designing 212 , 213
Tyk 71
U
Uniform Resource Identifier (URI) 150
URL shorteners 169
estimates and calculations 173 , 174
real-world use cases 170
requirements verification 179 , 180
User Datagram Protocol (UDP) 60
user interface design 3
User Service 244 , 300
API endpoints 244 , 245
API endpoints, exposing 213
data storage 213 , 214
designing 212
followers/followees, retrieving 217
follow/unfollow flow 216
follow/unfollow functionality 247 - 249
user authentication flow 215
user registration and authentication 245 - 247
user registration flow 214 , 215
V
vertical scaling 6 , 22
advantages 22
limitations 23
Video Service 299
virtual nodes 82
advantages 83
W
web application firewalls (WAFs) 70
wide-column stores 96
Write-Ahead Logging (WAL)) 340
write capacity units (WCUs) 92 , 93
write flow 121
write RPS 174
w variable
using 85 , 86
Z
Zipkin 164