-
Notifications
You must be signed in to change notification settings - Fork 79
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
Improve connection pool. #337
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mikkokar
requested review from
kvosper,
dvlato and
VivianLopes
and removed request for
kvosper
November 9, 2018 16:25
kvosper
suggested changes
Nov 12, 2018
components/client/src/main/java/com/hotels/styx/client/ConnectionSettings.java
Show resolved
Hide resolved
components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java
Outdated
Show resolved
Hide resolved
components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java
Outdated
Show resolved
Hide resolved
components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java
Outdated
Show resolved
Hide resolved
components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java
Show resolved
Hide resolved
...lient/src/test/unit/java/com/hotels/styx/client/connectionpool/SimpleConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
...lient/src/test/unit/java/com/hotels/styx/client/connectionpool/SimpleConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
...lient/src/test/unit/java/com/hotels/styx/client/connectionpool/SimpleConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
...lient/src/test/unit/java/com/hotels/styx/client/connectionpool/SimpleConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
...lient/src/test/unit/java/com/hotels/styx/client/connectionpool/SimpleConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
Add pool metrics.
(Just retry 3 times).
- pending connection timeout - connection listener
…nnectionpool/SimpleConnectionPoolTest.java Co-Authored-By: mikkokar <mikko.e.karjalainen@gmail.com>
…nnectionpool/SimpleConnectionPoolTest.java Co-Authored-By: mikkokar <mikko.e.karjalainen@gmail.com>
mikkokar
force-pushed
the
connection-pool
branch
from
November 14, 2018 10:45
ce2b773
to
fad7bd1
Compare
kvosper
approved these changes
Nov 14, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes: #333.
This is a complete rewrite of the Styx connection pool.
It addresses all known problems:
Pool Behaviour Overview
The improved pool has two queues:
activeConnections
contains all TCP connections that are immediately available at the pool. Any connections in this pool are already connected and ready to serve traffic.waitingSubscribers
is a FIFO queue for storing, well, waiting subscribers (aka pending connections).Borrow Connection
When a connection is borrowed, the pool checks if there are any immediately available connections in the
activeConnections
queue.If yes:
activeConnection
and emit via thePublisher
interface.If no:
waitingSubscribers
queue.Return Connection
When a connection is returned, offer it to the longest waiting subscriber in the
waitingSubscribers
queue (assuming the connection is still alive). If nobody is waiting (thewatingSubscribers
queue is empty) then put the connection back to theactiveConnections
queue.The pool disposes any connection that is returned as disconnected.
TCP Connection Establishment completed
Behaves much like connection return. The established connection is first offered to a waiting subscriber. The connection is queued in the
activeConnections
when there are no waiting subscribers.TCP Connection Termination
Eagerly trigger a new connection establishment.
Subscriber Cancels
Remove a cancelled subscriber from the
waitingSubscribers
queue.