Sistem penyimpanan file terdistribusi dengan replication, fault tolerance, dan smart-node detection, dikembangkan sebagai proyek akhir mata kuliah Sistem Terdistribusi.
Project ini menggunakan pendekatan arsitektur multi-service:
- server/ → seluruh backend (Naming Service, Storage Nodes, Database)
- client/ → Web dashboard (Next.js + React)
- File disimpan di 3 node penyimpanan:
sn-1→ Main Storage Node (Port 8001)sn-2→ Replica Storage Node (Port 8002)sn-3→ Backup Storage Node (Port 8003)
- Setiap upload ke sn-1 → otomatis direplikasi ke sn-2 dan sn-3
- Replikasi berjalan parallel menggunakan async/await
- Metadata tersimpan di MySQL
- Response mencakup status replikasi per node
- Upload tetap berhasil meski 1-2 node DOWN
- File yang gagal direplikasi masuk replication_queue
- Sistem tidak rollback jika ada node yang gagal
- Tracking lengkap di database
- Background job berjalan setiap 30 detik
- Otomatis detect node yang kembali UP
- Trigger recovery untuk sync file yang pending
- Update status di replication_queue (PENDING → COMPLETED)
- Endpoint untuk trigger recovery on-demand
- Berguna untuk testing dan maintenance
- API:
POST /nodes/{nodeId}/recover
- Database table untuk tracking replikasi
- Status: PENDING, IN_PROGRESS, COMPLETED, FAILED
- Retry count dan error message
- Monitoring via API
- File metadata di MySQL (naming service)
- Tracking lokasi file di setiap node
- Checksum SHA256 untuk validasi
- API untuk list files dengan info replicas
Naming service memilih node terbaik berdasarkan:
- Status UP
- Latency terendah
- Ketersediaan file
Frontend menampilkan (masih mock data):
- Status node (UP/DOWN)
- Latency node
- File explorer
- Statistik replikasi
- Log aktivitas
root/
│
├── client/
│ ├── public/
│ ├── src/
│ ├── package.json
│ └── Dockerfile
│
└── server/
├── docker-compose.yml
│
├── naming-service/
│ ├── main.go
│ ├── go.mod
│ └── Dockerfile
│
└── storage-node/
├── sn-1/
├── sn-2/
└── sn-3/
| Layer | Teknologi |
|---|---|
| Naming Service | Go (Gin) |
| Storage Nodes | Python FastAPI |
| Database | MySQL 8 |
| Frontend | Next.js + React |
| DevOps | Docker Compose (opsional) |
Menyimpan info node:
- status
- latency
- heartbeat
Metadata global file:
- file_key
- nama asli
- ukuran
Lokasi file pada node.
Backlog replikasi ketika node DOWN.
- Setup Database:
cd ~/projects/dfs/server
mysql -u dfs_user -padmin123 dfs_meta < naming-service/schema.sql- Make Scripts Executable:
chmod +x *.sh- Start All Services:
./start-all.sh- Test Upload:
./test-upload.sh- Check Status:
./check-status.sh- Stop Services:
./stop-all.shcd server
start-all.bat # Start services
test-upload.bat # Test upload
check-status.bat # Check status- WSL/Linux: Lihat server/README_LINUX.md atau server/SETUP_WSL.md
- Windows: Lihat server/QUICK_START_ID.md
- Instalasi dari awal: Lihat INSTALLATION.md
curl -X POST http://localhost:8080/upload -F "file=@test.jpg"curl -O http://localhost:8080/download/{FILE_ID}curl -X DELETE http://localhost:8080/files/{FILE_ID}# Check node latencies
curl http://localhost:8080/nodes
# Upload will route to node with lowest latency
curl -X POST http://localhost:8080/upload -F "file=@test.jpg"# Stop node-2 (CTRL+C)
# Upload file (will route to other node)
curl -X POST http://localhost:8080/upload -F "file=@test.jpg"
# Check replication queue
curl http://localhost:8080/replication-queue# Start node-2 kembali
# Wait 30 seconds
# Check logs: "Auto-recovered ... to node-2"# List all files with replicas
curl http://localhost:8080/files
# Check nodes status with latency
curl http://localhost:8080/nodes
# Monitor replication queue
curl http://localhost:8080/replication-queuecd server
test-routing.bat # Test upload/download routing
test-latency.bat # Test latency-based selection
test-delete-routing.bat # Test delete from all nodesLihat server/TESTING_REPLICATION.md dan server/ROUTING_FEATURES.md untuk dokumentasi lengkap.
- server/IMPLEMENTATION_SUMMARY.md - Overview implementasi lengkap
- server/ROUTING_FEATURES.md - Routing & latency-based selection
- server/REPLICATION_FEATURES.md - Automated replication
- server/QUICK_START_ID.md - Quick start guide (Bahasa Indonesia)
- server/TESTING_REPLICATION.md - Testing guide dengan 5 skenario
- server/TROUBLESHOOTING.md - Troubleshooting guide
- server/CHANGELOG.md - Version history
- server/naming-service/schema.sql - Database schema
- client/README.md - Frontend documentation
- Automated replication (sn-1 → sn-2, sn-3)
- Fault tolerance (upload tetap berhasil meski node DOWN)
- Replication queue (tracking di database)
- Auto-recovery (background job 30s interval)
- Manual recovery (API endpoint)
- Metadata management (MySQL)
- Upload/download routing via naming service
- Latency-based node selection
- Smart routing dengan automatic failover
- Monitoring endpoints
- Testing scripts (Windows batch files)
- Complete documentation
- Semua operasi file via naming service (port 8080)
- Client tidak perlu tahu alamat storage node
- Centralized control dan monitoring
- API:
POST /upload,GET /download/{fileKey},DELETE /files/{fileKey}
- Background job ukur latency setiap 30 detik
- Automatic pilih node tercepat untuk upload
- Automatic pilih node tercepat untuk download
- Database simpan latency_ms per node
- Optimal performance dan load distribution
- Frontend integration dengan backend API
- Checksum validation setelah replikasi
- File compression
- Encryption
- Backend Gin / FastAPI ✅
- Database & Replication Logic ✅
- DevOps & Testing Scripts ✅
- Frontend Next.js (partial - mock data)
Bebas digunakan untuk pembelajaran dan tugas akademik.