-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Peter Park
committed
Jan 6, 2025
1 parent
07cd949
commit ff34acc
Showing
23 changed files
with
313 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Cache | ||
|
||
|
||
**Hybrid Cache** | ||
|
||
Uses both local and remote cache. | ||
* Local Cache: Caffeine | ||
* Remote Cache: Redis (Lettuce) | ||
|
||
- Low latency: Local cache is faster than remote. | ||
- Memory management: handle memory by using LRU policy | ||
- Prevents cache stampede: Minimizes backend load when cache is missing (local cache -> remote cache -> db) | ||
- Clustering: scaling in high traffic, replicate data across node | ||
- Cache warm-up: Updates local cache during server startup. | ||
|
||
### Redis | ||
* pros: | ||
* rich data structure: string, list, sorted set, etc | ||
* persistence: RDB snapshot, AOF logs for backup, recovery | ||
* replication and clustering: scalability, fault-tolerance | ||
* atomic operation | ||
* high performance | ||
* cons: | ||
* single thread: might cause bottleneck | ||
|
||
### Memcache | ||
* pros: | ||
* simplicity: easy to setup, simple key-value | ||
* performance: fast get/set operation | ||
* multi thread: multi core process | ||
* low memory | ||
* cons: | ||
* no persistence: no backup, data is lost on restart of failure | ||
* limited data structure | ||
* no built in clustering | ||
* only LRU eviction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Database | ||
|
||
**DB Replication** | ||
|
||
- Improved read performance: Master for writes, replicas for reads. | ||
- Scalability and availability: Backup in case of failures. auto recovery | ||
- Load distribution: Spreads read and write operations across replicas. | ||
- read time replication of transaction logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# ID Generator | ||
|
||
creating unique and short IDs for URLs | ||
|
||
### Redis `INCR` | ||
The `INCR` in Redis generates auto increment IDs | ||
* pros: | ||
* Low latency: fast due to memory-based | ||
* Atomicity: The single-threaded of Redis ensures no collisions. | ||
* Scalability: clustering and sharding, master and replica | ||
* cons | ||
* SPOF: Data can be lost if the Redis server crashes. | ||
* Replication Lag: delays in replication cause ID synchronization issues. | ||
|
||
### Database `Auto Increment ID` | ||
use `AUTO_INCREMENT` to automatically generate unique IDs. | ||
* pros: | ||
* Built-in Functionality: minimal setup | ||
* Durability: IDs managed by DB system | ||
* Fail over: replication | ||
* cons: | ||
* Performance: Slower than Redis | ||
* Scalability: Inefficient in distributed database | ||
* Locking Issues: concurrency issue due to transaction locking. |
Oops, something went wrong.