Skip to content

Commit 0a94581

Browse files
committed
Raw SQL, PHP, J and some ultra basic distributed system stuff
1 parent 2aae807 commit 0a94581

File tree

11 files changed

+700
-64
lines changed

11 files changed

+700
-64
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ bower_components/
2626
*.log
2727
*.out
2828
*.dvi
29+
30+
.php_cs.cache
31+
.rubocop*

distributed-systems/basics.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Podcast with Heidi Howard (Research fellow in Comp Sci at Cambridge)
2+
3+
Sources
4+
5+
* Raft
6+
* https://raft.github.io/raft.pdf
7+
* good first paper to introduce this area
8+
* Paxos made moderately complex
9+
* Good 2nd paper after the Raft paper
10+
* _The part-time parliment_ by Lamport is the original paper which pioneered distributed systems
11+
* https://lamport.azurewebsites.net/pubs/lamport-paxos.pdf
12+
* fairly vague so it's hard to be sure whether things (e.g. Raft) are or are not Paxos
13+
* _Paxos made simple_ by Lamport
14+
* https://lamport.azurewebsites.net/pubs/paxos-simple.pdf
15+
* Lamports attempt to make paxos more obvious
16+
17+
18+
Distributed consensus algorithms
19+
20+
Distributed system =
21+
1. concurrent: multiple things happening at the same time
22+
1. asynchrony: we don't know how long messages will take to get to their destinatin
23+
1. failures: we don't know _if_ they will get to their destination
24+
25+
Consensus = making a decision in a distributed system
26+
examples:
27+
deciding a vaule in a register
28+
deciding an ordering of operations to be applied to a database
29+
30+
Consensus has 3 components:
31+
32+
1. the value you agree is the value somebody proposed (non triviality component)
33+
1. when you decide a value that is final then everybody finds ot the same vaule (the safety component)
34+
1. if everything is working ok in the ystem the system will reach a decision (the progress component)
35+
36+
37+
Luckily we don't always need consensus in a distributed systemd
38+
because it is quite expensive in terms of number of messages exchanged
39+
40+
YOu need consensus when you need _strong consistency guarantees_
41+
e.g. in a key-value store where you absolutely have to have linearizability, you need consensus when you can't rely on the clocks being synchronized
42+
43+
e.g. Google spanner avoids the need for consensus by putting atomic clocks in their data centers
44+
if you can rely on timestamps to be consistent within a very small margin then you don't need consensus
45+
46+
47+
* Consesus is the method of achieveing very strong consistency
48+
* in terms of CAP you are getting strong C but compromising availablity A i.e. it is a system focusing on C_P
49+
* many consensus systems rely on majorities - if a majority of nodes goes down then it can't reach consensus
50+
* e.g. 3 node system can tolerate 1 failure
51+
* 5 node system can tolerate 2 failures
52+
* 7 node system can tolerate 3 failures
53+
* people don't tend to scale the system beyond 7 nodes because the latency and number of messages you need to exchange to get consesus goes up a lot as you add notes - a conesnsus system is the opposite of a "scalable system" - as you add more nodes it gets slower!
54+
* examples
55+
* etcd recommends no more than 7 nodes https://cwiki.apache.org/confluence/display/ZOOKEEPER/Zab+vs.+Paxos
56+
* Google Chubby recommends no more than 5 nodes
57+
* Most systems recommend an _odd_ number of nodes because an odd number of N nodes tolerates as much failure as a system with N+1 nodes (the next even number) because of the majority thing
58+
* Leadership election = deciding which node gets to make decisions
59+
* typically the leader backs up all its decisions to the majority of systems
60+
* nodes vote for the leader (views, ballots, term numbers)
61+
* nodes can vote multiple times
62+
63+
64+
65+
* Paxos algorithm
66+
* multi paxos = an elected leader makes multiple decisions ("paxos" and "multi paxos" are used synonmysly
67+
* single degree paxos/vanilla paxos/classis paxos = a new leader is elected for each decision
68+
* paxos has 2 phases
69+
1. majority of nodes get together to elect a leader
70+
2. leader chooses a value and backs it up to a majority of nodes
71+
* systems which use paxos
72+
* chubby (google)
73+
* https://ai.google/research/pubs/pub27897
74+
* cassandra
75+
* how it works
76+
1. you send your write request to the leader
77+
1. leader decides on what order to write things
78+
1. leader tells other nodes what order to write in
79+
1. when majority have anssered that they have accepted taht order the leader will commit that write and acknowledge to you that the write was successful
80+
* theoritically you should get consensus for reads too but we often skip this in practice
81+
* Raft algorithm
82+
* a good well articulated simplified version of paxos specifically designed for state machine replication (which is the most common use-case for paxos)
83+
* https://raft.github.io/raft.pdf
84+
* It is a good starting point for undertanding the basics of Paxos
85+
* used by
86+
* etcd
87+
* kubernetes
88+
* ZAB (Zookeeper atomic broadcast) algorithm
89+
* very similar to multi-paxos
90+
* https://cwiki.apache.org/confluence/display/ZOOKEEPER/Zab+vs.+Paxos
91+
* Used in
92+
* Zookeeper
93+

j-lang/j-lang.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# J language
2+
3+
https://www.jsoftware.com/help/learning/contents.htm
4+
5+
```
6+
# install J
7+
$ brew cask install j
8+
9+
$ jcon # runs the interactive console
10+
$ jconsole # alias for above
11+
# Ctrl-d to exit
12+
13+
$ jhs # runs a local web server console
14+
# TODO: how to close it? ctrl-c and -d don't seem to work
15+
16+
$ jqt # runs a QT based console
17+
```
18+
19+
* array based
20+
* kind of an ASCII friendly APL
21+
* written in C but seems to have some Java GUI stuff
22+
* filetype is `.ijs`
23+
* comment marker is `NB.`
24+
* adjacency is important
25+
* calls data "nouns"
26+
* calls functions "verbs"
27+
* negative numbers have underscore prefix rather than dash e.g. `-2` is `_2` in J
28+
* `%` is the division symbol because APL used `/` to represent fold
29+
* strings are single quote delimited
30+
31+
32+
```j
33+
34+
NB. create a noun which is array [1,2,3]
35+
1 2 3
36+
37+
NB. negate the array [0, 2, 5]
38+
- 0 2 5
39+
NB. 0 _2 _5
40+
41+
NB. infix + verb
42+
1 + 3
43+
NB. 4
44+
45+
NB. infix + verb between array nouns
46+
2 3 + 4 5
47+
NB. 6 8
48+
49+
NB. division by 4/1 as rational number
50+
1 2 3 4 % 4r1
51+
NB. 1r4 1r2 3r4 1
52+
53+
NB. division by 4
54+
1 2 3 4 % 4
55+
NB. 0.25 0.5 0.75 1
56+
57+
NB. negation of a noun
58+
- 0 2 5
59+
NB. 0 _2 _5
60+
61+
echo 'hello'
62+
NB. hello
63+
64+
NB. folding a noun with +
65+
+/ 2 3 4
66+
NB. 9
67+
```
68+
69+

j-lang/j-lang.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env jcon
2+
3+
NB. vi: ft=j
4+
5+
NB. You can use J for shell scripting if you roll that way
6+
7+
echo 'hello world'
8+
9+
NB. without this line you will be dropped into the jcon interpreter when you
10+
NB. run the script
11+
exit ''

j-lang/test.ijs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
NB. comment
3+
4 5 6

nzsim.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
3+
Specifies "processes and controls" at two levels:
4+
5+
1. Baseline/essential - minimum acceptable level of controls
6+
1. _Good practice_ processes and controls
7+
8+
9+
10+
11+
There is a single set of controls for info marked:
12+
13+
"Official information"
14+
UNCLASSIFIED
15+
IN-CONFIDENCE
16+
SENSITIVE
17+
RESTRICTED
18+
19+
A further set of controls are specified for info marked:
20+
21+
CONFIDENTIAL
22+
SECRET
23+
TOP SECRET
24+
25+
26+
Some controls are marked "All classifications" so they apply to all of the above.
27+
28+
29+
> The use or non-use of good practice controls MUST be based on an agency’s
30+
> assessment and determination of residual risk related to information
31+
> security.
32+
33+
34+
The "good practice" controls are supposed to be based on risk assessment for the app. The baseline controls
35+
36+
It seems to be a big set of categoriesed controls
37+
38+
39+
Sections relevant to us
40+
41+
17
42+
22
43+
44+
45+
Accreditation and certification are not the same thing
46+
first you do certification and then get accreditation
47+
48+
49+
The agency CISO is the _certificaiton authority_
50+
The agency head (or some delegate) is the _accreditation authority_
51+
52+
53+
Possible deliverables
54+
55+
* architecture diagram of the system

0 commit comments

Comments
 (0)