User Tools

Site Tools


howtos:simple_stress_test_script

Stress Test Script

These two bash scripts make an easy stress tester for your webserver or to test your DoS capabilities.

First one is simply curl making a lot requests in a linear fashion, one after the other.

#!/bin/bash

# Set the URL of the website to test
url="https://www.example.com"

# Set the number of requests to send
num_requests=1000

# Send the requests
for i in $(seq 1 $num_requests); do
  curl $url
done

The second one runs it concurrently. You specify how many concurrent curl loops you want to run and then it goes through each URI the specified number of times.

#!/bin/bash

# Set the URLs of the websites to test
urls=("https://www.example1.com" "https://www.example2.com" "https://www.example3.com")

# Set the number of requests to send
num_requests=1000

# Set the number of concurrent requests
concurrent_requests=100

# Send the requests
for url in ${urls[@]}; do
  for i in $(seq 1 $num_requests); do
    curl $url &
    # Limit the number of concurrent requests
    if [[ $(jobs -r -p | wc -l) -gt $concurrent_requests ]]; then
      wait
    fi
  done
done
howtos/simple_stress_test_script.txt · Last modified: 15/12/2022 18:59 by domingo