A cloud-based file synchronization service, implementing RAFT consensus for fault tolerance and using gRPC for client-server communication
MIT License
Surfstore is a cloud-based file storage service modeled after Dropbox, allowing users to sync files to and from the cloud. It consists of a client and server architecture that communicates via gRPC.
Surfstore comprises of the following components:
Surfstore implements the RAFT consensus algorithm to ensure consistent metadata across MetaStore replicas, maintaining service integrity during failures. It utilizes consistent hashing for mapping blocks to BlockStores. Each BlockStore's address is hashed using SHA-256, creating a hash ring in the MetaStore.
Surfstore's sync engine is designed to manage file synchronization efficiently, inspired by Dropbox's three-tree approach:
The Synced Tree is crucial since it acts as a merge base in version control systems, allowing Surfstore to derive the correct sync behavior by distinguishing between local edits and remote updates.
For exact project specifications, check out the doc directory.
index.db
file to build the Local Tree, representing the last observed state on disk.# Ensure Go 1.22 or higher is installed on your machine.
$ go version
# install Protocol Compiler Plugins for Go
$ go install google.golang.org/protobuf/cmd/[email protected]
$ go install google.golang.org/grpc/cmd/[email protected]
# Add the Go binaries to your PATH
$ export PATH="$PATH:$(go env GOPATH)/bin"
# Clone the repository
$ git clone github.com/mayank-02/surfstore.git
cd surfstore
# Install dependencies
$ go mod tidy
$ protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative pkg/surfstore/surfstore.proto
# Run the tests
$ make test
To individually run the servers and client, follow the instructions below:
make run-blockstore
make IDX=0 run-raft
go run cmd/SurfstoreClientExec/main.go -f config.json <baseDir> <blockSize>
where <baseDir>
is the path to your base directory and <blockSize>
is the desired block size for file fragmentation.make TEST_REGEX=Test specific-test
make clean
RaftTestingInterface
for simulating node crashes and network partitions.Crash()
, MakeServerUnreachableFrom()
, and Restore()
help test server responses and RAFT protocol adherence.For more details, check out pkg/test/raft_test.go and pkg/test/raft_client_test.go.
This project is licensed under the MIT License - see the LICENSE file for details.