2017-06-15 54 views
2

我正在郵遞員發送HTTP GET請求。如果我使用域名而不是IP地址,http請求需要時間

所述第一請求是使用IP地址即

get 52.66.166.14 

這需要大約70ms的來完成。

第二請求是使用域名,即

get dev.iotrek.in 

這需要大約450ms內完成。

這種情況發生的原因是什麼?這是我在apis中得到的延遲。

我的服務器正在運行nginx-passenger。 我的後端在軌道上是紅寶石。

回答

0

這種差異可能等於您的DNS服務器延遲。

例如這裏是我的ISP的DNS請求:

$ curl --silent --output /dev/null example.com -w %{time_connect}:%{time_starttransfer}:%{time_total} 
0.142:0.252:0.252 

這裏是從另一個大陸的一個DNS請求:

$ curl --silent --output /dev/null example.com -w %{time_connect}:%{time_starttransfer}:%{time_total} 
0.414:0.525:0.525 

通知的time_connect是完全不同的。考慮使用DNS,地理上更適合你。

相關問題