
How to Use ApacheBench for Load Testing on Ubuntu 24.04
If you’re deploying a web application or API on Ubuntu 24.04, one of the most important steps is performance testing. A simple yet powerful tool for this task is ApacheBench (ab) — a command-line utility that lets you benchmark HTTP services quickly and efficiently.
In this guide, you’ll learn how to install ApacheBench on Ubuntu 24.04 and use it to simulate load, evaluate server performance, and interpret the results.
✅ What Is ApacheBench?
ApacheBench (ab) is a lightweight benchmarking tool that ships with the Apache HTTP server. It can simulate a large number of HTTP requests to test how well your server handles traffic.
It provides metrics like:
- Requests per second
- Average response time
- Number of failed requests
- Throughput
🧰 Prerequisites
- Ubuntu 24.04 system (local or cloud)
- A web application or endpoint to test
- Terminal access with
sudo
privileges
Step 1: Install ApacheBench
On Ubuntu 24.04, ApacheBench is part of the apache2-utils
package. Install it with:
bashCopyEditsudo apt update
sudo apt install apache2-utils
Verify the installation:
bashCopyEditab -V
You should see something like:
csharpCopyEditThis is ApacheBench, Version 2.3 <...>
Step 2: Basic Load Testing Command
Use the following command to send 100 requests with 10 concurrent connections:
bashCopyEditab -n 100 -c 10 http://localhost/
Where:
-n
= total number of requests-c
= number of concurrent requests
Step 3: Analyze the Output
Sample result:
yamlCopyEditConcurrency Level: 10
Time taken for tests: 0.850 seconds
Complete requests: 100
Failed requests: 0
Requests per second: 117.65 [#/sec] (mean)
Time per request: 85.0 [ms] (mean)
Key Metrics:
- Requests per second: Higher is better
- Time per request: Lower means faster response
- Failed requests: Indicates stability
Step 4: Test a Specific Endpoint
Replace localhost
with your actual domain or endpoint:
bashCopyEditab -n 500 -c 25 https://yourdomain.com/api/v1/products
⚠️ Be careful when testing production environments. Start with low values and monitor resource usage.
Step 5: Use POST Data
You can simulate a POST request by passing a payload file:
bashCopyEditab -n 100 -c 10 -p data.json -T application/json https://yourdomain.com/api/create
-p
= file with POST data-T
= content type (e.g., JSON)
Step 6: Export Results
Export metrics for analysis in spreadsheets or dashboards:
bashCopyEditab -n 100 -c 10 -e results.csv https://yourdomain.com/
This creates a CSV file with latency data you can visualize.
🧠 Pro Tips
- Combine with
htop
,atop
, oriotop
to monitor server load during testing. - Run tests from a separate machine or cloud VPS for more accurate results.
- Consider using wrk or siege for more advanced scenarios.
🛡️ Security Reminder
Avoid stress-testing production systems without prior planning. Uncontrolled load tests can:
- Trigger rate limits
- Crash your services
- Violate hosting provider terms
Summary
ApacheBench is a fast, reliable, and easy way to benchmark your web apps on Ubuntu 24.04. Whether you’re tuning APIs, testing response times, or stress-testing infrastructure, it helps identify bottlenecks and validate improvements.
Ready for Real-World Traffic?
At GreenHost, we provide high-performance, scalable, and eco-friendly Linux hosting — optimized for real load. Our experts can help you with stress testing, server tuning, and infrastructure scaling.