ifchicken's blog


  • Home

  • About

  • Tags

  • Categories

  • Archives

  • Search

LC-Backpack

Posted on 2021-06-20 | In LC
需要输入密碼查看哦。
Read more »

LC-40 Combination Sum II

Posted on 2021-06-20 | In LC
需要输入密碼查看哦。
Read more »

LC-322 Coin Change

Posted on 2021-06-20 | In LC
需要输入密碼查看哦。
Read more »

LC-377 Combination Sum IV

Posted on 2021-06-20 | In LC
需要输入密碼查看哦。
Read more »

LC-494 Target Sum

Posted on 2021-06-19 | In LC
需要输入密碼查看哦。
Read more »

Distributed Cache

Posted on 2021-06-07 | 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

  • original video
  • zookeeper
  • ref2

TODO

cache miss, search from disk? Bloom filter? SStable?

Back-of-the-envelope Estimation

Posted on 2021-06-06 | In System Design

Powers of two table

1
2
3
4
5
6
7
8
9
10
Power           Exact Value         Approx Value        Bytes
---------------------------------------------------------------
7 128
8 256
10 1024 1 thousand 1 KB
16 65,536 64 KB
20 1,048,576 1 million 1 MB
30 1,073,741,824 1 billion 1 GB
32 4,294,967,296 4 GB
40 1,099,511,627,776 1 trillion 1 TB

Resource

  • Latency number

Consistent Hashing

Posted on 2021-06-06 | In System Design

Used for re-sized hash table without moving most of data

Resource

  • ref

Rate Limiter

Posted on 2021-06-06 | 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

  1. server side
    • Fully control
  2. 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
  • 九章算法

system design

Posted on 2021-06-05 | In System Design
需要输入密碼查看哦。
Read more »
12<i class="fa fa-angle-right"></i>

ifchicken

16 posts
4 categories
1 tags
© 2021 ifchicken
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4
0%