Skip to content

Commit 6355724

Browse files
committed
bug fixes
1 parent 7a0314a commit 6355724

File tree

21 files changed

+1071
-114
lines changed

21 files changed

+1071
-114
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Quick Start Scripts for Locust Load Testing
2+
3+
## For Windows Users
4+
5+
### Option 1: Double-click to Run
6+
7+
Simply double-click `run_locust.bat` and it will:
8+
9+
- Check if Python is installed
10+
- Install Locust if needed
11+
- Start the Locust Web UI
12+
- Open http://localhost:8089 in your browser
13+
14+
### Option 2: Command Line
15+
16+
```powershell
17+
.\run_locust.bat
18+
```
19+
20+
## For Linux/Mac Users
21+
22+
### Make script executable (first time only):
23+
24+
```bash
25+
chmod +x run_locust.sh
26+
```
27+
28+
### Run the script:
29+
30+
```bash
31+
./run_locust.sh
32+
```
33+
34+
## Using the Locust Web UI
35+
36+
1. **Open Browser**: Go to http://localhost:8089
37+
2. **Configure Test**:
38+
- Number of users: 50 (start small)
39+
- Spawn rate: 5 users/second
40+
- Host: Already set to your deployment URL
41+
3. **Click Start** to begin load testing
42+
4. **Monitor**: Watch real-time statistics, charts, and failures
43+
44+
## Quick Commands (Without Scripts)
45+
46+
### Start Web UI
47+
48+
```powershell
49+
python -m locust -f locustfile.py --host=https://frontend-icu8wrczi-amanraz-thakurs-projects.vercel.app
50+
```
51+
52+
### Headless Mode (No UI)
53+
54+
```powershell
55+
python -m locust -f locustfile.py --host=https://frontend-icu8wrczi-amanraz-thakurs-projects.vercel.app --users 50 --spawn-rate 5 --run-time 2m --headless
56+
```
57+
58+
### Generate HTML Report
59+
60+
```powershell
61+
python -m locust -f locustfile.py --host=https://frontend-icu8wrczi-amanraz-thakurs-projects.vercel.app --users 50 --spawn-rate 5 --run-time 2m --headless --html=report.html
62+
```
63+
64+
## Test Scenarios
65+
66+
### Light Test (Development)
67+
68+
```powershell
69+
python -m locust -f locustfile.py --host=https://frontend-icu8wrczi-amanraz-thakurs-projects.vercel.app --users 10 --spawn-rate 2 --run-time 1m --headless
70+
```
71+
72+
### Medium Test (Typical Load)
73+
74+
```powershell
75+
python -m locust -f locustfile.py --host=https://frontend-icu8wrczi-amanraz-thakurs-projects.vercel.app --users 50 --spawn-rate 5 --run-time 5m --headless
76+
```
77+
78+
### Heavy Test (Stress Test)
79+
80+
```powershell
81+
python -m locust -f locustfile.py --host=https://frontend-icu8wrczi-amanraz-thakurs-projects.vercel.app --users 200 --spawn-rate 10 --run-time 10m --headless
82+
```
83+
84+
### Spike Test (Sudden Traffic)
85+
86+
```powershell
87+
python -m locust -f locustfile.py --host=https://frontend-icu8wrczi-amanraz-thakurs-projects.vercel.app --users 500 --spawn-rate 50 --run-time 3m --headless
88+
```
89+
90+
## What Gets Tested
91+
92+
- ✅ Homepage visits
93+
- ✅ Registration page
94+
- ✅ Team registration submissions
95+
- ✅ Contact form submissions
96+
- ✅ Dashboard access
97+
- ✅ Admin panel access
98+
- ✅ Team lead authentication
99+
100+
## Monitoring Results
101+
102+
### Key Metrics:
103+
104+
- **RPS (Requests/Second)**: Higher is better
105+
- **Response Time**: Should be <1s for most requests
106+
- **Failure Rate**: Should be <1%
107+
- **95th Percentile**: 95% of requests complete within this time
108+
109+
### Expected Performance:
110+
111+
- Homepage: <500ms
112+
- API endpoints: <1000ms
113+
- Database operations: <2000ms
114+
115+
## Troubleshooting
116+
117+
### If you see "ModuleNotFoundError: No module named 'locust'"
118+
119+
```powershell
120+
pip install locust
121+
```
122+
123+
### If you see connection errors
124+
125+
- Check if the deployment URL is accessible
126+
- Verify your internet connection
127+
- Check Vercel status
128+
129+
### If tests are failing
130+
131+
- Reduce number of users
132+
- Increase spawn rate delay
133+
- Check MongoDB connection limits
134+
- Review Vercel function execution limits
135+
136+
## Notes
137+
138+
- The target URL is automatically set to your latest deployment
139+
- Results are displayed in real-time in the web UI
140+
- You can stop tests at any time with Ctrl+C
141+
- Test data will be created in the database (remember to clean up)
142+
143+
## Current Deployment URL
144+
145+
**https://frontend-icu8wrczi-amanraz-thakurs-projects.vercel.app**

