-
Notifications
You must be signed in to change notification settings - Fork 910
Reduced resource consumption of async credential providers. #3275
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
Conversation
4c41d77
to
bf7ef79
Compare
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/test/java/software/amazon/awssdk/utils/cache/NonBlockingTest.java
Outdated
Show resolved
Hide resolved
a48f917
to
069261e
Compare
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
3cb87af
to
075f34f
Compare
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
utils/src/main/java/software/amazon/awssdk/utils/cache/NonBlocking.java
Outdated
Show resolved
Hide resolved
There are a few places where JavaDoc could be tweaked to reflect these changes: SsoCredentialsProvider, StsCredentialsProvider - suggested text for prefetch attribute on the Builder:
Additionally for
Perhaps remove and defer to |
Perhaps |
Yeah, it's a bit more constrained now. The goal for capping it to 5 minutes was to make log dives easier, because you know that the refresh will happen within 5 minutes of the calculated prefetch time (which is usually less than 5 minutes before the expiration time). If it was unbounded, people are more likely to have to search more logs to find the info. I just picked 5 minutes, because most of our default prefetch times are within 5 minutes of the stale times and most service throttling limits are windowed at one second. Some are longer, though, like IMDS's up-to-30 minutes. What would be an ideal max time in your mind? |
I think it's a cleaner story to say that prefetch happens in the window from the prefetch time to the stale time (with a bit of padding). Providing a larger prefetch window simply jitters the prefetch over that larger duration. Where E = token expiration, effective prefetch = rand([E - prefetch, E - stale - 1m]) (with the validity checks for overlaps etc) Practically speaking, most SDK consumers won't change the prefetch (or have a need to change the prefetch), leaving them with reasonable defaults (and hence a constrained window for log analysis, etc). In the case of larger numbers of multi-tenant cred providers one may wish to spread that over a larger window (say 10m). I don't practically see a use-case for bloated/unbounded pre-fetch windows - after say 10m you're starting to get into "fetching too frequently" territory. Sure, folks can configure a prefetch of 3500s on a 3600s token expiration if they wish - if we want to prevent that perhaps the prefetch could be validated (at configuration time) to be max(5m or 10% of token expiration duration). Alternately, the JavaDoc could be updated with that guidance, something along the lines of "There are diminishing returns for prefetch windows > 10% of token duration". |
You've convinced me, I think. Let me remove the jitter maximum. |
ae9a2e7
to
9e1ce1b
Compare
Alright, I believe I've resolved your comments, including the javadoc updates (good catch, wish there was a mechanism to keep those correct). |
Thanks; reviewed everything earlier - no further comments, this addresses the goals. Great work on this. |
1. Share thread pools across async credential providers (anything using CachedSupplier's NonBlocking prefetch strategy). 2. Log a warning if an extreme number of concurrent refreshes are happening, to help users detect when they're not closing their credential providers. Even though this is an increase in resource sharing, it should not cause increased availability risks. Because these threads are only used for background refreshes, if one particular type of credential provider has availability problems (e.g. SSO or STS high latency), it only disables background refreshes, not prefetches or synchronous fetches.
0107254
to
0f060fd
Compare
SonarCloud Quality Gate failed. |
There were some issues after the merge with master related timing because of the CachedSupplier update from #3275.
Fixes #3259.
Even though this is an increase in resource sharing, it should not cause increased availability risks. Because these threads are only used for background refreshes, if one particular type of credential provider has availability problems (e.g. SSO or STS high latency), it only disables background refreshes, not prefetches or synchronous fetches.