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.
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
Proxy: Use connection pools for images #4326
Proxy: Use connection pools for images #4326
Changes from all commits
480e073
52bc9aa
06e1a50
4bc77b8
003c6f8
75b6861
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I'm concerned about keeping that many open connections on small instances. Maybe we could bypass the pooling system if
CONFIG.pool_size == 0
?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.
Does the pool not automatically clean up connections?
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.
I don't think so? It seems that released connections are pushed to the
idle
list, but I'm not sure what causes them to be closed:https://github.com/crystal-lang/crystal-db/blob/3eaac85a5d4b7bee565b55dcb584e84e29fc5567/src/db/pool.cr#L151-L185
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.
Well that's a problem...
Regarding the bypass though, shouldn't that already be what
DB:Pool
does whenpool_size
equals 0? Invidious seems to be able to handle requests fine whenCONFIG.pool_size
is set to zero at leastThere 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.
YoutubeConnectionPool
sets themax_pool_size
andmax_idle_pool_size
to the value ofcapacity
. So meaning the pool will start out with 0 clients, and create more up tocapacity
, but then it'll keep all of them around forever.There is also not currently a way to set a timeout on idle connections. I.e. that would expire idle connections after some period of time. Is some discussion related to this in crystal-lang/crystal-db#47.
In the meantime it might be worth allowing to customize the
max_idle_pool_size
vs always assuming it should beCONFIG.pool_size
big. E.g. have a highermax_pool_size
to handle bursts, but then keepmax_idle_pool_size
set to something smaller for normal traffic.1
might be a good starting point, could run some benchmarks to figure out a good value.