node.js - 在高山运行 curl 需要很长时间才能开始
问题描述
我有一个 node:8.9.2-alpine 图像,我尝试在其中运行
curl -o /dev/null -s -w 'Total: %{time_total}\n' 'https://feed.theplatform.com/' -v
通话需要 6 秒。如果我在本地运行相同的 curl 大约需要 0.5 秒。
我发现 nslookup 需要一些时间,所以我跑了
RUN apk add --update --no-cache bind-tools
但是我的卷曲仍然需要 6 秒。
/ # curl -o /dev/null -s -w 'Total: %{time_total}\n' 'https://feed.theplatform.com/' -v --trace-time
10:13:54.843110 * Trying 199.27.170.188...
10:13:54.843198 * TCP_NODELAY set
10:13:54.938974 * Connected to feed.theplatform.com (199.27.170.188) port 443 (#0)
10:13:54.939222 * ALPN, offering http/1.1
10:13:54.950969 * successfully set certificate verify locations:
10:13:54.951041 * CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: none
10:13:54.951198 * TLSv1.2 (OUT), TLS handshake, Client hello (1):
10:13:54.951222 } [512 bytes data]
10:13:55.046650 * TLSv1.2 (IN), TLS handshake, Server hello (2):
10:13:55.046875 { [85 bytes data]
10:13:55.047031 * TLSv1.2 (IN), TLS handshake, Certificate (11):
10:13:55.047063 { [3984 bytes data]
10:13:55.047965 * TLSv1.2 (IN), TLS handshake, Server finished (14):
10:13:55.047990 { [4 bytes data]
10:13:55.048175 * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
10:13:55.048197 } [262 bytes data]
10:13:55.048233 * TLSv1.2 (OUT), TLS change cipher, Client hello (1):
10:13:55.048253 } [1 bytes data]
10:13:55.048338 * TLSv1.2 (OUT), TLS handshake, Finished (20):
10:13:55.048358 } [16 bytes data]
10:13:55.147028 * TLSv1.2 (IN), TLS change cipher, Client hello (1):
10:13:55.147077 { [1 bytes data]
10:13:55.147205 * TLSv1.2 (IN), TLS handshake, Finished (20):
10:13:55.147227 { [16 bytes data]
10:13:55.147273 * SSL connection using TLSv1.2 / AES256-SHA256
10:13:55.147295 * ALPN, server did not agree to a protocol
10:13:55.147339 * Server certificate:
10:13:55.147395 * subject: C=US; ST=Washington; L=Seattle; O=thePlatform, LLC; OU=Network Operations; CN=feed.theplatform.com
10:13:55.147423 * start date: Oct 22 22:05:39 2015 GMT
10:13:55.147451 * expire date: Jan 5 22:35:38 2019 GMT
10:13:55.147495 * subjectAltName: host "feed.theplatform.com" matched cert's "feed.theplatform.com"
10:13:55.147531 * issuer: C=US; O=Entrust, Inc.; OU=See www.entrust.net/legal-terms; OU=(c) 2012 Entrust, Inc. - for authorized use only; CN=Entrust Certification Authority -L1K
10:13:55.147553 * SSL certificate verify ok.
10:13:55.147650 > GET / HTTP/1.1
10:13:55.147650 > Host: feed.theplatform.com
10:13:55.147650 > User-Agent: curl/7.60.0
10:13:55.147650 > Accept: */*
10:13:55.147650 >
10:13:55.244488 < HTTP/1.1 403 Forbidden
10:13:55.244544 < Date: Fri, 13 Jul 2018 10:13:55 GMT
10:13:55.244576 < Content-Type: text/html;charset=ISO-8859-1
10:13:55.244606 < Cache-Control: must-revalidate,no-cache,no-store
10:13:55.244637 < Content-Length: 1365
10:13:55.244668 < Connection: close
10:13:55.244699 < Server: Jetty(8.1.16.2)
10:13:55.244730 <
10:13:55.244760 { [1225 bytes data]
10:13:55.244901 * Closing connection 0
10:13:55.245043 * TLSv1.2 (OUT), TLS alert, Client hello (1):
10:13:55.245079 } [2 bytes data]
Total: 5.915162
enter code here
enter code here
如果我调用 http 版本,它仍然需要很长时间:
/ # curl -o /dev/null -s -w 'Total: %{time_total}\n' 'http://feed.theplatform.com/' -v --trace-time
10:12:29.865144 * Trying 199.27.170.188...
10:12:29.865215 * TCP_NODELAY set
10:12:29.961021 * Connected to feed.theplatform.com (199.27.170.188) port 80 (#0)
10:12:29.961119 > GET / HTTP/1.1
10:12:29.961119 > Host: feed.theplatform.com
10:12:29.961119 > User-Agent: curl/7.60.0
10:12:29.961119 > Accept: */*
10:12:29.961119 >
10:12:30.057339 < HTTP/1.1 403 Forbidden
10:12:30.057395 < Date: Fri, 13 Jul 2018 10:12:30 GMT
10:12:30.057425 < Content-Type: text/html;charset=ISO-8859-1
10:12:30.057453 < Cache-Control: must-revalidate,no-cache,no-store
10:12:30.057482 < Content-Length: 1365
10:12:30.057505 < Connection: close
10:12:30.057527 < Server: Jetty(8.1.16.2)
10:12:30.057554 <
10:12:30.057578 { [1365 bytes data]
10:12:30.057666 * Closing connection 0
Total: 5.705922
如果我使用 node:8.11.3-alpine 我有同样的问题
如时间所示,通话开始时出现问题。我该如何解决?
解决方案
这是我的名称服务器的问题。通过添加 %{time_namelookup} 并运行
curl -o /dev/null -s -w 'Total: %{time_total}\nTime Namelookup: %{time_namelookup}\n' 'http://feed.theplatform.com/' -v --trace-time
我得到了时间名称查询:5.514205
我尝试将名称服务器更改为 googles,然后在 0.5 秒内得到结果。
推荐阅读
- numpy - Object dtype dtype('O') 没有原生 HDF5 等效项
- python - 如何使用 Axes3D 使我的曲面图出现?
- php - 如何从我的 Web PHP 应用程序中检测到请求来自我的办公室网络?
- python - 如何使用两个列表推导创建 2d numpy ndarray
- apache-camel - Apache Camel Producer模板
- node.js - 检查 NodeJS 中的路径中是否存在 blob
- laravel - 我应该在 Laravel 中嵌套资源的路由吗?
- gradle - 想法(通过 Gradle)“无法解析:”来自 mavenCentral() 的 Sonatype Nexus 代理的依赖项
- ios - Angular Web App - 异步函数(Observables)在 IoS 设备(safari 和 chrome 浏览器)中无法正常工作
- solr - Broadleaf Commerce Solr 问题