Category Archives: design

ddia chapter 5, replication

1. partition by key range 2. partition by hash HBase, key is sorted partition内部再sort. read intensive, 1. replication, 2. cache? read intensive leaderless, 加名人list,加cache leader-replica, 加replica vertical scale, 加CPU, memory, disk vertical split table. 将不同的column放在不同的node中 normalize, 归一化, no redundancy denormalize, large table global secondary index, local secondary index. consistency hashing rebalancing, 并不能彻底解决hotspot fixed number of… Read More »

DDIA, leaderless

Dynamo database, leaderless, quorum read/write, vector clock. database, ACID cache coherent, consistency linearizable, 用户写的action发生了,那么read的时候就要读出write的内容 leaderless, quoram write, quoram read read repair or a background process to detect the stale data in replica 如果是read repair,某些data一直没有被read repair过,有些机器down了。good data node不在了。所以一定要有background process anti-entrophy the higher entropy, the greater the disorder 3 nodes. r+w>n. when w=1, r=3. user1 only write… Read More »

Base64

959, in Base64 is O/. / is not uri-safe. An althernative is transform it to ASCII %47%. But this lengthens the URL. So in Base64, + -> – / -> _ Or use Base62. But Base62 transformation is too complex. In Base64, each char takes up 6 bits. So always make the coding 24 bits, or 3… Read More »

short polling, long polling, websocket

short polling ajax based call. Every fixed amount of time, it calls server and get the result(the result might be empty as well). long polling When client and server has opened a TCP connection, it won’t close. Client just wait. Whenever there is message in server side, it sends to client. web socket client builds a… Read More »

write intensive DB. LSMTree

scenario, intensive write. Also once written in DB, can be used immediately. Such as LSM Tree, (Log Structured Merge Tree) In memory, calld memtable. In disk called sstable(Sorted String Table) 1. append to WAL first, then append to memtable. In any case system is crashed, can recover from WAL. memtable is sorted. When it reaches… Read More »

Linearizability vs Serializability

Linearizability, 强调分布式中并发执行的顺序 Serializability, in DB, repeatable read doesn’t guarantee whole data has other data updated, deleted, or inserted. refer to isolation level.

DDIA chapter 7, Replica

leader based repliaction, elasticache replica pulls master replication log sync, async, semi-sync(only 1 replica is sync, other replicas are async) setup a new replica, or replica is down 1. copy snapshot 2. start sync from the log sequence number master is down 1. replica votes a new master 2. new master has data almost same… Read More »

transaction, distributed, replica keywords

facebook tao system. single leader replication. collaborative editing https://www.zhihu.com/question/274573543 https://operational-transformation.github.io/index.html OT, operational transaction write through cache, read through cache 2 leaders ddia figure 5-8 ring replication tungstn master-master replication Conflict-free replicated data type distributed lock -> distributed cache, chubby 读写异步 写异步->写事件流 paxos multi-paxos read after write, cascading rollback write after read, non repeatable read. https://jepsen.io/consistency… Read More »

Isolation Level

Optimistic lock, when do transaction, read the version I’d and timestamp. Dismiss when version is or timestamp changed. Good for a lot of read scenario Pessimistic lock, when do transaction, lock the record 3 types of read anomaly: Dirty read Non repeatable read Phantom read 4 Isolation levels Uncommitted read read an uncommitted data. After… Read More »

Rewrite lock, copy-on-write

Rewrite lock. Lock a data, then write it, then release the lock. copy-on-write, copy the data into a new place, update the date in new place. Then update the data’s reference to the new place.