System Design
Ref
- Distributed systems cheat sheet
- https://github.com/donnemartin/system-design-primer
- https://www.cloudcomputingpatterns.org/
- https://docs.microsoft.com/en-us/azure/architecture/guide/
Distributed Computing
Fallacies of Distributed Computing:
- The network is reliable
- Latency is zero
- Bandwidth is infinite
- The network is secure
- Topology doesn’t change
- There is one administrator
- Transport cost is zero
- The network is homogeneous
CAP theorem
: states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees:
- Consistency
- Availability
- Partition Tolerance
ACID
: set of properties of database transactions intended to guarantee validity even in the event of errors, power failures, etc
- Atomic
- Consistency
- Isolation
- Durability
BASE
: Basically Available, Soft state, Eventually consistency
Availability & Reliability
Availability
= system can serve the request
- load balancing
High availability (HA) mean no downtime always available
Reliability
= availability + working properly
- automated test
Single point of failure
= if it fails, will stop the entire system from working
Metrics:
- Uptime
- Downtime
- Failures
RPO
= Recovery Point Objective = How much data can we looseRTO
= Recovery Time Objective = How long it take to RecoveryMTBF
= Mean-Time-Between-Failures = Time between failures
Durability & Resiliency
Durability
refers to the on-going existence of the object or resource. Note that it does not mean you can access it, only that it continues to exist.
- By taking regular backups
- Storing resources in different geographical locations to sustain disasters.
- Performing checksums on data and repairing the corrupted data from backups.
Resiliency
= self-heal
- Desing to identify faulty software or hardware and automate the repair/restart features or in case of beyond repair, just take it out of the working system.
- Active failover sites for applications and active replication to restore corrupted data.
Redundancy and Replication
Data Deduplication: Technique for eliminating duplicate copies of repeating data
CRDT
= Conflit-free replicated data type
Consistent Hashing
Message Queue / Pub-Sub
Ref:
Types of delivery semantics:
- at-most-once
- at-least-once
- exactly-once
<!–
Rate Limiter
On progress
SQL vs. NoSQL
On progress
Long-Polling vs WebSockets vs Server-Sent Events
On progress –>
Partition & Sharding
Cache
Ref:
- Guides by Google
- Guides by Fastly
- Guides by Heroku
- Precondition HTTP Header
- RFC7234 - HTTP 1.1 Caching
- https://blog.logrocket.com/caching-strategies-to-speed-up-your-api/
- https://codeahoy.com/2017/08/11/caching-strategies-and-how-to-choose-the-right-one/
- https://sookocheff.com/post/api/effective-caching/
Solutions:
- Varnish: caching HTTP reverse proxy
Strategies:
- Cache Aside
- Read/Write Through
- Write-around
- Write-back
- Refresh ahead