Un CDN (Content Delivery Network) développé en Go, conçu pour accélérer la distribution de contenu web. Il inclut la mise en cache, l’équilibrage de charge et la surveillance des performances.
groupe 3 : Adrien ALBUQUERQUE, Thomas BUISSON, Matteo COURQUIN, Thanh-long PHAM
➜ Redirection dynamique des requêtes
✔ Cache LRU en mémoire
✔ Cache Redis pour une meilleure scalabilité
✔ Round Robin
✔ Weighted Round Robin
✔ Least Connections
✔ Rate Limiting (limitation de débit)
✔ Protection DDoS
✔ Headers HTTP sécurisés
✔ Métriques Prometheus
✔ Visualisation avec Grafana
✔ Logging avancé avec Logrus
📌 Outils nécessaires :
🔹 Docker & Docker Compose
🔹 Go 1.23+ (pour développement local)
Démarrer avec hot-reload :
docker compose -f ./docker-compose.dev.yml up -d
🌍 Accès : http://localhost:8080
📊 Métriques : http://localhost:8080/metrics
Lancer une version optimisée :
docker compose -f ./docker-compose.prod.yml up -d
🌍 Accès : http://localhost:8081
📊 Métriques : http://localhost:8081/metrics
cd front
npm install
npm run dev
📊 Grafana : http://localhost:3000
(admin/admin)
📡 Prometheus : http://localhost:9090
🗄️ Redis : localhost:6379
app/
├── internal/
│ ├── cache/ # Gestion du cache (implémentation LRU et intégration Redis)
│ ├── loadbalancer/ # Algorithmes de répartition de charge
│ └── middleware/ # Middlewares pour la sécurité et le monitoring
├── pkg/
│ └── config/ # Fichiers de configuration de l’application
└── main.go # Point d’entrée de l’application
📁 Fichier : internal/cache/cache.go
✔ Gestion via hashicorp/golang-lru
✔ Capacité ajustable
✔ Cache uniquement les requêtes GET
➜ Vider tout le cache
curl -X POST http://localhost:8080/cache/purge
📁 Fichier : internal/loadbalancer/loadbalancer.go
✔ Round Robin (répartition cyclique)
✔ Weighted Round Robin (distribution pondérée)
✔ Least Connections (priorité au serveur le moins chargé)
🔹 POST /register
➜ Inscription
🔹 POST /login
➜ Connexion
📥 POST /api/files
➜ Upload
📤 GET /api/files/:id
➜ Récupération
🗑️ DELETE /api/files/:id
➜ Suppression
📁 POST /api/folders
➜ Création
📜 GET /api/folders/:id
➜ Liste du contenu
🗑️ DELETE /api/folders/:id
➜ Suppression
📊 GET /metrics
➜ Statistiques Prometheus
💓 GET /health
➜ État du service
📡 GET /ready
➜ Vérification de disponibilité
✔ Temps de réponse (http_duration_seconds
)
✔ Total requêtes par endpoint (http_requests_total
)
✔ Taux de succès & erreurs
✔ Rate Limiting (100 req/s par défaut)
✔ Protection XSS & Injection SQL
✔ Headers Sécurisés
X-Frame-Options
X-Content-Type-Options
X-XSS-Protection
Content-Security-Policy
Strict-Transport-Security
1️⃣ Forkez le repo
2️⃣ Créez une branche :
git checkout -b feature/nouvelle-fonction
3️⃣ Ajoutez vos changements :
git commit -m "Ajout d'une nouvelle fonctionnalité"
4️⃣ Pushez votre code :
git push origin feature/nouvelle-fonction
5️⃣ Ouvrez une Pull Request
✔ AWS CLI installé & configuré
✔ eksctl & kubectl disponibles
docker build -t monrepo/cdn-go:latest -f docker/cdn/Dockerfile .
docker push monrepo/cdn-go:latest
eksctl create cluster --name cdn-cluster --region eu-west-3 --nodes 2
kubectl apply -f k8s/cdn-deployment.yaml
kubectl apply -f k8s/cdn-service.yaml
kubectl get pods
✔ Activer Kubernetes sur Docker Desktop
✔ Vérifier le contexte :
kubectl config get-contexts
kubectl config use-context docker-desktop
kubectl apply -f k8s/cdn-deployment.yaml
kubectl apply -f k8s/cdn-service.yaml
kubectl get services
🌍 API : http://localhost:80
📊 Métriques : http://localhost:80/metrics
💓 Health Check : http://localhost:80/health
💡 Nettoyez vos ressources après utilisation pour éviter des coûts inutiles !
📜 Logs & débogage :
kubectl logs -l app=cdn-go
✅ CDN Go prêt à l’emploi ! 🚀