Skip to content

Commit d7640bc

Browse files
committed
a
1 parent 01b251b commit d7640bc

23 files changed

Lines changed: 326 additions & 469 deletions

_CONTENT/eng/data/acid.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
---
3+
atomicity: tx
4+
consistency: invariants, FK, constraints
5+
isolation: concurrent txs do not interfere
6+
durability: WAL, replicas, fsync, power hardware
7+
8+
## tx
9+
group ops. to atomic units
10+
no partial failure
11+
consistency
12+
fk integrity
13+
data sync
14+
15+
## isolation problems
16+
lost updates
17+
18+
1. dirty-read: see uncommitted
19+
2. non-repeatable read: same query, different result
20+
3. phantom read: new rows appear or disappear
21+
4. lost updates: conc. writes lose data
22+
5. read-skew: existing rows change between reads
23+
6. write skew: two tx reads same data to decide writes
24+
may violate invariants, eg. no doctors remaining
25+
needs serial isolation
26+
27+
# solutions
28+
29+
## read committed
30+
only see committed rows
31+
read-skew possible
32+
33+
## repeatable read
34+
snapshot
35+
only see data committed before tx began
36+
37+
solves read-skew
38+
39+
impl. by MVCC
40+
multi-version conc. control
41+
each tx gets a snapshot (a set of tx ids)
42+
43+
analytics, backups
44+
45+
## serializable
46+
prevent all races
47+
solves phantoms and write-skew
48+
49+
MVCC + SSI
50+
20% perf cost
51+
52+
SSI: serializable snapshot isolation
53+
predicate locks
54+
dependency cycles
55+
56+
## dist tx
57+
saga: commit or compensate
58+
59+
or replicate entire transaction log through consensus

_CONTENT/eng/data/dataflow.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
---
22
---
3+
## encoding
4+
backward comp: old data, new code
5+
6+
breaking:
7+
deleting required fields
8+
changing field types
9+
10+
keep unknown fields
11+
tags vs names: compact + rename later
12+
13+
schema evolution
14+
avro
15+
protobuf
16+
317
## ipc
418
db
519
api
620
msg passing
721

822
push: pubsub, ws, sse, webhook
923
pull: query, poll
24+
q: decouple, buffer
1025

11-
stream: events
12-
batch: cron
13-
14-
req-resp
15-
q
16-
17-
MPI: message passing interface
26+
MPI
27+
message passing interface
1828
no central coordinator
1929
nodes communicate directly
2030

31+
## delivery guarantees
32+
at-most-once
33+
at-least-once: retries + idempotent receiver
34+
exactly-once: at-least once + dedup
2135

22-
## batch
36+
producer: add uniq msg ids, retry, track sent msgs on outbox table
37+
consumer: store seen ids, dedup, process+ack in tx
38+
39+
producer retry + consumer dedup
2340

41+
## batch
2442
immutable inputs
2543
atomic ops
2644

@@ -42,7 +60,6 @@ spark df
4260
Delta lake: parquet + transaction log + metadata
4361

4462
## stream
45-
4663
immutable events
4764
side effects
4865

@@ -61,17 +78,12 @@ watermark
6178
backpressure
6279
circuit breaker
6380

64-
exactly once
65-
idempotence + atomic commits
81+
exactly once: idempotence + tx commits
6682

6783
probabilistic dsa like bloomfilter, hyperloglog
6884

69-
windows
70-
fixed
71-
overlapping
72-
sliding
73-
session
85+
windows: fixed, overlapping, sliding, session
7486

7587
stream + stream : window
7688
stream + table : enrich
77-
table + table : materialized view of join
89+
table + table : materialized view of join

_CONTENT/eng/data/dist.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
---
3+
## consistency
4+
linearizable
5+
single copy illusion
6+
single leader
7+
election consensus
8+
sync replication or quorum
9+
10+
causal
11+
vector clocks + dependency tracking
12+
13+
eventual
14+
async replication
15+
conflict resolution (LWW, CRDTs, version vectors)
16+
17+
## consensus
18+
raft: majority ack, one leader per term
19+
split brain: lease + fencing token
20+
paxos
21+
pbft: o(n2)
22+
23+
## time and order
24+
NTP
25+
GPS
26+
27+
lamport clock: single counter per process, can only tell if A happens-before B
28+
vector clocks: list of counters per process, can detect concurrency, detects conflicts
29+
version vector: each replica tracks versions of replicated data objects
30+
31+
## availability
32+
heartbeat pings with timeout, adapt to network conditions
33+
lease with ttl
34+
gossip
35+
36+
## atomic commit
37+
2PC: ask all, commit if they all ack, like marriage, coordinator spof
38+
practical: 2pc + raft for coordinator failover

_CONTENT/eng/data/isolation.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

_CONTENT/eng/data/rep.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
---
3+
## replication
4+
```
5+
wal: low-level, version dependent
6+
logical: version free. CDC
7+
statement: compact but non-det.
8+
9+
leaderless
10+
single leader: eg. psql streaming
11+
multi leader: multi-datacenter, offline apps, docs
12+
13+
replication lag
14+
session models
15+
read after write: route reads to where you wrote or use timestamps
16+
monotonic reads: read from same server, sticky session
17+
consistent prefix reads: read in causal order
18+
19+
avoid conflicts
20+
same leader
21+
crdt
22+
23+
resolve conflicts
24+
read repair: compare replica responses
25+
background anti-entropy: detect using hashes of data parts and version vectors
26+
app logic: eg. last-write-wins
27+
28+
version vector: each replica tracks versions of replicated data objects
29+
```
30+
31+
## sharding
32+
```
33+
key range
34+
hash
35+
hybrid (hashkey, sortkey)
36+
37+
rebalancing
38+
fixed: many more parts upfront
39+
dynamic: split large, merge small. good for key-range
40+
hybrid
41+
42+
secondary indexes: local or global
43+
keep related data together to prevent scatter/gather
44+
hot keys: random prefix/suffix
45+
46+
```

_CONTENT/eng/data/storage.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
---
22
---
3-
## encoding
4-
backward comp: old data, new code
5-
6-
breaking:
7-
deleting required fields
8-
changing field types
9-
10-
keep unknown fields
11-
tags vs names: compact + rename later
12-
133
## log segments
144
kafka
155

@@ -18,9 +8,15 @@ parquet
188
clickhouse
199
influx
2010

11+
compression
12+
skip ranges
13+
only needed cols
14+
2115
## B+ trees
2216
all data in leaves
17+
100-500 children per node (fanout)
2318
leaves are linked for range queries
19+
write amplification from splitting/rebalancing
2420

2521
one node = one disk page (4kb)
2622

@@ -61,6 +57,9 @@ periodic merge
6157
local data, seq. io, flat files
6258
better compression and disk life
6359

64-
10x write throughput vs b-tree, 0.5x read/s
6560
less stable response times in higher percentiles
6661

62+
vs B-tree
63+
slower point queries
64+
better sequential write throughput
65+
multiple versions of same key until compaction

_CONTENT/eng/data/tx.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

_CONTENT/eng/dist/dist.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

_CONTENT/eng/dist/partitioning.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)