When client access delay occurs, you can view the dashboard in Log Service to analyze the response time of the SLB instance to rapidly locate an abnormal backend server.
This tutorial introduces how to use access logs to rapidly locate an abnormal backend server. For more information, see Configure access logs.
Configure access logs
- A Layer-7 listener is added.
- Log Service is activated.
- Log on to the SLB console.
- In the left-side navigation pane, choose .
- Select a region.
- Click Authorize, and then click Confirm Authorization Policy to authorize SLB to write logs to Log Service.
If you are a RAM user, you must obtain permissions from the corresponding account. For more information, see Authorize a RAM user to use access logs.Note This step is required only at the first time.
- On the Access Logs page, find the target SLB instance and click Configure Logging.
- Select the LogProject and LogStore and then click OK.
If there is no available LogStore, click Log Service console to create log projects.Note Make sure that the name of the LogProject is globally unique and the region of the LogProject is the same as that of the SLB instance.
Search access logs
To search access logs, complete these steps:
- Go to the log search page. You can navigate to the search page from the SLB console or the Log Service Console:
- From the SLB console:
On the Access Logs page, click View Logs.
- From the Log Service Console:
On the Logstores page, click Search of the target Logstore.
- From the SLB console:
- Click the target log field to view detailed information.
- Enter an SQL statement to query access logs.
For example, enter the following SQL statement to query the Top20 clients, which is used for analyzing the request source to assist business decision-making.
* | select ip_to_province(client_ip) as client_ip_province, count(*) as pv group by client_ip_province order by pv desc limit 50
Locate the abnormal backend server
You can locate the abnormal backend server by checking the dashboard of Log Service.
- On the Log Service console, click the project link of the SLB instance.
- In the left-side navigation pane, click
- Click the link of the SLB access log.
- In the dashboard, view the value in the top upstream response time tab. You can select to display the Average upstream response time (s) in descending order to check if the response time of any backend server surpasses 1 second.
If so, run the ssh command to log on to the backend server. Check if the CPU has kept running at high levels and handle the high loads.