System Design Material - s530479-ShivaKumar/Leet GitHub Wiki
System Design
Basic approach
Ask lot of questions to clarify the requirements.
List all the functional and non functional requirements.
Design the API's required
Talk about the database schema
Explain the architectural design.
Key characteristics of Distributed systems.
Scalability
Reliability
Availability
Efficiency
Serviceabbility or Manageability.
Load Balancing
1. LB algorithms
Least Connection Method
Least Response Time Method
Least Bandwidth Method
Round Robin Method
Weighted Round Robin Method
IP Hash.
Caching
Appication Server Cache
Cache invalidation
Write through cache
Write around cache
Write back cache.
Cache eviction policies
First In First Out (FIFO)
Last In First Out (LIFO)
Least Recently Used (LRU)
Most Recently Used (MRU)
Least Frequently Used (LFU)
Random Replacement (RR)
Data Partitioning
Methods
Horizontal partitioning
Vertical Partitioning
Directory Based Partitioning
Partitioning Criteria
Key or Hash-based partitioning
List partitioning
Round-robin partitioning
Composite partitioning
Common problems of Data Partitioning
Joins and Denormalization
Referential integrity
Rebalancing
Indexing
While indexing increases the performance of querying the database, they should be carefully selected to avoid decrease in performance where there are more write operations than retrivals.(Since we have to update the indexes each time when there is an insertion).
Proxies
A proxy server is an intermediate server between the client and the back-end server. Clients connect to proxy servers to make a request for a service like a web page, file, connection, etc. In short, a proxy server is a piece of software or hardware that acts as an intermediary for requests from clients seeking resources from other servers.
Typically, proxies are used to filter requests, log requests, or sometimes transform requests (by adding/removing headers, encrypting/decrypting, or compressing a resource). Another advantage of a proxy server is that its cache can serve a lot of requests. If multiple clients access a particular resource, the proxy server can cache it and serve it to all the clients without going to the remote server.
Open Proxy
Anonymous
Transparent
Reverse Proxy
Databases
SQL
Relational databases store data in rows and columns.
MySQL, Oracle, MS SQL Server, SQLite, Postgres, and MariaDB.
NO SQL
Key-Value Stores
Redis, Voldemort, and Dynamo.
Document Databases
CouchDB and MongoDB.
Wide-Column Databases
Cassandra and HBase.
Graph Databases
Neo4J and InfiniteGraph.
Differences between SQL and NoSQL
Storage
Schema
Querying
Scalability
Reliability or ACID compliance
System Design Problems
tiny URL
Functional Requirements
Should create a short url of fixed size when given a big URL
Should retrieve the big URL when short url is given
User login
Non functinal requirements
System should be available
System should be Scalable
System should be durable
System should be consistent.
API design
CreateURL(userToken, longURL, expirationTime)
get(userToken, shortURL)
deleteURL(userToken, shortURL)
DBSchema
NoSql will be good as we don't have much mappings and it can scale easily.