You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2018/10/29 09:35:00 UTC

[jira] [Commented] (HTTPCLIENT-1948) Apache HttpAsyncClient gets hanged for some seconds in case of high load

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666913#comment-16666913 ] 

Oleg Kalnichevski commented on HTTPCLIENT-1948:
-----------------------------------------------

What is _specifically_ the bug you are reporting and how are we expected to reproduce it?

Oleg

> Apache HttpAsyncClient gets hanged for some seconds in case of high load
> ------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1948
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1948
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (async)
>    Affects Versions: 4.4.1
>         Environment: Production
>            Reporter: Al Mohammed Abdullah
>            Priority: Major
>
> *Apache HttpAsyncClient gets hanged for some seconds in case of high load:*
> I have tried by creating connection Manager with max pool of 200 Connections and also eliminated idle,expired connections by running separate runnable thread.
> Here is code snippet
> {{public void init() { PoolingNHttpClientConnectionManager connectionManager = null; try { connectionManager = new PoolingNHttpClientConnectionManager (new DefaultConnectingIOReactor(IOReactorConfig.DEFAULT)); } catch (IOReactorException e1) { } // Increase max total connection to 200 connectionManager.setMaxTotal(200)); // Increase default max connection per route to 20 connectionManager.setDefaultMaxPerRoute(20); // Increase max connections for localhost:80 to 50 HttpHost localhost = new HttpHost(127.0.0.1, 8080); int maxPerRoute = Integer.parseInt(20); connectionManager.setMaxPerRoute(new HttpRoute(localhost), maxPerRoute); client = HttpAsyncClients.custom() .setConnectionManager((NHttpClientConnectionManager) connectionManager) .build(); client.start(); try { url = new URL(httpParams.getUrlParam()); } catch (MalformedURLException e) { e.printStackTrace(); } }}}
> Above method will call at server startup, Below method used for initiating request.
> {{private void invokePostMethodWithJsonContent(final JSONObject content, URL url2) throws HTTPException { HttpPost request = null; Future<HttpResponse> future = null; HttpResponse httpResp = null; String responseMsg = null; try { request = new HttpPost(url2.toString()); request.setEntity(new StringEntity(content.toString(), ContentType.APPLICATION_JSON)); final RequestConfig requestConfig = RequestConfig.custom() .setSocketTimeout(Integer.parseInt(httpParams.getReadTimeout())) .setConnectTimeout(Integer.parseInt(httpParams.getConnectionTimeout())) .setConnectionRequestTimeout(Integer.parseInt(httpParams.getReadTimeout())).build(); request.setConfig(requestConfig); Long startTime = new Date().getTime(); LOGGER.debug("time {}", new Date().getTime()); future = client.execute(request, null); httpResp = (HttpResponse) future.get(); if (httpResp != null && httpResp.getEntity() != null) { final HttpEntity responseEntity = httpResp.getEntity(); if (responseEntity != null) { responseMsg = EntityUtils.toString(responseEntity); } } } catch (final IOException e) { throw new HTTPException("Error in http adapter", "MPYHA00001", e); } catch (final JSONException e) { throw new HTTPException("Unable to process due to json error", "MPYHA00002", e); } catch (final InterruptedException e) { throw new HTTPException("Unable to connect http adapter", "MPYHA00003", e); } catch (final ExecutionException e) { throw new HTTPException("Error in http adapter", errorCode, e); } finally { httpResp = null; future = null; request = null; } }}}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org