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

feat: add support for a lazy refresh #2184

Merged
merged 4 commits into from
Apr 16, 2024
Merged

feat: add support for a lazy refresh #2184

merged 4 commits into from
Apr 16, 2024

Conversation

enocom
Copy link
Member

@enocom enocom commented Apr 15, 2024

When clients run the Proxy in environments where the CPU may be throttled, the background connection info refresh operation can fail to complete, causing connection errors. This commit introduces an option for a lazy refresh. Connection info is retrieved on an as needed-basis and cached based on the associated certificate's expiration. No background goroutine runs, unlike the default refresh ahead cache.

Enable it like so:

./cloud-sql-proxy <INSTANCE_CONNECTION_NAME> --lazy-refresh

A lazy refresh may result in increased latency (more requests will be subject to waiting for the refresh to complete), but gains in reliability.

Fixes #2183

When clients run the Proxy in environments where the CPU may be
throttled, the background connection info refresh operation can fail to
complete, causing connection errors. This commit introduces an option
for a lazy refresh. Connection info is retrieved on an as needed-basis
and cached based on the associated certificate's expiration. No
background goroutine runs, unlike the default refresh ahead cache.

 Enable it like so:

 ./cloud-sql-proxy <INSTANCE_CONNECTION_NAME> --lazy-refresh

A lazy refresh may result in increased latency (more requests will be
subject to waiting for the refresh to complete), but gains in
reliability.

Fixes #2183
@enocom enocom requested a review from a team as a code owner April 15, 2024 20:57
go.mod Outdated Show resolved Hide resolved
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

should we add an example usage to the help message?

@enocom enocom requested a review from jackwotherspoon April 16, 2024 16:41
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

LGTM

README.md Outdated Show resolved Hide resolved
Co-authored-by: Jack Wotherspoon <[email protected]>
@enocom enocom merged commit fd7ab82 into main Apr 16, 2024
12 of 13 checks passed
@enocom enocom deleted the lazy-refresh branch April 16, 2024 17:18
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.

Add support for a lazy refresh
2 participants