Performance Testing with wrk: Analyzing Latency and Throughput
Introduction:
In the realm of web development, ensuring optimal performance of your application is paramount. Performance testing tools like wrk allow developers to simulate real-world traffic and evaluate how their application performs under various load conditions. In this experiment, we'll delve into using wrk to analyze the latency and throughput of a web application.
Experiment:
Before diving into the experiment, let's set up wrk. If you haven't already installed it, follow these steps:
bashsudo apt-get install build-essential libssl-dev git -y
git clone https://github.com/wg/wrk.git wrk
cd wrk
make
sudo cp wrk /usr/local/bin
Now, let's execute a test using wrk:
bashewrk -t10 -c1000 -d10s -T30s --latency 'http://10.1.0.20:5000/parse?q=hello&project=5e1717fb0bdf66011ef82702'
Explanation:
-t10: Specifies 10 threads to be used for the test.
-c1000: Configures 1000 connections to be made concurrently.
-d10s: Sets the duration of the test to 10 seconds.
-T30s: Sets a 30-second timeout for each connection.
--latency: Enables latency measurement.
Results:
Thread Stats:
Average latency: 2.01s
Standard deviation: 980.91ms
Maximum latency: 6.36s
Requests/Sec:
Average: 48.45
Maximum: 290.00
Latency Distribution:
50% of requests were served in 2.01s
75% in 2.21s
90% in 3.23s
99% in 5.62s
Overall:
3247 requests were made in 10.09s
Total data transferred: 1.69MB
Average throughput: 321.77 requests/sec
Average transfer rate: 171.57KB/sec
The wrk tool provides valuable insights into the performance of our web application. In this experiment, we observed the latency distribution, average throughput, and request rates under a specific load scenario. By analyzing these metrics, developers can identify potential bottlenecks and optimize their application for better performance.
留言
張貼留言