-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Periodically remove inactive connection pool metrics (#6024)
Motivation: We observed that threads were blocked when multiple connections were closed simultaneously and the endpoint had a small number of event loops. https://github.com/line/armeria/blob/fa76e99fa6132545df3a8d05eeb81c5681ec8953/core/src/main/java/com/linecorp/armeria/client/ConnectionPoolMetrics.java#L79-L85 We have no exact evidence, but I guess Micrometer's `remove()` operation may take a long time. The other logic is a simple HashMap operation that does not block for a long time. Modifications: - Add a dedicated GC thread to remove inactive meters whose active connections are 0. - A jitter is added to prevent GC from executing simultaneously. - Unsed meters are removed every hour + jitter. - `ConnectionPoolListener` now implements `SafeCloseable` so users should close it when it is unused. Result: - Fix the bug where `EventLoop` is blocked for a long time by `ConnectionPoolListener.metricCollecting()` when a connection is closed.
- Loading branch information
Showing
7 changed files
with
320 additions
and
63 deletions.
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.