This project demonstrates a simple network file system implemented in Go. It explores low-level networking concepts and provides a practical example of how to build a distributed file system. The system operates in two modes: Master and Replica.
- Master and Replica Modes: The program can be run in either master or replica mode, allowing for flexible configurations based on your needs.
- Replica Requirement: At least one replica must be running before starting the master node. This ensures that the master can effectively manage and coordinate file operations across the replicas.
- Low-Level Networking Exploration: The primary goal of this project is to delve into low-level networking concepts in Go, providing insights into how network file systems operate.
- Go (version 1.19 or higher)
- Basic understanding of Go programming and networking concepts
- Clone the repository:
git clone https://github.com/yourusername/network-file-system.git cd network-file-system
- Run one or more replica instances providing
--port
and--storage-root
cli argumentsgo run main.go replica --port=XXXX --storage-root=/path/for/files
- Run the master instance which starts an http server to interact with the NFS
go run main.go master --peers=comma-seperated-list-of-ip-ports --storage-root=/path/for/files --http-port=XXXX
- POST / Which is the main file upload endpoint and expects multipart data,
data is replicated to all available replicas instances
- GET /byname?filename= This endpoint expects a previously uplocaded file and a randomly selected replica is used to
stream the (if available) to the client
- Create to replicas and one master instance and post a file to the master
start_servers.webm
- Call a GET request to read the uploaded file which is streamed from a random replica instance