Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ailidani
authored and
ailidani
committed
Jan 15, 2018
1 parent
dd8e9a1
commit c98b493
Showing
14 changed files
with
490 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,123 @@ | ||
## What is Paxi? | ||
|
||
## What is WPaxos? | ||
|
||
**WPaxos** is a multileader Paxos protocol that provides low-latency and high-throughput consensus across wide-area network (WAN) deployments. Unlike statically partitioned multiple Paxos deployments, WPaxos perpetually adapts to the changing access locality through object stealing. Multiple concurrent leaders coinciding in different zones steal ownership of objects from each other using phase-1 of Paxos, and then use phase-2 to commit update-requests on these objects locally until they are stolen by other leaders. To achieve fast phase-2 commits, WPaxos adopts the flexible quorums idea in a novel manner, and appoints phase-2 acceptors to be close to their respective leaders. | ||
|
||
WPaxos (WAN Paxos) paper (first version) can be found in https://arxiv.org/abs/1703.08905. | ||
**Paxi** is the framework that implements WPaxos and other Paxos protocol variants. Paxi provides most of the elements that any Paxos implementation or replication protocol needs, including network communication, state machine of a key-value store, client API and multiple types of quorum systems. | ||
|
||
*Warning*: Paxi project is still under heavy development, with more features and protocols to include. Paxi API may change too. | ||
|
||
## What is Paxi? | ||
|
||
**Paxi** is the framework that implements WPaxos and other Paxos protocol variants. Paxi provides most of the elements that any Paxos implementation or replication protocol needs, including network communication, state machine of a key-value store, client API and multiple types of quorum systems. | ||
## What is WPaxos? | ||
|
||
Warning: Paxi project is still under heavy development, with more features and protocols to include. Paxi API may change too. | ||
**WPaxos** is a multileader Paxos protocol that provides low-latency and high-throughput consensus across wide-area network (WAN) deployments. Unlike statically partitioned multiple Paxos deployments, WPaxos perpetually adapts to the changing access locality through object stealing. Multiple concurrent leaders coinciding in different zones steal ownership of objects from each other using phase-1 of Paxos, and then use phase-2 to commit update-requests on these objects locally until they are stolen by other leaders. To achieve fast phase-2 commits, WPaxos adopts the flexible quorums idea in a novel manner, and appoints phase-2 acceptors to be close to their respective leaders. | ||
|
||
WPaxos (WAN Paxos) paper (first version) can be found in https://arxiv.org/abs/1703.08905. | ||
|
||
## What is included? | ||
|
||
Algorithms: | ||
- [x] Classical multi-Paxos | ||
- [x] [Flexible Paxos](https://dl.acm.org/citation.cfm?id=3139656) | ||
- [x] [WPaxos](https://arxiv.org/abs/1703.08905) | ||
- [x] [EPaxos](https://dl.acm.org/citation.cfm?id=2517350) | ||
- [x] KPaxos (Static partitioned Paxos) | ||
- [ ] [Vertical Paxos](https://www.microsoft.com/en-us/research/wp-content/uploads/2009/08/Vertical-Paxos-and-Primary-Backup-Replication-.pdf) | ||
- [ ] [WanKeeper](http://ieeexplore.ieee.org/abstract/document/7980095/) | ||
|
||
Features: | ||
- [x] Benchmarking | ||
- [x] Linerizability checker | ||
- [ ] Transactions | ||
- [ ] Dynamic quorums | ||
- [ ] Fault injection | ||
- [ ] Linerizability checker | ||
|
||
|
||
# How to build | ||
|
||
1. Install [Go 1.9](https://golang.org/dl/). | ||
2. [Download](https://github.com/wpaxos/paxi/archive/master.zip) WPaxos source code from GitHub page or use following command: | ||
2. Use `go get` command or [Download](https://github.com/wpaxos/paxi/archive/master.zip) Paxi source code from GitHub page. | ||
``` | ||
go get github.com/ailidani/paxi | ||
``` | ||
|
||
3. Compile everything. | ||
3. Compile everything from `paxi/bin` folder. | ||
``` | ||
cd github.com/ailidani/paxi/bin | ||
./build.sh | ||
``` | ||
|
||
After compile, Golang will generate 4 executable files under `bin` folder. | ||
* `master` is the easy way to distribute configurations to all replica nodes. | ||
* `server` is one replica instance. | ||
* `client` is a simple benchmark that generates read/write reqeust to servers. | ||
* `cmd` is a command line tool to test Get/Set requests. | ||
* `master` is the alternative way to distribute configurations to all replica nodes. | ||
|
||
|
||
# How to run | ||
|
||
Each executable file expects some parameters which can be seen by `-help` flag, e.g. `./master -help`. | ||
Each executable file expects some parameters which can be seen by `-help` flag, e.g. `./server -help`. | ||
|
||
1. There are two ways to manage the system configuration. | ||
|
||
(1) Use a [configuration file](https://github.com/ailidani/paxi/blob/master/bin/config.json) with `-config FILE_PATH` option, default to "config.json" when omit. | ||
|
||
1. Start master node with 6 replicas running WPaxos: | ||
(2) Start a master node with 6 replica nodes running WPaxos: | ||
``` | ||
./master.sh -n 6 -algorithm "wpaxos" | ||
``` | ||
|
||
2. Start 6 servers with different zone id and node ids. | ||
2. Start 6 servers with different ids in format of "ZONE_ID.NODE_ID". | ||
``` | ||
./server -id 1.1 -master 127.0.0.1 & | ||
./server -id 1.2 -master 127.0.0.1 & | ||
./server -id 2.1 -master 127.0.0.1 & | ||
./server -id 2.2 -master 127.0.0.1 & | ||
./server -id 3.1 -master 127.0.0.1 & | ||
./server -id 3.2 -master 127.0.0.1 & | ||
./server -id 1.1 & | ||
./server -id 1.2 & | ||
./server -id 2.1 & | ||
./server -id 2.2 & | ||
./server -id 3.1 & | ||
./server -id 3.2 & | ||
``` | ||
|
||
3. Start benchmarking client with 10 threads, 1000 keys, 50 percent conflicting commands and run for 60 seconds in 1 round. | ||
3. Start benchmarking client that connects to server ID 1.1 and benchmark parameters specified in [benchmark.json](https://github.com/ailidani/paxi/blob/master/bin/benchmark.json). | ||
``` | ||
./client -id 1.1 -master 127.0.0.1 -bconfig benchmark.json | ||
./client -id 1.1 -bconfig benchmark.json | ||
``` | ||
|
||
The algorithms can also be running in **simulation** mode, where all nodes are running in one process and transport layer is replaced by Go channels. Check [`simulation.sh`](https://github.com/ailidani/paxi/blob/master/bin/simulation.sh) script on how to run. | ||
|
||
|
||
# How to implement algorithms in Paxi | ||
|
||
Replication algorithm in Paxi follows the message passing model, where several message types and their handle function are registered. | ||
Replication algorithm in Paxi follows the message passing model, where several message types and their handle function are registered. We use [Paxos](https://github.com/ailidani/paxi/tree/master/paxos) as an example for our step-by-step tutorial. | ||
|
||
1. Define messages, register with gob in `init()` function if using gob codec. | ||
1. Define messages, register with gob in `init()` function if using gob codec. As show in [`msg.go`](https://github.com/ailidani/paxi/blob/master/paxos/msg.go). | ||
|
||
2. Define handle function for each message type. | ||
2. Define a `Replica` structure embeded with `paxi.Node` interface. | ||
```go | ||
type Replica struct { | ||
paxi.Node | ||
*Paxos | ||
} | ||
``` | ||
|
||
Define handle function for each message type. For example, to handle client `Request` | ||
```go | ||
func (r *Replica) handleRequest(m paxi.Request) { | ||
if r.Config().Adaptive { | ||
if r.Paxos.IsLeader() || r.Paxos.Ballot() == 0 { | ||
r.Paxos.HandleRequest(m) | ||
} else { | ||
go r.Forward(r.Paxos.Leader(), m) | ||
} | ||
} else { | ||
r.Paxos.HandleRequest(m) | ||
} | ||
|
||
} | ||
``` | ||
|
||
3. Register the messages with their handle function using `Node.Register(interface{}, func())` interface. | ||
3. Register the messages with their handle function using `Node.Register(interface{}, func())` interface in `Replica` constructor. | ||
|
||
For sending messages, use `Send(to ID, msg interface{})`, `Broadcast(msg interface{})` functions in Node.Socket. | ||
Replica use `Send(to ID, msg interface{})`, `Broadcast(msg interface{})` functions in Node.Socket to send messages. | ||
|
||
For data-store related functions check db.go file. | ||
For data-store related functions check `db.go` file. | ||
|
||
For quorum types check quorum.go file. | ||
For quorum types check `quorum.go` file. | ||
|
||
Client uses a simple RESTful API to submit requests. GET method with URL "http://ip:port/key" will read the value of given key. POST method with URL "http://ip:port/key" and body as the value, will write the value to key. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.