Distributed Systems
46 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- 2.5 Distributed Transaction Solution: Sagahistorical
1. What Is Saga - A distributed transaction solution that guarantees eventual consistency. 2. Saga Process - There are multiple transaction participants, and each participant has two pieces of logic: a forward operation and a reverse operation. - Divide the transaction into two phases.
- 2.6 Distributed Transaction Solution: 3PChistorical
1. What Is 3PC - A distributed transaction solution that guarantees strong consistency and is an improved version of 2PC. 2. 3PC Process - Split the first phase of 2PC into two steps, so the whole transaction process has three phases: CanCommit, PreCommit, and DoCommit.
- 2.7 Distributed Transaction Solution: Two Phaseshistorical
1. What Are Two Phases - Divide the entire transaction process into two phases: preparation phase; commit phase or rollback phase. 2. Two-Phase Implementations 2.1. Database Layer - Two-Phase Implementation: 2PC. 2.2. Application Layer - Two-Phase Implementation: TCC.
- 2.8 Reliable-Message Eventual-Consistency Implementation: Local Message Tablehistorical
1. What Is a Local Message Table - Use two transactions, placing an order and then adding points, as an example. The ordering service is Service A and the points service is Service B. 1. Service A executes ordering logic. 2. After Service A successfully places the order, it sends a message to MQ. 3. Service B consumes the message and processes its local transaction.
- 2.9 Two-Phase Implementation: 2PChistorical
1. What Is 2PC - 2PC: Two-Phase Commit. - Divide the transaction into two phases. - In the first phase, the transaction manager sends prepare requests to all databases. - If all respond ok, execute commit in the second phase; if any responds fail, execute rollback in the second phase.
- 2.10 Two-Phase Implementation: TCChistorical
1. What Is TCC - 2PC is a two-phase approach at the database layer, while TCC is a two-phase approach at the application layer. - TCC: Try: attempt to execute the transaction; Confirm: confirm execution of the transaction; Cancel: cancel execution of the transaction. - In essence, it is also a two-phase transaction.
- 2.11 Best-Effort Notification Implementation: MQhistorical
1. What It Is - 1. The producer finishes executing its local transaction and sends a message to MQ. 2. MQ sends the message to the consumer. 3. The consumer consumes the message and executes its local transaction; if successful it ack's, and if it fails it nack's and requeues the message. 4. The consumer can actively call the producer's interface to query message status.
- 2.12 RocketMQ Transaction Messageshistorical
1. What Are RocketMQ Transaction Messages - Traditional local message tables depend on a message table in the database. - RocketMQ transactions encapsulate the local-message-table approach by moving the local message table into MQ, solving the atomicity problem between Producer-side message sending and local transaction execution.
- 3. Distributed Consensus Algorithmshistorical
1. What Are Distributed Consensus Algorithms - More precisely, they are consensus algorithms: making all nodes agree on something. 2. Why Consistency Problems Occur 2.1. Concurrent Client Requests - For example, in a Leader-Follower scenario: one Client, three Nodes A, B, and C. The Client asks A to write x as 1. If A considers x to be 1, then B and C must also consider the value to be 1.
- 3.1 Distributed Consensus Algorithm: Paxoshistorical
1. Basic Paxos 1.1. What Is Basic Paxos - Abbreviated as Paxos. - A distributed consensus algorithm invented by Lamport and the foundation of Raft and ZAB. 1.2. Basic Paxos Algorithm Process 1.2.1. Roles - client: request initiator; not important here. - proposer: proposal proposer, similar to a coordinator.