- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
免责声明:我知道这个问题有重复项(one、two、three),但是:
我正在尝试从此 URL 获取内容: https://api.vk.com/method/database.getCountries
Mac OS Chrome 浏览器在 70-100 毫秒内获取内容(我查看开发工具的“网络”选项卡),但我使用 apache http 客户端 4.5.2 的代码在 内获取内容180-200 毫秒。我还有一个带有 ( kevinsawicki-http-request) 库的代码,女巫在 70-100 毫秒内获取此页面(就像在浏览器中一样)。这种差异对我和(我认为)许多提出类似问题的其他开发者来说至关重要。
我的代码:
RequestConfig requestConfig = RequestConfig.custom()
.setCookieSpec(CookieSpecs.IGNORE_COOKIES)
.setSocketTimeout(60000)
.setConnectTimeout(5000)
.setConnectionRequestTimeout(5000)
.build();
SocketConfig socketConfig = SocketConfig.custom()
.setSoKeepAlive(false) //true - no differences in request time
.setTcpNoDelay(true)
.build();
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
connManager.setMaxTotal(50);
connManager.setDefaultMaxPerRoute(2);
CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultSocketConfig(socketConfig)
.setConnectionManager(connManager)
.setDefaultRequestConfig(requestConfig)
.setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36")
.build();
//1
long t11 = System.currentTimeMillis();
try(CloseableHttpResponse response1 = httpClient.execute(new HttpGet("https://api.vk.com/method/database.getCountries"))) {
code1 = response1.getStatusLine().getStatusCode();
}
long t12 = System.currentTimeMillis();
long reqTime1 = t12 - t11;
//2
long t21 = System.currentTimeMillis();
try(CloseableHttpResponse response2 = httpClient.execute(new HttpGet("https://api.vk.com/method/database.getCountries"))) {
code2 = response2.getStatusLine().getStatusCode();
}
long t22 = System.currentTimeMillis();
long reqTime2 = t22 - t21;
//3
long t31 = System.currentTimeMillis();
try(CloseableHttpResponse response3 = httpClient.execute(new HttpGet("https://api.vk.com/method/database.getCountries"))) {
code3 = response3.getStatusLine().getStatusCode();
}
long t32 = System.currentTimeMillis();
long reqTime3 = t32 - t31;
log.trace("reqTime1: {}", reqTime1);
log.trace("reqTime2: {}", reqTime2);
log.trace("reqTime3: {}", reqTime3);
这打印:
reqTime1: 198
reqTime2: 168
reqTime3: 160
(所有 3 个请求都返回 200 个 http 代码)
我有 JVM 选项:
-Djavax.net.ssl.keyStore=/path/to/my/keyStore.jks
-Djavax.net.ssl.keyStorePassword=my_password
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
-Dorg.apache.commons.logging.simplelog.showdatetime=true
-Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG
-Dorg.apache.commons.logging.simplelog.log.org.apache.http.wire=ERROR
(我的keyStore.jks中添加了vk.com证书)
这里是http-client的内部日志
[err] 2016/11/11 14:54:35:411 MSK [DEBUG] RequestAddCookies - CookieSpec selected: ignoreCookies
[err] 2016/11/11 14:54:35:412 MSK [DEBUG] RequestAuthCache - Auth cache not set in the context
[err] 2016/11/11 14:54:35:413 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 50]
[err] 2016/11/11 14:54:35:413 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 6][route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 50]
[err] 2016/11/11 14:54:35:413 MSK [DEBUG] MainClientExec - Opening connection {s}->https://api.vk.com:443
[err] 2016/11/11 14:54:35:414 MSK [DEBUG] DefaultHttpClientConnectionOperator - Connecting to api.vk.com/87.240.165.75:443
[err] 2016/11/11 14:54:35:414 MSK [DEBUG] SSLConnectionSocketFactory - Connecting socket to api.vk.com/87.240.165.75:443 with timeout 5000
[err] 2016/11/11 14:54:35:494 MSK [DEBUG] SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
[err] 2016/11/11 14:54:35:495 MSK [DEBUG] SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
[err] 2016/11/11 14:54:35:495 MSK [DEBUG] SSLConnectionSocketFactory - Starting handshake
[err] 2016/11/11 14:54:35:641 MSK [DEBUG] SSLConnectionSocketFactory - Secure session established
[err] 2016/11/11 14:54:35:642 MSK [DEBUG] SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
[err] 2016/11/11 14:54:35:642 MSK [DEBUG] SSLConnectionSocketFactory - negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
[err] 2016/11/11 14:54:35:642 MSK [DEBUG] SSLConnectionSocketFactory - peer principal: CN=*.vk.com, OU=Domain Control Validated
[err] 2016/11/11 14:54:35:642 MSK [DEBUG] SSLConnectionSocketFactory - peer alternative names: [*.vk.com, vk.com]
[err] 2016/11/11 14:54:35:642 MSK [DEBUG] SSLConnectionSocketFactory - issuer principal: CN=Go Daddy Secure Certificate Authority - G2, OU=http://certs.godaddy.com/repository/, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US
[err] 2016/11/11 14:54:35:643 MSK [DEBUG] DefaultHttpClientConnectionOperator - Connection established 172.20.10.2:55317<->87.240.165.75:443
[err] 2016/11/11 14:54:35:643 MSK [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-6: set socket timeout to 60000
[err] 2016/11/11 14:54:35:643 MSK [DEBUG] MainClientExec - Executing request GET /method/database.getCountries HTTP/1.1
[err] 2016/11/11 14:54:35:643 MSK [DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[err] 2016/11/11 14:54:35:644 MSK [DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[err] 2016/11/11 14:54:35:644 MSK [DEBUG] headers - http-outgoing-6 >> GET /method/database.getCountries HTTP/1.1
[err] 2016/11/11 14:54:35:644 MSK [DEBUG] headers - http-outgoing-6 >> Host: api.vk.com
[err] 2016/11/11 14:54:35:644 MSK [DEBUG] headers - http-outgoing-6 >> Connection: Keep-Alive
[err] 2016/11/11 14:54:35:645 MSK [DEBUG] headers - http-outgoing-6 >> User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
[err] 2016/11/11 14:54:35:645 MSK [DEBUG] headers - http-outgoing-6 >> Accept-Encoding: gzip,deflate
[err] 2016/11/11 14:54:35:725 MSK [DEBUG] headers - http-outgoing-6 << HTTP/1.1 200 OK
[err] 2016/11/11 14:54:35:725 MSK [DEBUG] headers - http-outgoing-6 << Server: Apache
[err] 2016/11/11 14:54:35:726 MSK [DEBUG] headers - http-outgoing-6 << Date: Fri, 11 Nov 2016 11:54:35 GMT
[err] 2016/11/11 14:54:35:726 MSK [DEBUG] headers - http-outgoing-6 << Content-Type: application/json; charset=utf-8
[err] 2016/11/11 14:54:35:726 MSK [DEBUG] headers - http-outgoing-6 << Content-Length: 286
[err] 2016/11/11 14:54:35:727 MSK [DEBUG] headers - http-outgoing-6 << Connection: keep-alive
[err] 2016/11/11 14:54:35:727 MSK [DEBUG] headers - http-outgoing-6 << X-Powered-By: PHP/3.7212
[err] 2016/11/11 14:54:35:727 MSK [DEBUG] headers - http-outgoing-6 << Set-Cookie: remixlang=0; expires=Sun, 05 Nov 2017 18:31:29 GMT; path=/; domain=.vk.com
[err] 2016/11/11 14:54:35:727 MSK [DEBUG] headers - http-outgoing-6 << Pragma: no-cache
[err] 2016/11/11 14:54:35:728 MSK [DEBUG] headers - http-outgoing-6 << Cache-control: no-store
[err] 2016/11/11 14:54:35:728 MSK [DEBUG] headers - http-outgoing-6 << Content-Encoding: gzip
[err] 2016/11/11 14:54:35:728 MSK [DEBUG] MainClientExec - Connection can be kept alive indefinitely
[err] 2016/11/11 14:54:35:729 MSK [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-6: Close connection
[err] 2016/11/11 14:54:35:730 MSK [DEBUG] MainClientExec - Connection discarded
[err] 2016/11/11 14:54:35:730 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 6][route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 50]
[err] 2016/11/11 14:54:35:730 MSK [DEBUG] RequestAddCookies - CookieSpec selected: ignoreCookies
[err] 2016/11/11 14:54:35:731 MSK [DEBUG] RequestAuthCache - Auth cache not set in the context
[err] 2016/11/11 14:54:35:731 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 50]
[err] 2016/11/11 14:54:35:731 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 7][route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 50]
[err] 2016/11/11 14:54:35:731 MSK [DEBUG] MainClientExec - Opening connection {s}->https://api.vk.com:443
[err] 2016/11/11 14:54:35:732 MSK [DEBUG] DefaultHttpClientConnectionOperator - Connecting to api.vk.com/87.240.165.75:443
[err] 2016/11/11 14:54:35:732 MSK [DEBUG] SSLConnectionSocketFactory - Connecting socket to api.vk.com/87.240.165.75:443 with timeout 5000
[err] 2016/11/11 14:54:35:786 MSK [DEBUG] SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
[err] 2016/11/11 14:54:35:787 MSK [DEBUG] SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
[err] 2016/11/11 14:54:35:787 MSK [DEBUG] SSLConnectionSocketFactory - Starting handshake
[err] 2016/11/11 14:54:35:909 MSK [DEBUG] SSLConnectionSocketFactory - Secure session established
[err] 2016/11/11 14:54:35:910 MSK [DEBUG] SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
[err] 2016/11/11 14:54:35:910 MSK [DEBUG] SSLConnectionSocketFactory - negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
[err] 2016/11/11 14:54:35:910 MSK [DEBUG] SSLConnectionSocketFactory - peer principal: CN=*.vk.com, OU=Domain Control Validated
[err] 2016/11/11 14:54:35:911 MSK [DEBUG] SSLConnectionSocketFactory - peer alternative names: [*.vk.com, vk.com]
[err] 2016/11/11 14:54:35:911 MSK [DEBUG] SSLConnectionSocketFactory - issuer principal: CN=Go Daddy Secure Certificate Authority - G2, OU=http://certs.godaddy.com/repository/, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US
[err] 2016/11/11 14:54:35:911 MSK [DEBUG] DefaultHttpClientConnectionOperator - Connection established 172.20.10.2:55318<->87.240.165.75:443
[err] 2016/11/11 14:54:35:912 MSK [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-7: set socket timeout to 60000
[err] 2016/11/11 14:54:35:912 MSK [DEBUG] MainClientExec - Executing request GET /method/database.getCountries HTTP/1.1
[err] 2016/11/11 14:54:35:912 MSK [DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[err] 2016/11/11 14:54:35:913 MSK [DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[err] 2016/11/11 14:54:35:913 MSK [DEBUG] headers - http-outgoing-7 >> GET /method/database.getCountries HTTP/1.1
[err] 2016/11/11 14:54:35:913 MSK [DEBUG] headers - http-outgoing-7 >> Host: api.vk.com
[err] 2016/11/11 14:54:35:913 MSK [DEBUG] headers - http-outgoing-7 >> Connection: Keep-Alive
[err] 2016/11/11 14:54:35:914 MSK [DEBUG] headers - http-outgoing-7 >> User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
[err] 2016/11/11 14:54:35:914 MSK [DEBUG] headers - http-outgoing-7 >> Accept-Encoding: gzip,deflate
[err] 2016/11/11 14:54:35:989 MSK [DEBUG] headers - http-outgoing-7 << HTTP/1.1 200 OK
[err] 2016/11/11 14:54:35:989 MSK [DEBUG] headers - http-outgoing-7 << Server: Apache
[err] 2016/11/11 14:54:35:990 MSK [DEBUG] headers - http-outgoing-7 << Date: Fri, 11 Nov 2016 11:54:35 GMT
[err] 2016/11/11 14:54:35:990 MSK [DEBUG] headers - http-outgoing-7 << Content-Type: application/json; charset=utf-8
[err] 2016/11/11 14:54:35:990 MSK [DEBUG] headers - http-outgoing-7 << Content-Length: 286
[err] 2016/11/11 14:54:35:990 MSK [DEBUG] headers - http-outgoing-7 << Connection: keep-alive
[err] 2016/11/11 14:54:35:991 MSK [DEBUG] headers - http-outgoing-7 << X-Powered-By: PHP/3.7212
[err] 2016/11/11 14:54:35:991 MSK [DEBUG] headers - http-outgoing-7 << Set-Cookie: remixlang=0; expires=Wed, 08 Nov 2017 21:16:16 GMT; path=/; domain=.vk.com
[err] 2016/11/11 14:54:35:991 MSK [DEBUG] headers - http-outgoing-7 << Pragma: no-cache
[err] 2016/11/11 14:54:35:991 MSK [DEBUG] headers - http-outgoing-7 << Cache-control: no-store
[err] 2016/11/11 14:54:35:992 MSK [DEBUG] headers - http-outgoing-7 << Content-Encoding: gzip
[err] 2016/11/11 14:54:35:992 MSK [DEBUG] MainClientExec - Connection can be kept alive indefinitely
[err] 2016/11/11 14:54:35:992 MSK [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-7: Close connection
[err] 2016/11/11 14:54:35:993 MSK [DEBUG] MainClientExec - Connection discarded
[err] 2016/11/11 14:54:35:993 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 7][route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 50]
[err] 2016/11/11 14:54:35:994 MSK [DEBUG] RequestAddCookies - CookieSpec selected: ignoreCookies
[err] 2016/11/11 14:54:35:994 MSK [DEBUG] RequestAuthCache - Auth cache not set in the context
[err] 2016/11/11 14:54:35:994 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 50]
[err] 2016/11/11 14:54:35:995 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 8][route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 50]
[err] 2016/11/11 14:54:35:995 MSK [DEBUG] MainClientExec - Opening connection {s}->https://api.vk.com:443
[err] 2016/11/11 14:54:35:996 MSK [DEBUG] DefaultHttpClientConnectionOperator - Connecting to api.vk.com/87.240.165.75:443
[err] 2016/11/11 14:54:35:996 MSK [DEBUG] SSLConnectionSocketFactory - Connecting socket to api.vk.com/87.240.165.75:443 with timeout 5000
[err] 2016/11/11 14:54:36:050 MSK [DEBUG] SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
[err] 2016/11/11 14:54:36:050 MSK [DEBUG] SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
[err] 2016/11/11 14:54:36:050 MSK [DEBUG] SSLConnectionSocketFactory - Starting handshake
[err] 2016/11/11 14:54:36:117 MSK [DEBUG] SSLConnectionSocketFactory - Secure session established
[err] 2016/11/11 14:54:36:118 MSK [DEBUG] SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
[err] 2016/11/11 14:54:36:118 MSK [DEBUG] SSLConnectionSocketFactory - negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
[err] 2016/11/11 14:54:36:118 MSK [DEBUG] SSLConnectionSocketFactory - peer principal: CN=*.vk.com, OU=Domain Control Validated
[err] 2016/11/11 14:54:36:118 MSK [DEBUG] SSLConnectionSocketFactory - peer alternative names: [*.vk.com, vk.com]
[err] 2016/11/11 14:54:36:118 MSK [DEBUG] SSLConnectionSocketFactory - issuer principal: CN=Go Daddy Secure Certificate Authority - G2, OU=http://certs.godaddy.com/repository/, O="GoDaddy.com, Inc.", L=Scottsdale, ST=Arizona, C=US
[err] 2016/11/11 14:54:36:119 MSK [DEBUG] DefaultHttpClientConnectionOperator - Connection established 172.20.10.2:55331<->87.240.165.75:443
[err] 2016/11/11 14:54:36:119 MSK [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-8: set socket timeout to 60000
[err] 2016/11/11 14:54:36:119 MSK [DEBUG] MainClientExec - Executing request GET /method/database.getCountries HTTP/1.1
[err] 2016/11/11 14:54:36:119 MSK [DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[err] 2016/11/11 14:54:36:119 MSK [DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[err] 2016/11/11 14:54:36:120 MSK [DEBUG] headers - http-outgoing-8 >> GET /method/database.getCountries HTTP/1.1
[err] 2016/11/11 14:54:36:120 MSK [DEBUG] headers - http-outgoing-8 >> Host: api.vk.com
[err] 2016/11/11 14:54:36:120 MSK [DEBUG] headers - http-outgoing-8 >> Connection: Keep-Alive
[err] 2016/11/11 14:54:36:120 MSK [DEBUG] headers - http-outgoing-8 >> User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
[err] 2016/11/11 14:54:36:120 MSK [DEBUG] headers - http-outgoing-8 >> Accept-Encoding: gzip,deflate
[err] 2016/11/11 14:54:36:188 MSK [DEBUG] headers - http-outgoing-8 << HTTP/1.1 200 OK
[err] 2016/11/11 14:54:36:189 MSK [DEBUG] headers - http-outgoing-8 << Server: Apache
[err] 2016/11/11 14:54:36:189 MSK [DEBUG] headers - http-outgoing-8 << Date: Fri, 11 Nov 2016 11:54:36 GMT
[err] 2016/11/11 14:54:36:189 MSK [DEBUG] headers - http-outgoing-8 << Content-Type: application/json; charset=utf-8
[err] 2016/11/11 14:54:36:189 MSK [DEBUG] headers - http-outgoing-8 << Content-Length: 286
[err] 2016/11/11 14:54:36:190 MSK [DEBUG] headers - http-outgoing-8 << Connection: keep-alive
[err] 2016/11/11 14:54:36:190 MSK [DEBUG] headers - http-outgoing-8 << X-Powered-By: PHP/3.7212
[err] 2016/11/11 14:54:36:190 MSK [DEBUG] headers - http-outgoing-8 << Set-Cookie: remixlang=0; expires=Thu, 16 Nov 2017 00:20:15 GMT; path=/; domain=.vk.com
[err] 2016/11/11 14:54:36:190 MSK [DEBUG] headers - http-outgoing-8 << Pragma: no-cache
[err] 2016/11/11 14:54:36:190 MSK [DEBUG] headers - http-outgoing-8 << Cache-control: no-store
[err] 2016/11/11 14:54:36:190 MSK [DEBUG] headers - http-outgoing-8 << Content-Encoding: gzip
[err] 2016/11/11 14:54:36:191 MSK [DEBUG] MainClientExec - Connection can be kept alive indefinitely
[err] 2016/11/11 14:54:36:191 MSK [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-8: Close connection
[err] 2016/11/11 14:54:36:192 MSK [DEBUG] MainClientExec - Connection discarded
[err] 2016/11/11 14:54:36:192 MSK [DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 8][route: {s}->https://api.vk.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 50]
[14:54:36.193] TRACE [proliker.utils.TestService.hc(TestService.java:300)]: reqTime1: 319
[14:54:36.193] TRACE [proliker.utils.TestService.hc(TestService.java:301)]: reqTime2: 264
[14:54:36.194] TRACE [proliker.utils.TestService.hc(TestService.java:302)]: reqTime3: 198
当然,上述测试是在关闭内部日志记录的情况下执行的,因为它会为每个请求额外增加约 50 毫秒。
我已经阅读了所有 apache http-client 站点文档三次,我不知道去哪里看,哪里有错误。我非常希望,一些极客可以帮助我提高请求速度。
最佳答案
[err] 2016/11/11 14:54:36:191 MSK [DEBUG] MainClientExec - Connection can be kept alive indefinitely
[err] 2016/11/11 14:54:36:191 MSK [DEBUG] DefaultManagedHttpClientConnection - http-outgoing-8: Close connection
[err] 2016/11/11 14:54:36:192 MSK [DEBUG] MainClientExec - Connection discarded
如果这不是故意的,那么使 HttpClient 更快的最简单方法是重新使用连接(尤其是在使用 SSL/TLS 传输安全性时)。
始终确保响应内容已被完全消耗(通过从内容流读取直到流结束或关闭流)。
try(CloseableHttpResponse response1 = httpClient.execute(new HttpGet("https://api.vk.com/method/database.getCountries"))) {
int code1 = response1.getStatusLine().getStatusCode();
EntityUtils.consume(response1.getEntity());
}
关于java - Apache Http 客户端比浏览器慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40547771/
自己试试看: import pandas as pd s=pd.Series(xrange(5000000)) %timeit s.loc[[0]] # You need pandas 0.15.1
我最近开始使用 Delphi 中的 DataSnap 来生成 RESTful Web 服务。在遵循 Marco Cantu 本人和互联网上其他几个人的指导后,我成功地使整个“链条”正常工作。 但是有一
我一直在为操作系统类(class)编写以下代码,但结果有些奇怪。该代码创建x线程并同时运行它们,以便将两个平方矩阵相乘。每个线程将输入矩阵的Number_of_rows/Number_of_threa
我正在尝试确定何时使用 parallel包以加快运行某些分析所需的时间。我需要做的一件事是创建矩阵,比较具有不同行数的两个数据框中的变量。我在 StackOverflow 上问了一个关于有效方法的问题
我最近对我的代码进行了一些清理,并在此过程中更改了此内容(不完全是真实的代码): read = act readSTRef test1 term i var = do t v^!terms.
我正在计时查询和同一个查询的执行时间,分页。 foreach (var x in productSource.OrderBy(p => p.AdminDisplayName) .Wher
我正在开发一个项目 (WPF),我有一个 Datagrid 从数据库加载超过 5000 条记录,所以我使用 BackgroundWorker 来通知用户数据正在加载,但它太慢了,我需要等待将近 2分钟
我在查询中添加 ORDER BY 时遇到问题。没有 ORDER BY 查询大约需要 26ms,一旦我添加 ORDER BY,它大约需要 20s。 我尝试了几种不同的方法,但似乎可以减少时间。 尝试 F
我是 Android 开发新手,遇到了性能问题。当我的 GridView 有太多项目时,它会变得有点慢。有什么方法可以让它运行得更快一些吗? 这是我使用的代码: 适配器: public class C
这里的要点是: 1.设置query_cache_type = 0;重置查询缓存; 2.在 heidisql(或任何其他客户端 UI)中运行任何查询 --> 执行,例如 45 毫秒 3.使用以下代码运行
想象下表: CREATE TABLE drops( id BIGSERIAL PRIMARY KEY, loc VARCHAR(5) NOT NULL, tag INT NOT
我的表 test_table 中的示例数据: date symbol value created_time 2010-01-09 symbol1
首先,如果已经有人问过这个问题,我深表歉意,至少我找不到任何东西。 无论如何,我将每 5 分钟运行一次 cron 任务。该脚本加载 79 个外部页面,而每个页面包含大约 200 个我需要在数据库中检查
我有下面的 SQL 代码,它来自 MySQL 数据库。现在它给了我期望的结果,但是查询很慢,我想我应该在进一步之前加快这个查询的速度。 表agentstatusinformation有: PKEY(主
我需要获取一个对象在 Core Data 中数千个其他对象之间的排名。现在,这是我的代码: - (void)rankMethod { //Fetch all objects NSFet
我正在编写一个应用程序,我需要在其中读取用户的地址簿并显示他所有联系人的列表。我正在测试的 iPhone 有大约 100 个联系人,加载联系人确实需要很多时间。 ABAddressBookRef ad
我正在使用 javascript 将 160 行添加到包含 10 列的表格中。如果我这样做: var cellText = document.createTextNode(value); cell.a
我是 Swift 的新手,我已经设置了一个 tableView,它从 JSON 提要中提取数据并将其加载到表中。 表格加载正常,但是当表格中有超过 10 个单元格时,它会变得缓慢且有些滞后,特别是它到
我在 InitializeCulture 和 Page_PreInit 事件之间的 asp.net 页面中遇到性能问题。当我重写 DeterminePostBackMode() 时,我发现问题出在 b
我在 Hetzner 上有一个带有 256GB RAM 6 个 CPU(12 个线程) 的专用服务器,它位于德国。我有 CENTOS 7.5。 EA4。 我的问题是 SSL。每天大约 2 小时,我们在
我是一名优秀的程序员,十分优秀!