This directory contains load testing scripts designed to simulate Token Generation Event (TGE) scenarios where 1,000+ concurrent users might refresh their dashboards simultaneously.
- Install Artillery globally:
npm install -g artillery- Install project dependencies:
npm install- Ensure your API server is running:
npm start- Purpose: Tests basic API endpoints without authentication
- Duration: ~10 minutes
- Peak Load: 500 RPS
- Endpoints:
/api/vaults,/health
- Purpose: Full TGE scenario with authenticated users
- Duration: ~20 minutes
- Peak Load: 500 RPS sustained for 10 minutes
- Endpoints: Auth, vaults, portfolio, claims history
- Purpose: Quick validation test
- Duration: ~5 minutes
- Peak Load: 500 RPS
- Endpoints: Core API endpoints
# Basic load test
npm run test:load:basic
# Comprehensive TGE test
npm run test:load:comprehensive
# Quick test
npm run test:load:quick
# Default (basic test)
npm run test:load# Basic test
node scripts/run-tge-load-test.js basic
# Comprehensive test
node scripts/run-tge-load-test.js comprehensive
# Quick test
node scripts/run-tge-load-test.js quick# Basic test
artillery run artillery-basic-load-test.yml
# Comprehensive test
artillery run artillery-tge-comprehensive.yml
# Quick test
artillery run artillery-tge-load-test.ymlAPI_BASE_URL: Target API URL (default:http://localhost:3000)
Example:
API_BASE_URL=http://localhost:4000 npm run test:load- P99 Latency: < 200ms (target)
- P95 Latency: < 100ms (ideal)
- Error Rate: < 1%
- Throughput: Maintain 500 RPS during peak load
- User login with signature
- Fetch vaults list
- Fetch individual vault details
- Fetch vault beneficiaries
- Simulate realistic user navigation patterns
- User authentication
- Fetch portfolio data
- Fetch claims history with pagination
- Simulate portfolio review behavior
- Health checks
- Public vault data
- Export summary requests
- Simulate public API usage
- Rapid succession of API calls
- Simulate aggressive user behavior
- Test system limits
After each test run:
- HTML report is generated:
artillery-report.html - JSON data is saved:
artillery-report.json - Key metrics are displayed in the console
- P99 Latency: Should be < 200ms
- P95 Latency: Should be < 100ms
- Error Rate: Should be < 1%
- RPS (Requests Per Second): Actual throughput
- Response Time Distribution: Identify slow endpoints
-
Artillery not found:
npm install -g artillery
-
Connection refused:
- Ensure API server is running
- Check API_BASE_URL environment variable
-
High error rates:
- Check server logs
- Verify database connections
- Monitor resource usage
-
Memory issues:
- Reduce arrival rate in test config
- Monitor server memory usage
- Check for memory leaks
Edit the .yml files to adjust:
arrivalRate: Requests per secondduration: Test phase durationweight: Scenario probability- Endpoints and request parameters
- Define new scenario in the
.ymlfile - Set appropriate weight
- Add request flow with think times
- Test with smaller loads first
- Never run load tests against production without approval
- Use staging environment that mirrors production
- Monitor system resources during tests
- Have rollback plans ready
- Coordinate with team during test windows
These tests can be integrated into CI/CD pipelines:
# Example GitHub Actions step
- name: Run Load Tests
run: |
npm install -g artillery
npm run test:load:quickFor issues or questions:
- Check Artillery documentation: https://artillery.io/docs/
- Review test logs for specific errors
- Monitor server logs during test execution