Distributed durable unique 64bit ID server
ticketd is a distributed durable unique 64bit ID server. The raft protocol is used for consistency.
It uses LMDB for storing data, H2O for HTTP, and raft for concensus.
ticketd is completely written in C.
ticketed opens 2 ports as follows:
- HTTP client traffic
- Peer to peer traffic using a ticketd specific binary protocol
Examples below make use of the excellent httpie
Node A starts a new cluster:
ticketd start --id 1 --peer_port 9001 --http_port 8001
Node B joins the new cluster via A:
ticketd join 127.0.0.1:9001 --id 2 --peer_port 9002 --http_port 8002
Node C joins the new cluster via A:
ticketd join 127.0.0.1:9001 --id 3 --peer_port 9003 --http_port 8003
http --ignore-stdin POST 127.0.0.1:8001
HTTP/1.1 200 OK
Connection: keep-alive
Date: Sat, 08 Aug 2015 10:02:07 GMT
Server: h2o/1.3.1
transfer-encoding: chunked
823378840
If we try to obtain an identifier from a non-leader, then ticketd will respond with a 301 redirect reponse. The redirect shows the location of the current leader.
Forcing the client to redirect to the leader means that future requests will be faster (ie. no delays are caused by proxying the request).
curl --request POST -i -L 127.0.0.1:8003
HTTP/1.1 301 Moved Permanently
Date: Thu, 13 Aug 2015 16:03:02 GMT
Server: h2o/1.3.1
Connection: close
location: http://127.0.0.1:8001/
HTTP/1.1 200 OK
Date: Thu, 13 Aug 2015 16:03:02 GMT
Server: h2o/1.3.1
Connection: keep-alive
transfer-encoding: chunked
1272863780
If the leader isn't available, then we respond with a 503.
curl --request POST -i -L 127.0.0.1:8003
HTTP/1.1 503 Leader unavailable
Date: Sat, 15 Aug 2015 05:54:38 GMT
Server: h2o/1.3.1
Connection: keep-alive
content-length: 0
$ make libuv
$ make libh2o
$ make