-
Notifications
You must be signed in to change notification settings - Fork 910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp connection pool #1441
Revamp connection pool #1441
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1441 +/- ##
==========================================
+ Coverage 72.75% 72.88% +0.13%
==========================================
Files 617 613 -4
Lines 26842 26750 -92
Branches 3246 3248 +2
==========================================
- Hits 19528 19496 -32
+ Misses 5599 5543 -56
+ Partials 1715 1711 -4
Continue to review full report at Codecov.
|
core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/SafeConnectionPoolListener.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/HttpClientDelegate.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/ConnectionPoolListenerAdapter.java
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/HttpClientDelegate.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/HttpSessionHandler.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/SafeConnectionPoolListener.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/logging/ConnectionPoolLoggingListener.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/logging/ConnectionPoolLoggingListener.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java
Outdated
Show resolved
Hide resolved
@inch772 You might want to review this pull request since 1) the connection pooling has been written by you initially and 2) you might be looking for a chance to exercise your coding skill! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job~!
core/src/main/java/com/linecorp/armeria/client/HttpChannelPool.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/client/ConnectionPoolListenerAdapter.java
Show resolved
Hide resolved
LGTM again~! |
LGTM |
Related: line#818 Motivation: - Unlike HTTP/1 connections, HTTP/2 connections do not need to be removed from the connection pool. We has slight loss of efficiency because we currently remove an HTTP/2 connection from the pool and add it back. - Current connection pool implementation has unnecessarily deep type hierarchy and high level of indirection which weren't very useful. - There's circular package dependency between `armeria.client` and `armeria.client.pool` which is undesirable. Modifications: - Merged `HttpSessionChannelFactory`, `KeyedChannelPool` and `DefaultKeyedChannelPool` into `HttpChannelPool`. - Tuned the internal data structure of `DefaultKeyedChannelPool`. - `PoolKey` does not include `SessionProtocol` anymore. We keep separate `Map` for each `SessionProtocol`. - Improved the connection pool implementation so that the connections with the same session protocol are grouped together even if they were created from different URI schemes. For example, both `h2c://` and `http://` can create `h2c` connections, but their connections were treated differently, but not anymore. - Removed unnecessary synchronization since all code in `HttpChannelPool` should be run in an event loop. - Replaced `KeyedChannelPoolHandler` and its related classes with `ConnectionPoolListener` et al. - We do not notify the listeners about acquisition and release because it has no meaning for HTTP/2 and it is more meaningful to retrieve such information from `RequestLog`. Let me know if you have a suggestions for more listener methods. Result: - Fixes line#818 - Connection pool listener API has a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :-)
Thank you, reviewers! |
Related: line#818 Motivation: - Unlike HTTP/1 connections, HTTP/2 connections do not need to be removed from the connection pool. We has slight loss of efficiency because we currently remove an HTTP/2 connection from the pool and add it back. - Current connection pool implementation has unnecessarily deep type hierarchy and high level of indirection which weren't very useful. - There's circular package dependency between `armeria.client` and `armeria.client.pool` which is undesirable. Modifications: - Merged `HttpSessionChannelFactory`, `KeyedChannelPool` and `DefaultKeyedChannelPool` into `HttpChannelPool`. - Tuned the internal data structure of `DefaultKeyedChannelPool`. - `PoolKey` does not include `SessionProtocol` anymore. We keep separate `Map` for each `SessionProtocol`. - Improved the connection pool implementation so that the connections with the same session protocol are grouped together even if they were created from different URI schemes. For example, both `h2c://` and `http://` can create `h2c` connections, but their connections were treated differently, but not anymore. - Removed unnecessary synchronization since all code in `HttpChannelPool` should be run in an event loop. - Replaced `KeyedChannelPoolHandler` and its related classes with `ConnectionPoolListener` et al. - We do not notify the listeners about acquisition and release because it has no meaning for HTTP/2 and it is more meaningful to retrieve such information from `RequestLog`. Let me know if you have a suggestions for more listener methods. Result: - Fixes line#818 - Connection pool listener API has a breaking change.
Related: #818
Motivation:
removed from the connection pool. We has slight loss of efficiency
because we currently remove an HTTP/2 connection from the pool and
add it back.
hierarchy and high level of indirection which weren't very useful.
armeria.client
andarmeria.client.pool
which is undesirable.Modifications:
HttpSessionChannelFactory
,KeyedChannelPool
andDefaultKeyedChannelPool
intoHttpChannelPool
.DefaultKeyedChannelPool
.PoolKey
does not includeSessionProtocol
anymore. We keepseparate
Map
for eachSessionProtocol
.with the same session protocol are grouped together even if they
were created from different URI schemes. For example, both
h2c://
and
http://
can createh2c
connections, but their connectionswere treated differently, but not anymore.
HttpChannelPool
should be run in an event loop.KeyedChannelPoolHandler
and its related classes withConnectionPoolListener
et al.it has no meaning for HTTP/2 and it is more meaningful to retrieve
such information from
RequestLog
. Let me know if you have asuggestions for more listener methods.
Result: