A
A
avp2017-04-25 09:44:47
PHP
avp, 2017-04-25 09:44:47

How to make statistics on the loading time of web pages?

How to make statistics on the loading time of web pages? I have nginx and php5.6.
For some reason, my SuiteCRM pages take a long time to form.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2017-04-25
@BuriK666

nginx.org/ru/docs/http/ngx_http_upstream_module.ht...
$upstream_response_time

A
Alexey Sundukov, 2017-04-25
@alekciy

Set the $upstream_response_time variable to the log file format. I have this in /etc/nginx/nginx.conf:

http {

    ##
    # Basic Settings
    ##
    log_format main     '$remote_addr:$remote_port - $remote_user [$time_local] $host "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for" $request_time-$upstream_response_time';
....
}

Then in the logs there are two numbers at the end of the line:
The first digit allows you to identify "slow" clients (when the first digit is large and the second is small). The second shows how long the engine takes to generate pages. Allows you to identify problems on the backend. But such a command allows you to calculate the median of the page generation time:
cat nginx_access.log | awk -F\" '{print $9}' | grep -v ".--$" | awk -F\- '{print $2}' | sort -n | awk '{all[NR]=$1;} END {print all[int(NR*0.5)]}'
1.391

Total backend requests I have today:
cat nginx_access.log | awk -F\" '{print $9}' | grep -v ".--$" | wc -l
74557

Which in total tells me that today 50% (median) of backend requests, i.e. 37288 pieces completed in less than 1.391 seconds. Although I personally prefer to monitor the 85% percentile:
cat nginx_access.log | awk -F\" '{print $9}' | grep -v ".--$" | awk -F\- '{print $2}' | sort -n | awk '{all[NR]=$1;} END {print all[int(NR*0.85)]}'
1.869

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question