Skip to content

Commit d70b05e

Browse files
committed
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
1 parent 924ae11 commit d70b05e

File tree

4 files changed

+1
-31
lines changed

4 files changed

+1
-31
lines changed

config/config.example.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,25 +214,6 @@ https_only: false
214214
##
215215
#pool_size: 100
216216

217-
218-
##
219-
## Max idle size of the HTTP pool used to connect to youtube. Each
220-
## domain ('youtube.com', 'ytimg.com', ...) has its own pool.
221-
##
222-
## This means that when releasing a connection back into the pool, it will
223-
## be closed if there are already more than idle_pool_size connections within
224-
## the pool
225-
##
226-
## Do note that idle connections are kept around forever without any way of
227-
## timing them out.
228-
##
229-
## When unset this value has the same value as pool_size
230-
##
231-
## Accepted values: a positive integer
232-
## Default: <none> (internally this means that it has the same value as pool_size)
233-
##
234-
#idle_pool_size:
235-
236217
##
237218
## Amount of seconds to wait for a client to be free from the pool
238219
## before raising an error

src/invidious.cr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ SOFTWARE = {
9494

9595
YT_POOL = Invidious::ConnectionPool::Pool.new(
9696
max_capacity: CONFIG.pool_size,
97-
idle_capacity: CONFIG.idle_pool_size,
9897
timeout: CONFIG.pool_checkout_timeout
9998
) do
10099
next make_client(YT_URL, force_resolve: true)
@@ -106,15 +105,13 @@ GGPHT_URL = URI.parse("https://yt3.ggpht.com")
106105

107106
GGPHT_POOL = Invidious::ConnectionPool::Pool.new(
108107
max_capacity: CONFIG.pool_size,
109-
idle_capacity: CONFIG.idle_pool_size,
110108
timeout: CONFIG.pool_checkout_timeout
111109
) do
112110
next make_client(GGPHT_URL, force_resolve: true)
113111
end
114112

115113
COMPANION_POOL = Invidious::ConnectionPool::Pool.new(
116114
max_capacity: CONFIG.pool_size,
117-
idle_capacity: CONFIG.idle_pool_size
118115
) do
119116
companion = CONFIG.invidious_companion.sample
120117
next make_client(companion.private_url, use_http_proxy: false)

src/invidious/config.cr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ class Config
160160

161161
# Max pool size for HTTP requests to youtube.com and ytimg.com (each domain has a separate pool)
162162
property pool_size : Int32 = 100
163-
# Idle pool size for HTTP requests to youtube.com and ytimg.com (each domain has a separate pool)
164-
property idle_pool_size : Int32? = nil
165163

166164
# Amount of seconds to wait for a client to be free from the pool before rasing an error
167165
property pool_checkout_timeout : Float64 = 5

src/invidious/connection/pool.cr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@ module Invidious::ConnectionPool
77
def initialize(
88
*,
99
max_capacity : Int32 = 5,
10-
idle_capacity : Int32? = nil,
1110
timeout : Float64 = 5.0,
1211
&client_factory : -> HTTP::Client
1312
)
14-
if idle_capacity.nil?
15-
idle_capacity = max_capacity
16-
end
17-
1813
pool_options = DB::Pool::Options.new(
1914
initial_pool_size: 0,
2015
max_pool_size: max_capacity,
21-
max_idle_pool_size: idle_capacity,
16+
max_idle_pool_size: max_capacity,
2217
checkout_timeout: timeout
2318
)
2419

@@ -106,7 +101,6 @@ module Invidious::ConnectionPool
106101

107102
pool = ConnectionPool::Pool.new(
108103
max_capacity: CONFIG.pool_size,
109-
idle_capacity: CONFIG.idle_pool_size,
110104
timeout: CONFIG.pool_checkout_timeout
111105
) do
112106
next make_client(url, force_resolve: true)

0 commit comments

Comments
 (0)