Tương lai: thêm VPS làm node thứ 3
Vì sao cần thêm VPS làm node thứ 3
Phần tiêu đề “Vì sao cần thêm VPS làm node thứ 3”Setup PC ↔ Laptop hiện tại có limitation:
- Cần ≥1 peer online để sync — nếu cả 2 máy tắt cùng lúc, data trapped
- Đi công tác dài + tắt PC → laptop work alone, changes queue cho đến khi PC bật lại
- Nếu cả 2 máy fail (vd thiên tai, trộm) → mất data — không có 3rd copy
VPS as 3rd peer giải quyết:
- ✅ Always-on → laptop changes sync ngay lên VPS, không phải đợi PC
- ✅ Off-site backup → cloud copy nếu cả 2 máy fail
- ✅ 3-way mesh → bất kỳ máy nào cũng có thể là peer
Đề xuất kiến trúc
Phần tiêu đề “Đề xuất kiến trúc”PC ←─────── Syncthing TLS ────────→ Laptop ↑ ↑ │ │ └───── Syncthing TLS ──→ VPS ←─── Syncthing TLS ──┘ (always-on, cloud peer)VPS cài Syncthing daemon 24/7. Pair với cả PC + Laptop.
Các lựa chọn VPS
Phần tiêu đề “Các lựa chọn VPS”Option A: Oracle Always Free (free forever)
Phần tiêu đề “Option A: Oracle Always Free (free forever)”- 4 OCPU ARM Ampere + 24 GB RAM + 200 GB storage = $0/month
- ⚠ Idle reclaim: 7-day CPU < 20% (95th percentile) → instance reclaimed
- ⚠ Out-of-capacity: ARM instances khó allocate trong popular regions
- Workaround: cron CPU spike + region selection (Mumbai, Tokyo có capacity tốt)
Option B: Hetzner CX21 ($5.83/month)
Phần tiêu đề “Option B: Hetzner CX21 ($5.83/month)”- 2 CPU + 4 GB RAM + 40 GB SSD
- 100% reliable, no idle reclaim
- Fast network (1 Gbps)
- EU + US locations
Option C: DigitalOcean Droplet ($6/month)
Phần tiêu đề “Option C: DigitalOcean Droplet ($6/month)”- 1 CPU + 1 GB RAM + 25 GB SSD (basic)
- Standard provider, well-supported
Option D: Existing VPS bạn đã có
Phần tiêu đề “Option D: Existing VPS bạn đã có”Nếu có VPS chạy services khác (vd web hosting), cài Syncthing daemon song song.
Các bước cài đặt (tổng quát)
Phần tiêu đề “Các bước cài đặt (tổng quát)”- Provision VPS — chọn provider, deploy Ubuntu 22.04+ LTS
- Install Syncthing:
Terminal window sudo apt update && sudo apt install -y syncthing - Configure Syncthing:
- Generate config:
syncthing generate - GUI bind 0.0.0.0:8384 + set strong password (Settings → User & Password)
- Allow firewall ports 22000 TCP+UDP, 21027 UDP
- Generate config:
- Auto-start daemon:
Terminal window sudo systemctl enable --now syncthing@<user> - Reverse proxy GUI (optional, recommended for security):
- Cloudflare Tunnel hoặc Caddy → expose
syncthing.<domain>với HTTPS
- Cloudflare Tunnel hoặc Caddy → expose
- Pair với PC + Laptop:
- Add VPS Device ID vào cả 2 máy
- Share folders với VPS device
- Initial sync từ PC/Laptop → VPS:
- Có thể tốn time tùy folder size + VPS bandwidth
Tình huống sử dụng
Phần tiêu đề “Tình huống sử dụng”Travel scenario
Phần tiêu đề “Travel scenario”Trước đi: PC ←sync→ Laptop (state same) ↓ sync VPS (3rd copy)
Đi công tác (tắt PC): Laptop work tiếp, edit files ↓ sync via internet VPS (receives changes)
Về nhà bật PC: PC ←sync from VPS→ has all laptop changes 3 peers converge→ Không phải đợi PC bật để laptop sync về. VPS = always-receiving peer.
Disaster recovery
Phần tiêu đề “Disaster recovery”Cả 2 máy fail (vd hỏa hoạn) → VPS có copy → mua máy mới, install Syncthing, pair với VPS Device ID → recover toàn bộ data.
Multi-device extension
Phần tiêu đề “Multi-device extension”Thêm máy thứ 3 (vd workstation văn phòng), thứ 4 (vd phone via Syncthing Android) — pair với VPS, all sync via VPS.
Cân nhắc đánh đổi
Phần tiêu đề “Cân nhắc đánh đổi”| Aspect | 2-peer (PC+Laptop) | 3-peer (+VPS) |
|---|---|---|
| Cost | $0 | $0-6/month (depend on provider) |
| Always-on | ❌ | ✅ |
| Disaster recovery | ❌ | ✅ |
| Setup complexity | Simple | Medium |
| Bandwidth usage | LAN only (if cùng nhà) | Cloud upload mỗi change |
| Privacy | 100% local | VPS provider has access (encrypted blocks though) |
Lưu ý mã hoá
Phần tiêu đề “Lưu ý mã hoá”Syncthing v1.18+ supports untrusted devices mode:
- Device ID added with
untrusted: trueflag - Device receives encrypted blocks, không decrypt được
- Storage cloud peer KHÔNG nhìn thấy plaintext
Recommend cho VPS hosting cloud — trust mode untrusted cho safety.
Tránh idle reclaim (Oracle)
Phần tiêu đề “Tránh idle reclaim (Oracle)”Cron job spike CPU + network để Oracle không reclaim:
0 */6 * * * stress -c 1 --timeout 30s 2>&1 || true0 */6 * * * curl -s https://example.com > /dev/nullHoặc Syncthing scan + relay traffic tự nhiên đủ activity (varies).
Em sẽ kiểm chứng + viết chương chi tiết
Phần tiêu đề “Em sẽ kiểm chứng + viết chương chi tiết”Bước tiếp theo
Phần tiêu đề “Bước tiếp theo”- Architecture — current 2-peer design
- AI agent prompts — apply VPS setup khi ready