You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: distributed/clock.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@
12
12
- Cant distinguish concurrent event
13
13
14
14
### Vector Clock
15
-
- Just array of lamport
15
+
- Just an array of Lamport
16
16
- CRDT
17
17
- Causally Related
18
18
- One must be less and others equal or less
@@ -21,7 +21,7 @@
21
21
22
22
### Interval Tree Clock
23
23
- Version Vectors or Interval Tree Clocks
24
-
- All unique identifier coming together modifying
24
+
- All unique identifiers coming together modifying
25
25
- We need to track causality.
26
26
- In a nutshell, given two events modifying a given piece of data and originating from different nodes in the system, we want to know if one of those events could have influenced the other one, or in other words if one of those events `happened before` the other one.
Copy file name to clipboardExpand all lines: distributed/distributed systems.md
+19-19
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Distributed Systems
2
2
3
-
A distributed system is basically a network of autonomous systems/servers connected using a middleware which can share resources, capabilities, files and so on.
3
+
A distributed system is a network of autonomous systems/servers connected using a middleware that can share resources, capabilities, files, and so on.
4
4
5
5
6
6
Distributed System Categories
@@ -12,10 +12,10 @@ Distributed System Categories
12
12
6. Distributed Ledgers
13
13
14
14
15
-
### Concensus
15
+
### Consensus
16
16
- State machine replication based on log
17
17
- State Machine Replication Principle:
18
-
-Physical logging means logging the contents of each row that is changed.
18
+
- Physical logging means logging the contents of each row that is changed.
19
19
- Logical logging means logging not the changed rows but the SQL commands that lead to the row changes
20
20
21
21
- Symmetric
@@ -26,7 +26,7 @@ Distributed System Categories
26
26
- Raft
27
27
28
28
- Distributed Data Stores
29
-
- The concensus part can be separated as a service with ZooKeeper
29
+
- The consensus part can be separated as a service with ZooKeeper
30
30
- Consistency Model
31
31
- ACID
32
32
- eg. HBase, Couchbase, Redis, Zookeeper.
@@ -42,7 +42,7 @@ Distributed System Categories
42
42
43
43
- Distributed Application
44
44
- Bittorent
45
-
- Trackerless torrent: Protocol that did not rely on centralized trackers for gathering metadata and finding peers, but instead uses new algorithms.
45
+
- Trackerless torrent: Protocol that does not rely on centralized trackers for gathering metadata and finding peers, but instead uses new algorithms.
46
46
- One such instance is Kademlia `Mainline DHT`, a distributed hash table (DHT) that allows you to find peers through other peers.
47
47
- In effect, each user performs a tracker’s duties.
48
48
@@ -54,12 +54,12 @@ Distributed System Categories
54
54
55
55
- Preserves symmetry and avoids having a centralized registry for storing membership and node liveness information.
56
56
57
-
- Data replication is at the heart of making data durable and available in the presence of hardware failures such as machine crashes, disk failures, network partitions and clock skews.
57
+
- Data replication is at the heart of making data durable and available in the presence of hardware failures such as machine crashes, disk failures, network partitions, and clock skews.
58
58
59
59
- Popular implementations include those from `etcd` and `consul`.
60
60
- Next-generation distributed databases such as YugaByte DB, CockroachDB and TiDB use Raft for both leader election and data replication
61
61
62
-
- The final value has to determined non-deterministically using heuristics such as Last-Writer-Wins (LWW) and Conflict Free Replicated Data Types (CRDT).
62
+
- The final value has to be determined non-deterministically using heuristics such as Last-Writer-Wins (LWW) and Conflict Free Replicated Data Types (CRDT).
63
63
64
64
- Distributed systems are kept weakly consistent for performance
65
65
- Input Speculation
@@ -71,12 +71,12 @@ Distributed System Categories
71
71
- But another possible approach is optimistic replication, where all concurrent updates are allowed to go through, with inconsistencies possibly created, and the results are merged or "resolved" later.
72
72
- In this approach, consistency between the replicas is eventually re-established via "merges" of differing replicas.
73
73
- Operation based
74
-
- Statebased
74
+
- State-based
75
75
- However, there are practical differences.
76
-
- State-based CRDTs are often simpler to design and to implement; their only requirement from the communication substrate is some kind of gossip protocol.
76
+
- State-based CRDTs are often simpler to design and implement; their only requirement from the communication substrate is some kind of gossip protocol.
77
77
- Their drawback is that the entire state of every CRDT must be transmitted eventually to every other replica, which may be costly.
78
78
- In contrast, operation-based CRDTs transmit only the update operations, which are typically small.
79
-
- However, operation-based CRDTs require guarantees from the communication middleware;that the operations are not dropped or duplicated when transmitted to the other replicas, and that they are delivered in causal order.
79
+
- However, operation-based CRDTs require guarantees from the communication middleware;that the operations are not dropped or duplicated when transmitted to the other replicas, and that they are delivered in causal order.
80
80
81
81
82
82
### Network Time Protocol
@@ -86,7 +86,7 @@ Distributed System Categories
86
86
- It is very useful in situations like bank transactions. Assume the following situation without the presence of NTP. - Suppose you carry out a transaction, where your computer reads the time at 2:30 PM while the server records it at 2:28 PM.
87
87
- The server can crash very badly if it’s out of sync.
-[Distributed System Design with Zookeeper](https://medium.com/@bikas.katwal10zookeeper-introduction-designing-a-distributed-system-using-zookeeper-and-java-7f1b108e236)
Copy file name to clipboardExpand all lines: distributed/raft.md
+2-3
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,6 @@ The six fundamental operations of Raft are:
20
20
- Configuration Changes
21
21
- Adding or removing servers
22
22
23
-
24
23
Each server in the cluster can be in one of three states:
25
24
- Follower state
26
25
- Leader state
@@ -32,7 +31,7 @@ Each server maintains its current term and has only two RPCs and three persisten
32
31
33
32

34
33
35
-
The leader must regularly send empty heartbeats to all followers in the form of empty append entries. The election timeout is the span of time for choosing a leader, and safety is the liveliness of the leader election. A random timeout is eventually selected to complete the election.
34
+
The leader must regularly send empty heartbeats to all followers in the form of empty append entries. The election timeout is the period for choosing a leader, and safety is the liveliness of the leader election. A random timeout is eventually selected to complete the election.
36
35
37
36
### Logs
38
37
The committed log is persisted on disk on a majority of the servers. The leader never overwrites the log but appends to it. All future leaders must have all committed logs. The leader will not respond until the command has been logged, committed, and executed by the leader's state machine. Linearizability is guaranteed with a unique key. Configuration changes must go through two phases.
@@ -61,4 +60,4 @@ A term is a duration for which a specific server acts as the leader. A new elect
Copy file name to clipboardExpand all lines: language/c++/cast.md
+15-15
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
```c++
8
8
9
-
// Used to explicitly find out if casted
9
+
// Used to explicitly find out if cast
10
10
a = f;
11
11
a = static_cast<int>(f);
12
12
@@ -16,28 +16,28 @@ class Int {
16
16
int x;
17
17
public:
18
18
Int(int x=0) {
19
-
cout << "conversion constructor" << endl;
20
-
}
19
+
cout << "conversion constructor" << endl;
20
+
}
21
21
operator string ( ) {
22
-
cout << "conversion operator" << endl;
22
+
cout << "conversion operator" << endl;
23
23
return to_string(x);
24
-
}
24
+
}
25
25
}
26
26
27
27
int main() {
28
-
Int obj(3);
28
+
Int obj(3);
29
29
30
-
// Compile time casting
31
-
string str = obj;
32
-
obj = 20;
30
+
// Compile time casting
31
+
string str = obj;
32
+
obj = 20;
33
33
}
34
34
35
35
36
36
// Prevents char to int type cast at compile time
37
-
// In every case provides better security than cstyle (void *) cast
37
+
// In every case provides better security than c-style (void *) cast
38
38
39
39
// For compatible type conversion, such as float to int.
40
-
// For conversion operator and conversion constructors.
40
+
// For conversion operators and conversion constructors.
41
41
// To avoid unrelated pointer conversion.
42
42
// Avoids derived to private base pointer conversion.
43
43
// Use for all up-cast but never use for confused down-cast because there are no runtime checks performed
@@ -48,12 +48,12 @@ int main() {
48
48
49
49
- Const Cast
50
50
- To remove const, volatile
51
-
- When a thirdparty library is taking a `non-const` param and not changing it
51
+
- When a third-party library is taking a `non-const` param and not changing it
52
52
53
53
- Dynamic Cast
54
-
- In order to use it, must have `virtual function` in base class.
54
+
- To use it, must have `virtual function` in the base class.
55
55
- Work only on polymorphic base class (at least one virtual function in base class) because it uses this information in runtime to decide about wrong down-cast
56
56
- It is used for up-cast (D to B) and down-cast (B to D), but it is mainly used for correct downcast
57
-
- Using this cast has run time overhead, because it checks object types at run time using `RTTI` (Run Time Type Information)
58
-
- If we are sure that we will never cast to wrong object then we should always avoid this cast and use `static_cast`
57
+
- Using this cast has run time overhead because it checks object types at run time using `RTTI` (Run Time Type Information)
58
+
- If we are sure that we will never cast to the wrong object then we should always avoid this cast and use `static_cast`
-Other language has compiletime and run-time prevention of threading and memory corruption issue, while they abstract away my access to machine. But, C family language provides access with little in the way of safeguard.
3
-
- C++ has local dialects that prevent understanding codebase, where rust has strict guideline
2
+
-Another language has compile-time and run-time prevention of threading and memory corruption issues, while they abstract away my access to the machine. However, the C family language provides access with little in the way of safeguarding.
3
+
- C++ has local dialects that prevent understanding codebase, whereas Rust has a strict guideline
4
4
5
5
- Memory barriers
6
-
- Can be used to prevent compilers to reorder operations, instructions for instructionn level parallelism
6
+
- Can be used to prevent compilers from reordering operations, instructions for instruction-level parallelism
0 commit comments