System Design Basics
System design is the process of defining elements of a system based on the specified requirements.
Here, we will be covering six basic terms that are widely used in system designing.
1. Caching
What is caching?
Caching is the process of storing data in a cache (temporary storage), so that future requests for that data can be served faster.
When do we cache?
When site content is not changed frequently, we can use CDN to reduce the load on the server and to serve the end-user — much faster.
When your server is consuming more time because of some intensive computations.
When the server has to make multiple network requests and API calls.
2. Proxies
What is a Proxy?
A proxy server is a server that acts as a gateway between client and server.
The proxy server will get all the request from the client and forwards the request to the server. So when the server responds, it will receive the data and forward it to the client.
Types of Proxies
Forward Proxy: A proxy (server) which acts on behalf of the client in the interaction between client and server.
e.g. VPNsReverse Proxy: A proxy (server) which acts on behalf of the server in the interaction between client and server.
e.g. Load Balancing
Why do we use a Proxy Server?
To log requests and responses
To block or unblock websites
Encrypting and decrypting
Transform request headers
Caching
Secures the actual application servers
3. Scalability
What is scalability?
The ability to handle more request, either by adding more machines or by adding bigger machines.
Types of scalability
Vertical Scaling: Scale by adding more power (CPU, RAM) to a server.
Horizontal Scaling: Scale by adding more machines to a server.
Difference
4. Load Balancers
What is Load Balancer?
A load balancer acts as a reverse proxy and distributes traffic to different servers in the resource pool to ensure that no single server becomes overworked and subsequently unreliable. Load balancers effectively minimize server response time and maximize throughput.
Common Load Balancing algorithms
Round Robin
Least Connection Method
Least Response Time Method
Least Bandwidth Method
Hashing Methods
Custom Load Method
5. Databases
Relational Databases
It has a strict structure on all the data entities.
Stores data in a structured table with rows as records and columns as attributes.
Most relational databases support (SQL) Structured Query Language.
It supports ACID properties.
Example: MySQL, PostgreSQL, SQLite.
Non-Relational Databases
It has a more flexible structure for its data.
Stores data in key-value pairs. Represent data in collections of JSON documents.
It supports BASE properties.
Example: MongoDB, Cassandra, CouchDB.
Relational — ACID Properties:
A-Atomicity: The database must guarantee that if one operation fails the entire transaction will also fail. It’s “all or nothing”.
C-Consistency: The database must be consistent before and after the transaction. Every read operation will receive the updated resulted after a recent write operation.
I-Isolation: Multiple transactions will occur independently without interference. Changes occurring in a particular transaction will not be visible to other transaction until that transaction is completed.
D-Durability: Once data is stored in the database, it will remain even if the system failure occurs. As it is stored in the disk(e.g. HDD) and not in memory(e.g. RAM).
Non-Relational — BASE Properties:
BA-Basically Available: This database guarantees availability in terms of CAP theorem.
S-Soft State: The system may change over time even without input. Copies of a data item may be inconsistent due to eventual consistency.
E-Eventual Consistency: The system will eventually become consistent if it doesn’t receive input during that time.
When to use SQL vs NoSQL?
6. CAP Theorem
Consistency, Availability, Partition tolerance
What is CAP Theorem?
CAP theorem states that any distributed system can support only any two among consistency, availability, and partition tolerance.
Consistency: In a distributed system, all the nodes maintain the same data at a given time.
Availability: At any time every request for the distributed system gets a valid response.
Partition Tolerance: The distributed system can perform continuously even if there is a network failure or data loss.
Thanks for reading ❤
CodeMasheen.org | Instagram | Twitter | Originally posted at Medium