jira-importer opened a new issue, #1088:
URL: https://github.com/apache/httpcomponents-core/issues/1088

   **[Linton 
Miller](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=linton.miller)**
 opened 
**[HTTPCORE-586](https://issues.apache.org/jira/browse/HTTPCORE-586?redirect=false)**
 and commented
   
   LaxConnPool intentionally does not make strong guarantees about enforcing 
the maximum size of the connection pools. However, it has poor behaviour when 
hit with a block of concurrent requests all at once.
   
   e.g. if the pool max size is 2, and 20 lease request all arrive concurrently 
at once, it may well create 20 connections.
   
   That's because the pool size is limited by the leased size, but there's a 
gap in the code between testing the size and adding a leased entry:
   
   ```java
           if (pending.isEmpty() && leased.size() < max) {
               final PoolEntry<T, C> entry = new PoolEntry<>(route, timeToLive);
               addLeased(entry);
   ```
   
   Thus multiple threads can concurrently pass the leased.size() < max test and 
thus all create a new PoolEntry.
   
   That can be greatly improved by not using the leased.size() to track pool 
size, but to have a separate explicit AtomicInteger counting the number of 
created PoolEntries.
   
   
   ---
   
   **Affects:** 5.0-beta8
   
   **Remote Links:**
   - [GitHub Pull Request `#134`
   ](https://github.com/apache/httpcomponents-core/pull/134)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to