Skip to content
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

do not create a unique connection pool for every CacheService instance #24725

Merged
merged 1 commit into from May 13, 2024

Conversation

freben
Copy link
Member

@freben freben commented May 10, 2024

The old code created a new @keyv/redis or @keyv/memcache instance every time that anyone called getClient. That's fine if done once per plugin, but not if it's called over and over again. That creates a new connection pool per call, which gets abandoned by the caller (likely, if it's written in such a way that it calls getClient repeatedly in the first place) which piles up more and more active connections to the underlying cache store until it starts rejecting connections.

Could have gone all the way to memoizing on the options object to save on Keyv wrapper object overhead, but this felt like it would still cover all realistic use cases without having to worry about how that changes over time.

Ref: https://discord.com/channels/687207715902193673/1034089724664610938/1237307568410464256

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
@freben freben requested review from a team as code owners May 10, 2024 17:45
@freben freben requested review from Rugvip and vinzscam May 10, 2024 17:45
@backstage-goalie
Copy link
Contributor

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/backend-common packages/backend-common patch v0.22.0-next.2

@drodil
Copy link
Contributor

drodil commented May 13, 2024

Great fix @freben ! Hope this gets shipped in the next release (tomorrow?)!

Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

Let's :shipit:

@freben freben merged commit 94a7d1b into master May 13, 2024
30 checks passed
@freben freben deleted the freben/one-cache branch May 13, 2024 07:34
Copy link
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.27.0 release, scheduled for Tue, 14 May 2024.

Copy link
Contributor

Uffizzi Cluster pr-24725 was deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants