Remove idle_pool_size config

Clients created when idle_capacity is reached but not max_capacity
are discarded as soon as the client is checked back into the pool,
not when the connection is closed.

This means that allowing idle_capacity to be lower than max_capacity
essentially just makes the remaining clients a checkout timeout
deterrent that gets thrown away as soon as it is used. Not useful
for reusing connections whatsoever during peak load times
This commit is contained in:
syeopite 2025-04-10 00:42:43 -07:00
parent 24a6c31b18
commit 0865bc55fd
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A
4 changed files with 1 additions and 31 deletions

View File

@ -214,25 +214,6 @@ https_only: false
##
#pool_size: 100
##
## Max idle size of the HTTP pool used to connect to youtube. Each
## domain ('youtube.com', 'ytimg.com', ...) has its own pool.
##
## This means that when releasing a connection back into the pool, it will
## be closed if there are already more than idle_pool_size connections within
## the pool
##
## Do note that idle connections are kept around forever without any way of
## timing them out.
##
## When unset this value has the same value as pool_size
##
## Accepted values: a positive integer
## Default: <none> (internally this means that it has the same value as pool_size)
##
#idle_pool_size:
##
## Amount of seconds to wait for a client to be free from the pool
## before raising an error

View File

@ -94,7 +94,6 @@ SOFTWARE = {
YT_POOL = Invidious::ConnectionPool::Pool.new(
max_capacity: CONFIG.pool_size,
idle_capacity: CONFIG.idle_pool_size,
timeout: CONFIG.pool_checkout_timeout
) do
next make_client(YT_URL, force_resolve: true)
@ -106,7 +105,6 @@ GGPHT_URL = URI.parse("https://yt3.ggpht.com")
GGPHT_POOL = Invidious::ConnectionPool::Pool.new(
max_capacity: CONFIG.pool_size,
idle_capacity: CONFIG.idle_pool_size,
timeout: CONFIG.pool_checkout_timeout
) do
next make_client(GGPHT_URL, force_resolve: true)
@ -114,7 +112,6 @@ end
COMPANION_POOL = Invidious::ConnectionPool::Pool.new(
max_capacity: CONFIG.pool_size,
idle_capacity: CONFIG.idle_pool_size
) do
companion = CONFIG.invidious_companion.sample
next make_client(companion.private_url, use_http_proxy: false)

View File

@ -160,8 +160,6 @@ class Config
# Max pool size for HTTP requests to youtube.com and ytimg.com (each domain has a separate pool)
property pool_size : Int32 = 100
# Idle pool size for HTTP requests to youtube.com and ytimg.com (each domain has a separate pool)
property idle_pool_size : Int32? = nil
# Amount of seconds to wait for a client to be free from the pool before rasing an error
property pool_checkout_timeout : Float64 = 5

View File

@ -7,18 +7,13 @@ module Invidious::ConnectionPool
def initialize(
*,
max_capacity : Int32 = 5,
idle_capacity : Int32? = nil,
timeout : Float64 = 5.0,
&client_factory : -> HTTP::Client
)
if idle_capacity.nil?
idle_capacity = max_capacity
end
pool_options = DB::Pool::Options.new(
initial_pool_size: 0,
max_pool_size: max_capacity,
max_idle_pool_size: idle_capacity,
max_idle_pool_size: max_capacity,
checkout_timeout: timeout
)
@ -106,7 +101,6 @@ module Invidious::ConnectionPool
pool = ConnectionPool::Pool.new(
max_capacity: CONFIG.pool_size,
idle_capacity: CONFIG.idle_pool_size,
timeout: CONFIG.pool_checkout_timeout
) do
next make_client(url, force_resolve: true)