frontend/load-testing/README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Load Testing with Locust
2+
3+
This directory contains Locust load testing scripts for the Hackathon Registration Platform.
4+
5+
## Setup
6+
7+
1. **Install Python** (if not already installed)
8+
9+
- Download from https://www.python.org/downloads/
10+
11+
2. **Install Locust:**
12+
```bash
13+
pip install -r requirements.txt
14+
```
15+
16+
## Running Load Tests
17+
18+
### Basic Load Test (Web UI)
19+
20+
Run Locust with web interface:
21+
22+
```bash
23+
locust -f locustfile.py --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app
24+
```
25+
26+
Then open http://localhost:8089 in your browser and configure:
27+
28+
- **Number of users**: Start with 10-50
29+
- **Spawn rate**: 5 users per second
30+
- **Host**: Pre-filled with your deployment URL
31+
32+
### Headless Load Test (Command Line)
33+
34+
Run without web UI:
35+
36+
```bash
37+
locust -f locustfile.py --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app --users 50 --spawn-rate 5 --run-time 2m --headless
38+
```
39+
40+
Parameters:
41+
42+
- `--users 50`: Simulate 50 concurrent users
43+
- `--spawn-rate 5`: Add 5 users per second
44+
- `--run-time 2m`: Run for 2 minutes
45+
- `--headless`: No web UI
46+
47+
### Test Specific User Type
48+
49+
Test only regular users:
50+
51+
```bash
52+
locust -f locustfile.py HackathonUser --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app
53+
```
54+
55+
Test only admin users:
56+
57+
```bash
58+
locust -f locustfile.py AdminUser --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app
59+
```
60+
61+
## What Gets Tested
62+
63+
### HackathonUser (Regular Visitors)
64+
65+
- ✅ Homepage visits (30% of actions)
66+
- ✅ Registration page visits (20%)
67+
- ✅ Team registration submissions (10%)
68+
- ✅ Contact form submissions (10%)
69+
- ✅ Team lead status checks (10%)
70+
- ✅ Dashboard visits (10%)
71+
72+
### AdminUser
73+
74+
- ✅ Admin page access (50%)
75+
- ✅ Fetching all registrations (50%)
76+
77+
## Understanding Results
78+
79+
### Key Metrics to Watch:
80+
81+
- **RPS (Requests Per Second)**: Higher is better
82+
- **Response Time**: Should be <1s for most requests
83+
- **Failure Rate**: Should be <1%
84+
- **95th Percentile**: 95% of requests complete within this time
85+
86+
### Expected Performance:
87+
88+
- Homepage: <500ms
89+
- API endpoints: <1000ms
90+
- Database operations: <2000ms
91+
92+
## Sample Test Scenarios
93+
94+
### Light Load (Development Testing)
95+
96+
```bash
97+
locust -f locustfile.py --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app --users 10 --spawn-rate 2 --run-time 1m --headless
98+
```
99+
100+
### Medium Load (Typical Usage)
101+
102+
```bash
103+
locust -f locustfile.py --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app --users 50 --spawn-rate 5 --run-time 5m --headless
104+
```
105+
106+
### Heavy Load (Stress Testing)
107+
108+
```bash
109+
locust -f locustfile.py --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app --users 200 --spawn-rate 10 --run-time 10m --headless
110+
```
111+
112+
### Spike Test (Sudden Traffic)
113+
114+
```bash
115+
locust -f locustfile.py --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app --users 500 --spawn-rate 50 --run-time 3m --headless
116+
```
117+
118+
## Export Results
119+
120+
Save results to CSV:
121+
122+
```bash
123+
locust -f locustfile.py --host=https://frontend-2qaml73oq-amanraz-thakurs-projects.vercel.app --users 50 --spawn-rate 5 --run-time 2m --headless --csv=results --html=report.html
124+
```
125+
126+
This generates:
127+
128+
- `results_stats.csv` - Request statistics
129+
- `results_failures.csv` - Failed requests
130+
- `results_stats_history.csv` - Time-series data
131+
- `report.html` - Visual HTML report
132+
133+
## Troubleshooting
134+
135+
### Connection Errors
136+
137+
- Check if the deployment URL is correct
138+
- Ensure the site is accessible
139+
- Verify Vercel isn't rate-limiting
140+
141+
### High Failure Rates
142+
143+
- Reduce number of users
144+
- Increase spawn rate delay
145+
- Check MongoDB connection limits
146+
- Review Vercel function execution limits (free tier: 10s timeout)
147+
148+
### Database Issues
149+
150+
- MongoDB Atlas free tier has connection limits (500 max)
151+
- Consider upgrading if testing with >100 concurrent users
152+
153+
## Best Practices
154+
155+
1. **Start Small**: Begin with 10 users, gradually increase
156+
2. **Monitor Server**: Watch Vercel logs during tests
157+
3. **Test Off-Peak**: Avoid testing during actual registrations
158+
4. **Clean Test Data**: Remove test registrations after load tests
159+
5. **Respect Limits**: Vercel free tier has bandwidth/execution limits
160+
161+
## Security Note
162+
163+
The `locustfile.py` includes the admin token for testing. This is acceptable for load testing but ensure:
164+
165+
- Don't commit sensitive tokens to public repos
166+
- Use test environments when possible
167+
- Clean up test data after testing
6.32 KB
Binary file not shown.

0 commit comments

Comments
 (0)