0
我希望能夠在僅使用一個連接到服務器的相當快的速率(> 1500 /秒)爲POST消息使用駱駝HTTPS服務器。優化駱駝HTTP4用的KeepAlive
我試圖將keepalive設置爲true,但我仍然無法看到任何速度的提高。
接過了tcpdump在發送5個消息,我發現上的wireshark 5 SYN/ACK數據包。 可能SSL證書也在每個POST上發送。 (102包由tcpdump的捕獲,但所有我送5個「HelloWorld」的字符串)
有沒有什麼辦法可以加快速度?這是我使用的代碼:
CamelContext context = new DefaultCamelContext();
final HttpComponent http = (HttpComponent) context.getComponent("https4");
http.setConnectionsPerRoute(1);
http.setMaxTotalConnections(1);
HttpConfiguration httpConfiguration = new HttpConfiguration();
http.setHttpConfiguration(httpConfiguration);;
context.addComponent("fcpHttpComponent", http);
template = context.createProducerTemplate();
headers.put(Exchange.CONTENT_TYPE, "application/json");
headers.put(Exchange.HTTP_METHOD, HttpMethods.POST);
final String endpoint = "https://xxx.xxx.xxx.xxx:443";
try {
httpEndpoint = new HttpEndpoint(endpoint, http, new URI(endpoint));
httpEndpoint.configureProperties(headers);
PoolingHttpClientConnectionManager clientConnectionManager = new PoolingHttpClientConnectionManager();
SocketConfig socketConfig = SocketConfig.custom()
.setSoKeepAlive(true)
.setSoReuseAddress(true)
.setTcpNoDelay(true)
.setSndBufSize(10)
.build();
clientConnectionManager.setDefaultSocketConfig(socketConfig);
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.setMaxConnPerRoute(1);
clientBuilder.setConnectionManager(clientConnectionManager);
clientBuilder.build();
ConnectionKeepAliveStrategy keepAliveStrategy = new DefaultConnectionKeepAliveStrategy();
clientBuilder.setKeepAliveStrategy(keepAliveStrategy);
httpEndpoint.setClientBuilder(clientBuilder);
httpEndpoint.setClientConnectionManager(clientConnectionManager);
template.start();
context.start();
} catch (final Exception e) {
LOG.error("Exception while starting Camel context ", e);
}
//Call this method 5 times
template.asyncRequestBodyAndHeaders(httpEndpoint, message, headers);
SSL證書詳細信息以JVM參數的形式給出。我能夠發佈數據,但速度是我需要改進的。
[更新]我使用的Apache Tomcat 8我的服務器。 設置在server.xml中的以下內容:
<Connector
protocol="org.apache.coyote.http11.Http11NioProtocol"
port="443" maxThreads="200"
scheme="https" secure="true" SSLEnabled="true"
keystoreFile="/x/store.jks" keystorePass="y"
clientAuth="false" sslProtocol="TLS" maxKeepAliveRequests="-1" keepAliveTimeout="-1" />
有沒有別的東西,我需要配置我的服務器上呢?