Article directory
1. Demand
In the past two days, the interfaces encountered in the dev environment responded very slowly, and none of the interfaces exceeded 1s. There are two certain points:
- Gateway upstream: outer Nginx service, domain name resolution, etc.
- Downstream of the gateway: the business service of the first level of the lower layer of Spring Cloud Gateway
After viewing SkyWorking, the response time of each interface and service calls are normal.
Through the way of IP + PORT, the access interface speed is also normal. Then it is the problem of the domain name and Nginx layer. It can be located by means of curl.
2. Realize
2.1 curl command output format
curl-format.txt
time_namelookup[DNS解析耗时]: %{
time_namelookup}\n
time_connect[TCP建连耗时]: %{
time_connect}\n
time_appconnect[SSL握手耗时]: %{
time_appconnect}\n
time_redirect[请求事务耗时]: %{
time_redirect}\n
time_pretransfer[请求到开始响应耗时]: %{
time_pretransfer}\n
time_starttransfer[请求到开始传输耗时]: %{
time_starttransfer}\n
------------------------------------------------------------\n
time_total[总耗时]: %{
time_total}\n\n\n
2.2 Execute the curl command
curl -w "@curl-format.txt" -o /dev/null -s -L -H "Content-Type: application/json" -H "Authorization: Bearer b28b9jkklla4c4782yui5bfbac55" -X GET https://www.baidu.com
[root@aa tmp]# curl -w "@curl-format.txt" -o /dev/null -s -L -H "Content-Type: application/json" -H "Authorization: Bearer b28b9jkklla4c4782yui5bfbac55" -X GET https://www.baidu.com
time_namelookup[DNS解析耗时]: 0.004
time_connect[TCP建连耗时]: 0.034
time_appconnect[SSL握手耗时]: 0.171
time_redirect[请求事务耗时]: 0.000
time_pretransfer[请求到开始响应耗时]: 0.171
time_starttransfer[请求到开始传输耗时]: 0.201
------------------------------------------------------------
time_total[总耗时]: 0.201