System Design Flashcards
What are CRUD operations?
Create, Read, Update, Delete
Often serves as the bedrock of a functioning system, thus at the core of many APIs
What is pagination and why is it necessary?
When a network request warrants a large response, the API might be designed to return a limited portion of that response accompanied by an identifier for the client to request the next page if desired
Often used when designing API list endpoints
What is an ACL?
Access Control List
Refers to a permissioning model about which users in a system can perform which operations
What is a DDoS attack?
Distributed Denial of Service attack
A DoS attack where the traffic flooding the target system comes from many different sources making it much harder to defend against
What is a DoS attack?
Denial of Service attack
Attack where a malicious user tries to bring down or damage a system in order to render it unavailable to users, often by flooding the target system
What is rate limiting?
The act of limiting the number of requests sent to/from a system
Often used to prevent DoS attacks
What is streaming in terms of networking?
The act of continuously getting a feed of information from a server by keeping an open connection between the two machines
What is polling?
The act of fetching data regularly at an interval to make sure the data is not too stale
What is a socket?
A kind of file that acts like a stream
Processes can read/write to sockets and communicate in this manner
Often fronts for TCP connection
What is the gossip protocol?
When a set of machines talk to each other in an uncoordinated manner in a cluster to spread information through a system without requiring a central source of data
What is a peer-to-peer network?
A collection of machines referred to as peers that divide workload between themselves to complete the workload faster
Often used in file distribution systems
What is blob storage?
Widely used storage that only allows the user to store and retrieve data based on the name of the blob
ie. GCS and AWS S3
What is a key value store?
A flexible NoSQL db often used for caching and dynamic configuration
Examples:
- Etcd
- Zookeeper
- Redis
What is the difference between strong consistency vs eventual consistency?
Strong consistency
- Refers to consistency of ACID transactions
Eventual consistency
- Database reads may return stale data
- An eventually consistent database gives guarantees that the state of the db will eventually reflect writes within a certain time period
What is ACID transaction?
A type of db transaction that has the following properties
Atomicity
- The operations that constitute the transaction will either all succeed/fail
Consistency
- Transaction cannot bring db to an invalid state
- After the transaction is committed/rolled back, the rules for each record will still apply
Isolation
- Execution of multiple transactions concurrently will have the same effect as if they had been executed sequentially
Durability
- Any committed transaction is written to non-volatile storage; not be undone by a crash, power loss or network partition
What is the difference between relational vs non-relational databases?
Relational db
- Structured db where data is stored following a tabular format
- Often referred to as SQL dbs
- Often supports powerful querying using SQL
Non-relational db
- Database that is free from imposed, tabular-like structure
- Often referred to as NoSQL dbs
What are the different ways that data can be stored? Explain the difference
Disk
- Data will persist through power failures and machine crashes
- Can refer to either HDD or SSD
- AKA persistent storage
Memory
- Refers to RAM (Random Access Memory)
- Data stored in memory will be lost through power failures and machine crashes
What are databases?
Programs that either use disk/memory to store/query data
In general, they are themselves servers that are long-lived and interact with the rest of your application through network calls, with protocols on top of TCP or HTTP
What is the single responsibility principle?
A single component having one responsibility and executing it perfectly
This approach provides flexibility and makes management easier
What is separation of concerns?
Keeping components separate/loosely-coupled makes them reusable
This approach makes scaling the service easier
What is client-server architecture?
Uses the request-response model
The client sends a request to the server for information and the server responds with it
What is a client?
A machine/process that requests data from a server
A single machine can be both client and server at the same time
ie. act as a server for users and a client for a db
ie. web app, mobile app, web-based console running commands to interact with the backend server
What is a server?
A machine/process that provides data for a client, usually by listening to incoming network calls
A single machine can be both client and server at the same time
ie. act as a server for users and a client for a db
ie. app server, proxy server, mail server, file server
What is an IP address?
An address given to each machine connected to public internet
Special values
- Localhost: 127.0.0.1
- Your private network: 192.168.x.x
Why are there different ports?
In order for multiple programs to listen for new network connections on the same machine without colliding, they pick a port to listen on
Common ports and their uses
- 22: SSH
- 53: DNS lookup
- 80: HTTP
- 443: HTTPS
What is TCP?
Network protocol built on top of IP
Allows for ordered, reliable data delivery between machines over the internet by creating a connection
TCP is usually implemented in the kernel, which exposes sockets to applications that they can use to stream data through an open connection
What is HTTP?
HyperText Transfer Protocol
Common network protocol implemented on top of TCP
What is an IP network packet?
Data being sent over IP
Consists of:
- IP header: contains source and destination IP addresses, and other network-related information
- Payload: data being sent
What are application servers?
Servers that run web apps
What is a forward proxy?
A server that sits between a client and server and acts on behalf of the client
Typically used to mask the client’s identity (IP address)
What is a reverse proxy?
A server that sits between clients and servers and acts on behalf of the servers
Typically used for logging, load balancing and caching
ie. Nginx is a popular web server often used as a reverse proxy and load balancer