Skip to content

Latest commit

 

History

History
86 lines (63 loc) · 1.92 KB

File metadata and controls

86 lines (63 loc) · 1.92 KB

Stress Tester

A simple bash script for stress testing API endpoints.

Usage

./stress-test.sh <curl-file> [concurrency] [total-requests]

Examples

# 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 20

Creating a Curl File

Create 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

Output

==========================================
           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

How It Works

  1. Reads the curl command from your file
  2. Executes N requests with C concurrent workers using xargs -P
  3. Captures HTTP status codes from each request
  4. Reports statistics and rate limit threshold

Requirements

  • bash
  • curl
  • bc (for calculations)
  • xargs

Tips

  • 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