Linux command
oha 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Send 100 requests to URL
oha -n [100] [https://example.com]
Run load test for 30 seconds
oha -z [30s] [https://example.com]
Test with 50 concurrent connections
oha -c [50] -n [1000] [https://example.com]
POST request with JSON body
oha -m POST -d '[{"key":"value"}]' -T application/json [https://example.com/api]
Use custom headers
oha -H "Authorization: Bearer [token]" [https://example.com]
Set queries per second limit
oha -q [100] -z [30s] [https://example.com]
Disable TLS verification
oha --insecure [https://example.com]
Output results as JSON
oha -n [100] --json [https://example.com]
说明
oha is an HTTP load generator written in Rust, inspired by hey and rakyll/hey. It provides real-time TUI visualization during load tests and detailed latency statistics. By default, oha displays a terminal interface showing request progress, latency distribution, and error rates. Use --no-tui for scripted execution or --json for machine-readable output. The tool measures response time distribution including percentiles (p50, p90, p99), throughput, and error rates. With --latency-correction, it applies coordinated omission correction for accurate latency under load. Rate limiting with -q enables controlled load testing without overwhelming targets. Combined with -z for duration-based tests, this enables realistic traffic simulation. oha supports HTTP/1.1 and HTTP/2, custom headers for authentication, and various request body formats for API testing.
参数
- -n _num_
- Number of requests to send. Default: 200.
- -c _num_
- Number of concurrent connections. Default: 50.
- -z _duration_
- Duration of test (e.g., 10s, 1m).
- -q _rate_
- Rate limit in queries per second.
- -m, --method _method_
- HTTP method: GET, POST, PUT, DELETE, etc.
- -d, --data _body_
- Request body data.
- -D, --data-file _file_
- Read request body from file.
- -T, --content-type _type_
- Content-Type header value.
- -H _header_
- Custom header (repeatable).
- -A, --accept _type_
- Accept header value.
- -t, --timeout _secs_
- Request timeout in seconds.
- --latency-correction
- Enable coordinated omission correction.
- --no-tui
- Disable real-time terminal UI.
- --json
- Output results in JSON format.
- --insecure
- Skip TLS certificate verification.
- --http2
- Use HTTP/2.
- --host _host_
- Override Host header.
- -p, --redirect _num_
- Maximum redirects to follow.
FAQ
What is the oha command used for?
oha is an HTTP load generator written in Rust, inspired by hey and rakyll/hey. It provides real-time TUI visualization during load tests and detailed latency statistics. By default, oha displays a terminal interface showing request progress, latency distribution, and error rates. Use --no-tui for scripted execution or --json for machine-readable output. The tool measures response time distribution including percentiles (p50, p90, p99), throughput, and error rates. With --latency-correction, it applies coordinated omission correction for accurate latency under load. Rate limiting with -q enables controlled load testing without overwhelming targets. Combined with -z for duration-based tests, this enables realistic traffic simulation. oha supports HTTP/1.1 and HTTP/2, custom headers for authentication, and various request body formats for API testing.
How do I run a basic oha example?
Run `oha -n [100] [https://example.com]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n _num_ do in oha?
Number of requests to send. Default: 200.