Operations 2 min read

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.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How to Use AWK to Identify Slow Web Requests and Compute Average Response Times

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):

AWK script screenshot
AWK script screenshot

Running the script: awk -f avgtime_script access_log Sample output:

/a.php = 1
/b.php = 0
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Web serverlog analysisShell scripting
Java High-Performance Architecture
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.