Distributed Cache
Posted on
|
In
System Design
Requirement
- Functional (put, get)
- non-functional (high scalability, high availability, high performance)
Simple solution
- client -> local cache -> Data storage
- LRU
Scale to multiple machine
- local cache is not enough -> distributed system
- separate service / cache server
- sharding cache server (Consistent Hashing)
- Cache client call config service(ZooKeeper) to discover all cashe servers
- master / slave for cache server
- put: master
- get: slave
Resource
TODO
cache miss, search from disk? Bloom filter? SStable?
Back-of-the-envelope Estimation
Posted on
|
In
System Design
Powers of two table
1 | Power Exact Value Approx Value Bytes |
Resource
Rate Limiter
Posted on
|
In
System Design
Rate limiter could implmented by each API/ each IP/ total region Might save the rule in DB / config file
Where to implement
- server side
- Fully control
- middleware
- API gateway
- Might be 3rd party
Algorithm
- Token bucket
- Leaking bucket
- Fixed window counter
- sliding window log
- Sliding window counter
Resource
- Good video
- Need to review again to get deeper
- Code for TokenBucket
- 九章算法