π£ Bomb - HTTP & WebSocket Stress Testing Tool
A high-performance, production-grade Rust console application for stress-testing both HTTP endpoints and WebSocket servers. Bomb spawns multiple concurrent clients that can either send HTTP requests to REST APIs or establish WebSocket connections to send JSON messages and verify responses.
π Table of Contents
- Features
- Quick Start
- Installation
- Usage
- Random Generation
- Sample Output
- Testing Your Server
- Configuration Tips
- Contributing
β¨ Features
π Dual Protocol Support
- HTTP Stress Testing (beta): Support for GET, POST, PUT, DELETE, and PATCH methods
- WebSocket Testing: Full WebSocket client implementation with message verification
- Flexible URL Support: Supports http://, https://, ws://, and wss:// protocols
π Performance & Concurrency
- Concurrent Clients: Spawn N concurrent clients for maximum load
- Rate Limiting: Configurable message/request rate per client
- Comprehensive Metrics: Detailed performance reporting with RTT statistics
- Flexible Termination: Run for a specific duration or send a total number of requests
π§ Reliability & Resilience
- Graceful Shutdown: Handles Ctrl+C gracefully, waiting for pending responses
- Connection Resilience: Automatic WebSocket reconnection with exponential backoff
- Timeout Handling: Configurable response timeouts with failure tracking
- Custom Headers: Support for authentication and custom HTTP headers
π Advanced Testing Features
- Message Verification: Tracks unique message IDs to verify echo responses (WebSocket)
- HTTP Status Tracking: Monitors HTTP response codes and success rates
- Dynamic Payloads: Random UUID and data generation for realistic testing
- Memory Protection: Configurable limits to prevent resource exhaustion
π Quick Start
# Install from crates.io
# Test WebSocket echo server
# Test HTTP API
π¦ Installation
Option 1: Install from crates.io (Recommended)
Option 2: Build from Source
The binary will be available at target/release/bomb.
Prerequisites
- Rust 1.80+ (2024 edition)
- Cargo package manager
π οΈ Usage
Basic Examples
# WebSocket echo test
# HTTP GET test
# HTTP POST with JSON
WebSocket Testing
# Test local WebSocket server
# Test with custom payload
# Broadcast mode testing
HTTP Testing
# Load test API endpoint
# Test with authentication
# Different HTTP methods
Advanced Usage
# High load with custom headers
# Dynamic URLs with random data
# Complex JSON payload with random values
### Command Line Options
USAGE: bomb [OPTIONS] --target
OPTIONS: -t, --target Target URL to stress test (supports HTTP/HTTPS/WS/WSS protocols) [required] -c, --clients Number of concurrent clients to spawn [default: 10] -d, --duration Duration of the test (e.g., '30s', '5m', '2h') -n, --total-messages Total number of messages to send across all clients -r, --message-rate Messages per second per client (0 = unlimited) [default: 100] --timeout Connection timeout in seconds [default: 30] --max-pending Maximum pending messages per client (memory protection) [default: 6000] -H, --header Custom headers in 'Key: Value' format (can be used multiple times) --insecure Allow insecure TLS connections (skip certificate verification) -v, --verbose Enable verbose logging -p, --payload JSON payload to send (WebSocket mode requires 'id' field, HTTP mode does not) -m, --mode Connection protocol mode [default: ws] Possible values: http, ws --ws-mode <WS_MODE> WebSocket behavior mode (only used in WebSocket mode) [default: echo] Possible values: echo, broadcast --http-method HTTP method for stress testing (only used in HTTP mode) [default: get] Possible values: get, post, put, delete, patch -h, --help Print help (see a summary with '-h') -V, --version Print version
## π² Random Generation System
Bomb supports powerful random data generation that can be used in both target URLs and JSON payloads. This enables realistic testing scenarios with dynamic data values.
### Supported Random Patterns
| Pattern | Description | Example Input | Example Output |
|---------|-------------|---------------|----------------|
| `<rnd:uuid>` | Random UUID | `<rnd:uuid>` | `550e8400-e29b-41d4-a716-446655440000` |
| `<rnd:int[min, max]>` | Random integer in range | `<rnd:int[1, 100]>` | `42` |
| `<rnd:float[min, max]>` | Random float with precision | `<rnd:float[-0.5, 7.3]>` | `3.7` |
| `<rnd:ts[start, end]>` | Random timestamp in range | `<rnd:ts[1680000000, 1690000000]>` | `1685432100` |
| `<rnd:ts>` | Random timestamp (last 30 days) | `<rnd:ts>` | `1694567890` |
| `<rnd:datetime[start_dt, end_dt]>` | Random datetime in RFC3339 format with range | `<rnd:datetime[2024-01-01T00:00:00Z, 2024-12-31T23:59:59Z]>` | `2024-06-15T14:30:22+00:00` |
| `<rnd:datetime>` | Random datetime in RFC3339 format (last 30 days) | `<rnd:datetime>` | `2024-08-20T09:15:33+00:00` |
### Examples
```bash
# Dynamic URLs with unique session IDs
bomb -t "ws://localhost:8080/session/<rnd:uuid>/ws" -c 5 -n 20
# JSON payload with random data
bomb -t ws://api.example.com/ws -p '{
"id": "<rnd:uuid>",
"userId": <rnd:int[1000, 9999]>,
"score": <rnd:float[0.0, 100.0]>,
"timestamp": <rnd:ts>
}' -c 10 -r 5
Key Features:
- Each message gets fresh random values
- Range validation (automatically swaps min/max if needed)
- Float precision matches input format
- Works in both URLs and JSON payloads
π Sample Output
Echo Mode (Default)
π WebSocket Stress Test Configuration:
Target: ws://localhost:8080/ws
Clients: 20
Duration: 30s
Message Rate: 15 msg/s per client
Timeout: 5s
Mode: Echo
Custom Headers: 2 headers
Authorization: Bearer token123
X-API-Key: secret-key
π WebSocket Stress Test Results
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π§ Configuration:
Target: ws://localhost:8080/ws
Clients: 20
Duration: 30s
Message Rate: 15 msg/s per client
Timeout: 5s
Custom Headers: 2 headers
Authorization: Bearer token123
X-API-Key: secret-key
π Overall Results:
Test Duration: 30.12s
Messages Sent: 8,847
Messages Received: 8,831
Messages Failed: 16
Success Rate: 99.82%
β‘ Performance:
Messages/sec: 293.71
Per Client: 14.69 msg/s
π Round-Trip Time:
Average RTT: 23.45ms
Min RTT: 8ms
Max RTT: 156ms
β
Test completed successfully with excellent performance!
Broadcast Mode
π WebSocket Stress Test Configuration:
Target: ws://localhost:8080/broadcast
Clients: 5
Total Messages: 20
Per Client: 4 messages
Message Rate: 10 msg/s per client
Timeout: 5s
Mode: Broadcast
π WebSocket Stress Test Results
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π§ Configuration:
Target: ws://localhost:8080/broadcast
Clients: 5
Total Messages: 20
Per Client: 4 messages
Message Rate: 10 msg/s per client
Timeout: 5s
π‘ Broadcast Statistics:
Expected Deliveries: 100
Actual Deliveries: 95
Broadcast Completeness: 95.00%
β οΈ Incomplete Broadcasts: 5 messages
π Overall Results:
Test Duration: 2.15s
Messages Sent: 20
Messages Received: 95
Messages Failed: 0
Success Rate: 100.00%
β‘ Performance:
Messages/sec: 9.30
Per Client: 1.86 msg/s
π₯ Per-Client Summary:
Client ID | Sent | Received | Failed | Success% | Avg RTT
----------|------|----------|--------|----------|--------
0 | 4 | 20 | 0 | 100.0% | 0.0ms
1 | 4 | 18 | 0 | 100.0% | 0.0ms
2 | 4 | 19 | 0 | 100.0% | 0.0ms
3 | 4 | 19 | 0 | 100.0% | 0.0ms
4 | 4 | 19 | 0 | 100.0% | 0.0ms
π― Test completed successfully!
Note on Broadcast Mode Success Rate: In broadcast mode, each client receives messages from all other clients ( including their own).
π§ͺ Testing Your WebSocket Server
Expected Server Behavior
Bomb supports two different server behavior modes:
Echo Mode (Default)
For echo servers, your WebSocket server should:
- Echo messages back: Return the same JSON message that was sent
- Preserve message ID: The
idfield must be identical in the response - Handle concurrent connections: Support multiple simultaneous clients
- Respond promptly: Reply within the configured timeout period
Broadcast Mode
For broadcast servers, your WebSocket server should:
- Broadcast to all clients: Send received messages to all connected clients
- Preserve message content: Forward the complete JSON message
- Handle concurrent connections: Support multiple simultaneous clients
- Reliable delivery: Ensure messages reach all active connections
Example Echo Server
Here's a simple Node.js echo server for testing:
const WebSocket = require;
const wss = ;
wss.;
console.log;
Example Broadcast Server
Here's a simple Node.js broadcast server for testing:
const WebSocket = require;
const wss = ;
// Track all connected clients
const clients = ;
wss.;
console.log;
Message Format
Default Payload
By default, Bomb sends simple JSON messages with this structure:
Custom Payloads
You can send custom JSON payloads using the -p option. The payload must contain an id field for response
tracking:
# Simple custom payload
# Complex payload with nested data
# Fixed ID for testing specific scenarios
Random Data Generation
Use the enhanced random generation patterns in your payloads:
# Multiple random patterns in one payload
# Event scheduling with datetime ranges
Important: Each message gets a unique set of random values. The id field is used for response tracking and RTT
calculation.
πΊοΈ Common Test Patterns
Load Testing
# Gradual load increase
# HTTP API load testing
Capacity Testing
# Find maximum concurrent connections
# HTTP capacity testing
Authentication Testing
# JWT authentication
# API key authentication
π§ Configuration Tips
Performance Tuning
- Client Count: Start with 10-20 clients (
-c 10) and increase gradually - Message Rate: Begin with 5-10 msg/s per client (
-r 5) for baseline testing - Timeout: Use 5-10 seconds (
-T 5) for local testing, 10-30s for remote servers - Headers: Add authentication/custom headers with
-H "Key: Value"
Network Considerations
- Local Testing: Use
ws://localhostorws://127.0.0.1 - Remote Testing: Ensure firewall allows WebSocket connections
- SSL/TLS: Use
wss://for encrypted connections - Insecure Mode: Only use
-kor--insecurefor testing with self-signed certificates - Authentication: Use
-Hto add required auth headers for protected endpoints
High Failure Rates
Success Rate: 45.2%
- Increase timeout value with
-T 10or--timeout 10 - Reduce message rate with
-r 5or--message-rate 5 - Check server capacity and logs
- Verify server properly echoes messages
π Development
# Run tests
# Check code quality
π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure
cargo testandcargo clippypass - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ for stress testing