How to Use AWK to Identify Slow Web Requests and Compute Average Response Times
Learn how to parse web server access logs with AWK, aggregate response times per URL, calculate average latency for each request, and output the results, enabling you to pinpoint long‑running requests that degrade system performance.
Purpose
Identify which requests have long‑term impact on system performance.
Method
Web server logs record response time for each request. By aggregating the total response time for identical URLs and dividing by the number of accesses, you obtain the average response time per request.
For example, if /a.php appears three times with response times 1, 2, and 3, its average is (1+2+3)/3.
Implementation
Use AWK to process each log line, sum response times and counts, then compute averages.
In typical logs the response time is in column 6 and the URL is in column 8.
Example AWK script (shown as an image):
Running the script: awk -f avgtime_script access_log Sample output:
/a.php = 1
/b.php = 0Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
