Skip to content
This repository was archived by the owner on Apr 20, 2025. It is now read-only.

GoofyTeam/GoofyContentDeliveryNetwork

Repository files navigation

⚡ CDN Go - Réseau de Distribution de Contenu

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.


Membre du groupe

groupe 3 : Adrien ALBUQUERQUE, Thomas BUISSON, Matteo COURQUIN, Thanh-long PHAM

🔹 Fonctionnalités

🔀 Proxy HTTP

➜ Redirection dynamique des requêtes

🎛️ Système de Cache

Cache LRU en mémoire
Cache Redis pour une meilleure scalabilité

⚖️ Load Balancer

Round Robin
Weighted Round Robin
Least Connections

🛡️ Sécurité

Rate Limiting (limitation de débit)
Protection DDoS
Headers HTTP sécurisés

📈 Monitoring & Logs

Métriques Prometheus
Visualisation avec Grafana
Logging avancé avec Logrus


🛠 Prérequis

📌 Outils nécessaires :
🔹 Docker & Docker Compose
🔹 Go 1.23+ (pour développement local)


🚀 Démarrage

🔧 Mode Développement

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

🏭 Mode Production

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

💻 Démarrer le Frontend

cd front
npm install
npm run dev

🔗 Services Complémentaires

📊 Grafana : http://localhost:3000 (admin/admin)
📡 Prometheus : http://localhost:9090
🗄️ Redis : localhost:6379


📂 Organisation du Projet

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

🔍 Détails Techniques

🗄️ Système de Cache

⚡ Cache LRU (en mémoire)

📁 Fichier : internal/cache/cache.go
✔ Gestion via hashicorp/golang-lru
✔ Capacité ajustable
✔ Cache uniquement les requêtes GET

🛠 Gestion du Cache via API

Vider tout le cache

curl -X POST http://localhost:8080/cache/purge

⚖️ Équilibrage de Charge

🏗️ Algorithmes Supportés

📁 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é)


🌐 Endpoints API

🔑 Authentification

🔹 POST /register ➜ Inscription
🔹 POST /login ➜ Connexion

📂 Gestion des Fichiers (avec authentification)

📥 POST /api/files ➜ Upload
📤 GET /api/files/:id ➜ Récupération
🗑️ DELETE /api/files/:id ➜ Suppression

📁 Gestion des Dossiers (avec authentification)

📁 POST /api/folders ➜ Création
📜 GET /api/folders/:id ➜ Liste du contenu
🗑️ DELETE /api/folders/:id ➜ Suppression

🔎 Monitoring

📊 GET /metrics ➜ Statistiques Prometheus
💓 GET /health ➜ État du service
📡 GET /ready ➜ Vérification de disponibilité


📊 Monitoring & Sécurité

📊 Métriques Disponibles

Temps de réponse (http_duration_seconds)
Total requêtes par endpoint (http_requests_total)
Taux de succès & erreurs

🛡️ Mesures de Sécurité

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

🤝 Comment Contribuer

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


☁️ Déploiement sur AWS EKS

🔹 Pré-requis

AWS CLI installé & configuré
eksctl & kubectl disponibles

🏗️ Construction de l’image Docker

docker build -t monrepo/cdn-go:latest -f docker/cdn/Dockerfile .
docker push monrepo/cdn-go:latest

🚀 Déploiement Kubernetes

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

🛠 Déploiement Local avec Kubernetes

⚙️ Configuration

✔ Activer Kubernetes sur Docker Desktop
✔ Vérifier le contexte :

kubectl config get-contexts
kubectl config use-context docker-desktop

🚀 Lancer l’application

kubectl apply -f k8s/cdn-deployment.yaml
kubectl apply -f k8s/cdn-service.yaml
kubectl get services

🔍 Vérifications

🌍 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 ! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •