Spaces:
Runtime error
Runtime error
Commit ·
888d4a9
1
Parent(s): 19b259c
add Locust load testing script and documentation for the Skill Classification API
Browse filesFiles changed (2)
27 unmodified lines2829303132333435363738394041424329 unmodified lines7374757677787980818283848586878889909192935 unmodified lines9910010127 unmodified linesNella Web UI, configura i seguenti parametri:| Parametro | Descrizione | Valore Consigliato ||-----------|-------------|-------------------|| **Host** | URL dell'API da testare | `http://localhost:8080` (Docker) o `http://localhost:8000` (locale) || **Number of users** | Numero totale di utenti simulati | 10-100 || **Spawn rate** | Utenti da creare al secondo | 1-10 |### 4. Avvia il TestClicca su **"Start swarming"** per avviare il test di carico.## Task ImplementatiLo script simula il comportamento di utenti reali con i seguenti task:29 unmodified lines### Esecuzione Headless (senza UI)```bashlocust -f locustfile.py --headless -u 50 -r 5 -t 5m --host http://localhost:8000```| Opzione | Descrizione ||---------|-------------|| `--headless` | Esegui senza Web UI || `-u 50` | 50 utenti simulati || `-r 5` | 5 utenti creati al secondo || `-t 5m` | Durata del test: 5 minuti || `--host` | URL dell'API |### Esportazione Risultati```bashlocust -f locustfile.py --headless -u 50 -r 5 -t 5m --host http://localhost:8000 --csv=results```Questo creerà file CSV con i risultati del test.5 unmodified lines├── locustfile.py # Script principale di load testing└── README.md # Questa documentazione```27 unmodified lines282930313233343536373839404142434445464748495051525354555657585929 unmodified lines89909192939495969798991001011021031041051061071081091101111121135 unmodified lines11912012112212312412512612727 unmodified linesNella Web UI, configura i seguenti parametri:| Parametro | Descrizione | Valore di Default ||-----------|-------------|-------------------|| **Host** | URL dell'API da testare | `https://dacrow13-hopcroft-skill-classification.hf.space` || **Number of users** | Numero totale di utenti simulati | 5-10 (HF Spaces) / 10-100 (locale) || **Spawn rate** | Utenti da creare al secondo | 1-2 |### 4. Avvia il TestClicca su **"Start swarming"** per avviare il test di carico.## Ambienti di TestLo script è preconfigurato per testare l'API deployata su **HuggingFace Spaces**:| Ambiente | URL | Note ||----------|-----|------|| **HuggingFace Spaces** (default) | `https://dacrow13-hopcroft-skill-classification.hf.space` | Produzione || Docker locale | `http://localhost:8080` | Sviluppo con Docker || Uvicorn locale | `http://localhost:8000` | Sviluppo senza Docker |Per testare un ambiente diverso, usa il flag `--host`:```bashlocust -f locustfile.py --host http://localhost:8080```## Task ImplementatiLo script simula il comportamento di utenti reali con i seguenti task:29 unmodified lines### Esecuzione Headless (senza UI)```bash# Test su HuggingFace Spaces (default)locust -f locustfile.py --headless -u 5 -r 1 -t 2m# Test su Docker localelocust -f locustfile.py --headless -u 50 -r 5 -t 5m --host http://localhost:8080```| Opzione | Descrizione ||---------|-------------|| `--headless` | Esegui senza Web UI || `-u 5` | 5 utenti simulati || `-r 1` | 1 utente creato al secondo || `-t 2m` | Durata del test: 2 minuti || `--host` | URL dell'API (override) |### Esportazione Risultati```bashlocust -f locustfile.py --headless -u 5 -r 1 -t 2m --csv=results```Questo creerà file CSV con i risultati del test.5 unmodified lines├── locustfile.py # Script principale di load testing└── README.md # Questa documentazione```## Note Importanti- **HuggingFace Spaces**: Usa un numero ridotto di utenti (5-10) per non sovraccaricare il servizio gratuito- **Latenza**: I test su HF Spaces avranno latenze maggiori rispetto ai test locali- **Cold Start**: Il primo request potrebbe essere lento se lo Space è in sleep mode
18 unmodified lines192021222324252618 unmodified lines"""# Default host for the API (can be overridden via --host flag or Web UI)# Use http://localhost:8080 for Docker or http://localhost:8000 for local devhost = "http://localhost:8080"# Wait between 1 and 5 seconds between tasks to simulate real user behaviorwait_time = between(1, 5)18 unmodified lines192021222324252618 unmodified lines"""# Default host for the API (can be overridden via --host flag or Web UI)# HuggingFace Spaces URL (or use http://localhost:8080 for Docker, http://localhost:8000 for local dev)host = "https://dacrow13-hopcroft-skill-classification.hf.space"# Wait between 1 and 5 seconds between tasks to simulate real user behaviorwait_time = between(1, 5)
monitoring/locust/README.md+36-10
monitoring/locust/locustfile.py+2-2