System Design Flashcards
Master Template
DNS (Domain Name System)
phonebook for the internet. domain is sent in query to recursive resolver which provides the IP address.
what is a load balancer?
distribute network traffic. ensure optimal resource utilization, reduced latency, high availability.
round robin (load balancer)
requests are sequentially and evenly distributed across all available servers in a cyclical manner
least connections (load balancer)
assigns requests to the server with the fewest active connections
IP Hash (load balancer)
client’s IP is hashed, the result decides which server the request is directed to. this method ensures that the same user ends up on the same server, helping maintain session persistence
API Gateway Functions
Request Routing
Authentication and Authorization
Rate Limiting
Caching
Request and Response Transformation
Authentication vs Authorization
Authentication is verifying identity, usually based off a token.
Authorization is verifying what actions a user has based off their role.
Content Delivery Network (CDN)
distributed network of servers that store and deliver content (images, videos, scripts) to users from locations that are geographically closer to them.
request for content->check local server->if cached, return->else check other local servers or origin->cache locally and serve content
sharding
dividing the rows of a table into smaller tables and storing them on distinct servers or database instances. This method is employed to distribute the database load across multiple servers, thereby enhancing performance.
vertical partitioning
splitting the columns of a table into separate tables. This technique aims to reduce the column count in a table and boost the performance of queries that only access a limited number of columns.
Database Replication
The main objective of database replication is to enhance data availability, redundancy, and fault tolerance, ensuring the system remains operational even in the face of hardware failures or other issues. Primary database + many replicas.
Distributed Messaging Systems
These systems facilitate communication by decoupling sender and receiver components, enabling them to develop and function independently. provide a reliable, scalable, and fault-tolerant means for exchanging messages between numerous, possibly geographically-dispersed applications, services, or components.
Microservices
loosely coupled independent functions. SRP. independence, decentralized, communication via REST/gRPC. fault tolerant.
NoSQL datbases
unstructured or semi-structured data. flexible and scalable. document based(MongoDB): JSON.
Key-Value (DynamoDB): best for read/write and scaling horizontally.
Column-Family (Cassandra): groups of related columns. best for write-heavy workloads and queries with known row/column keys.
Graph-Based (Neptune): complex relationships like social networks or recommendation systems.
Database Index
enhance speed of query operations. provide a direct route to data in the table without searching. implemented using a b-tree. tradeoff: additional storage space, write performance (have to update indices)