Repository navigation
Add caching for JWT tokens - #151
Conversation
|
@garrettjonesgoogle PTAL when you have moment |
| throw new IllegalStateException("generateJwtAccess threw an unchecked exception that couldn't be rethrown", e); | ||
| } | ||
| } | ||
| private String generateJwtAccess(URI uri) throws IOException { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@lesv could you take a look too? |
|
Updated:
PTAL |
|
Oh I was wanting to do the snapshot bump in a separate PR that gets committed before this one... |
|
Oops, sorry I misunderstood. I cherrypicked the version bump to a separate PR: |
lesv
left a comment
There was a problem hiding this comment.
Just a quick look, I think you might wish to refresh at 30-60 seconds 'til instead of 10. I don't see much else thats obvious. I'm going to look again before I give an approval.
| private LoadingCache<URI, String> createCache() { | ||
| return CacheBuilder.newBuilder() | ||
| .maximumSize(100) | ||
| .expireAfterWrite(LIFE_SPAN_SECS - 10, TimeUnit.SECONDS) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
cbe70cd to
6fc7bb2
Compare
lesv
left a comment
There was a problem hiding this comment.
PTAL - I'm just not finding how tokenCache is being set by fromStream(credentialsStream) flow.
| this.privateKey = Preconditions.checkNotNull(privateKey); | ||
| this.privateKeyId = privateKeyId; | ||
| this.defaultAudience = defaultAudience; | ||
| this.tokenCache = createCache(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -228,6 +241,28 @@ public static ServiceAccountJwtAccessCredentials fromStream(InputStream credenti | |||
| + " Expecting '%s'.", fileType, SERVICE_ACCOUNT_FILE_TYPE)); | |||
| } | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@lesv PTAL |
Use guava's LoadingCache to cache JWT tokens. This should address performance for both clientside & serverside:
Benchmarks (n1-standard-4):
Merging this PR will have a significant impact on the consistency of Cloud Bigtable's performance (and other low latency products as well).