A simple bash script for stress testing API endpoints.
./stress-test.sh <curl-file> [concurrency] [total-requests]# Test with defaults (50 concurrent, 100 requests)
./stress-test.sh my-api.curl
# Test with 50 concurrent, 600 total requests
./stress-test.sh my-api.curl 50 600
# Light test with 5 concurrent, 20 requests
./stress-test.sh my-api.curl 5 20Create a .curl file with your request:
# my-api.curl
curl -X GET 'https://api.example.com/data' \
--header 'Authorization: Bearer YOUR_TOKEN'Notes:
- Lines starting with
#are ignored (comments) - Multi-line curl commands are supported
- The script extracts and executes the curl command
==========================================
STRESS TEST RESULTS
==========================================
Total requests: 600
Concurrency: 50
Duration: 45s
Requests/sec: 13.33
------------------------------------------
Response Status Codes
------------------------------------------
200 OK: 100
429 Rate Limit: 500
Other errors: 0
------------------------------------------
Rate Limit Analysis
------------------------------------------
First 429 at: request #101
Approx threshold: ~100 requests
==========================================
⚠ Rate limit at or below 100
- Reads the curl command from your file
- Executes
Nrequests withCconcurrent workers usingxargs -P - Captures HTTP status codes from each request
- Reports statistics and rate limit threshold
- bash
- curl
- bc (for calculations)
- xargs
- Start small: Test with 20 requests first to verify everything works
- Check the endpoint: Make sure a single request works before load testing
- Rate limits: The script identifies when 429 responses start appearing