maurocarlu commited on
Commit
9dabbe0
·
1 Parent(s): 20320bd

add Locust load testing script and documentation for the Skill Classification API

Browse files
monitoring/locust/README.md CHANGED
@@ -28,16 +28,32 @@ Apri il browser e vai a: **http://localhost:8089**
28
 
29
  Nella Web UI, configura i seguenti parametri:
30
 
31
- | Parametro | Descrizione | Valore Consigliato |
32
  |-----------|-------------|-------------------|
33
- | **Host** | URL dell'API da testare | `http://localhost:8080` (Docker) o `http://localhost:8000` (locale) |
34
- | **Number of users** | Numero totale di utenti simulati | 10-100 |
35
- | **Spawn rate** | Utenti da creare al secondo | 1-10 |
36
 
37
  ### 4. Avvia il Test
38
 
39
  Clicca su **"Start swarming"** per avviare il test di carico.
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  ## Task Implementati
42
 
43
  Lo script simula il comportamento di utenti reali con i seguenti task:
@@ -73,21 +89,25 @@ Durante il test, Locust fornisce le seguenti metriche in tempo reale:
73
  ### Esecuzione Headless (senza UI)
74
 
75
  ```bash
76
- locust -f locustfile.py --headless -u 50 -r 5 -t 5m --host http://localhost:8000
 
 
 
 
77
  ```
78
 
79
  | Opzione | Descrizione |
80
  |---------|-------------|
81
  | `--headless` | Esegui senza Web UI |
82
- | `-u 50` | 50 utenti simulati |
83
- | `-r 5` | 5 utenti creati al secondo |
84
- | `-t 5m` | Durata del test: 5 minuti |
85
- | `--host` | URL dell'API |
86
 
87
  ### Esportazione Risultati
88
 
89
  ```bash
90
- locust -f locustfile.py --headless -u 50 -r 5 -t 5m --host http://localhost:8000 --csv=results
91
  ```
92
 
93
  Questo creerà file CSV con i risultati del test.
@@ -99,3 +119,9 @@ monitoring/locust/
99
  ├── locustfile.py # Script principale di load testing
100
  └── README.md # Questa documentazione
101
  ```
 
 
 
 
 
 
 
28
 
29
  Nella Web UI, configura i seguenti parametri:
30
 
31
+ | Parametro | Descrizione | Valore di Default |
32
  |-----------|-------------|-------------------|
33
+ | **Host** | URL dell'API da testare | `https://dacrow13-hopcroft-skill-classification.hf.space` |
34
+ | **Number of users** | Numero totale di utenti simulati | 5-10 (HF Spaces) / 10-100 (locale) |
35
+ | **Spawn rate** | Utenti da creare al secondo | 1-2 |
36
 
37
  ### 4. Avvia il Test
38
 
39
  Clicca su **"Start swarming"** per avviare il test di carico.
40
 
41
+ ## Ambienti di Test
42
+
43
+ Lo script è preconfigurato per testare l'API deployata su **HuggingFace Spaces**:
44
+
45
+ | Ambiente | URL | Note |
46
+ |----------|-----|------|
47
+ | **HuggingFace Spaces** (default) | `https://dacrow13-hopcroft-skill-classification.hf.space` | Produzione |
48
+ | Docker locale | `http://localhost:8080` | Sviluppo con Docker |
49
+ | Uvicorn locale | `http://localhost:8000` | Sviluppo senza Docker |
50
+
51
+ Per testare un ambiente diverso, usa il flag `--host`:
52
+
53
+ ```bash
54
+ locust -f locustfile.py --host http://localhost:8080
55
+ ```
56
+
57
  ## Task Implementati
58
 
59
  Lo script simula il comportamento di utenti reali con i seguenti task:
 
89
  ### Esecuzione Headless (senza UI)
90
 
91
  ```bash
92
+ # Test su HuggingFace Spaces (default)
93
+ locust -f locustfile.py --headless -u 5 -r 1 -t 2m
94
+
95
+ # Test su Docker locale
96
+ locust -f locustfile.py --headless -u 50 -r 5 -t 5m --host http://localhost:8080
97
  ```
98
 
99
  | Opzione | Descrizione |
100
  |---------|-------------|
101
  | `--headless` | Esegui senza Web UI |
102
+ | `-u 5` | 5 utenti simulati |
103
+ | `-r 1` | 1 utente creato al secondo |
104
+ | `-t 2m` | Durata del test: 2 minuti |
105
+ | `--host` | URL dell'API (override) |
106
 
107
  ### Esportazione Risultati
108
 
109
  ```bash
110
+ locust -f locustfile.py --headless -u 5 -r 1 -t 2m --csv=results
111
  ```
112
 
113
  Questo creerà file CSV con i risultati del test.
 
119
  ├── locustfile.py # Script principale di load testing
120
  └── README.md # Questa documentazione
121
  ```
122
+
123
+ ## Note Importanti
124
+
125
+ - **HuggingFace Spaces**: Usa un numero ridotto di utenti (5-10) per non sovraccaricare il servizio gratuito
126
+ - **Latenza**: I test su HF Spaces avranno latenze maggiori rispetto ai test locali
127
+ - **Cold Start**: Il primo request potrebbe essere lento se lo Space è in sleep mode
monitoring/locust/locustfile.py CHANGED
@@ -19,8 +19,8 @@ class SkillClassificationUser(HttpUser):
19
  """
20
 
21
  # Default host for the API (can be overridden via --host flag or Web UI)
22
- # Use http://localhost:8080 for Docker or http://localhost:8000 for local dev
23
- host = "http://localhost:8080"
24
 
25
  # Wait between 1 and 5 seconds between tasks to simulate real user behavior
26
  wait_time = between(1, 5)
 
19
  """
20
 
21
  # Default host for the API (can be overridden via --host flag or Web UI)
22
+ # HuggingFace Spaces URL (or use http://localhost:8080 for Docker, http://localhost:8000 for local dev)
23
+ host = "https://dacrow13-hopcroft-skill-classification.hf.space"
24
 
25
  # Wait between 1 and 5 seconds between tasks to simulate real user behavior
26
  wait_time = between(1, 5)