- Newest
- Most votes
- Most comments
How about this:
-
Is this the right way to refresh token and re-create pools, do you have any suggestions? Implementing a background scheduler to refresh the authentication token and recreate the JedisPool is a practical solution, considering the limitations of JedisPool in supporting a credentials provider. However, this approach inherently adds operational complexity and may lead to increased overhead from frequent pool re-creation.
-
Do you recommend any specific time to refresh the token e.g every 5 mins or 7 mins? Refreshing the token at an interval of 5 to 7 minutes is a prudent strategy, as it guarantees the token remains valid while incorporating a buffer to account for potential delays. The specific interval should be determined based on the application's tolerance for downtime and the frequency with which the token is utilized.
-
Do you recommend to migrate us to use a Redis client that support credential provider and takes care of the refresh logic? Transitioning to a Redis client with credentials provider support, such as AWS SDK-integrated clients, is strongly recommended. These clients are designed to manage token generation and refresh processes seamlessly, eliminating the need for custom scheduling logic. This solution streamlines the implementation and significantly mitigates the risk of token expiration.
-
Is there anything that we missing to consider when we are doing this auth token refresh?
- Ensure that the token refresh logic is designed to be thread-safe, effectively preventing race conditions.
- Continuously evaluate the performance impact associated with frequent pool re-creation, particularly under high-load scenarios.
- Develop and implement comprehensive error-handling mechanisms to manage token refresh failures or pool re-creation issues gracefully and efficiently.
- Is there any other mechanism that we can use instead of the background scheduler?
- In scenarios where migrating to a client with credentials provider support is not viable, it is advisable to utilize a connection pool library capable of dynamically reconfiguring authentication credentials, eliminating the need for frequent pool re-creation.
- Consider leveraging AWS Lambda or other serverless technologies to facilitate token generation and distribution, thereby reducing the operational burden on your application.
Hey,
Hope you're keeping well.
Your approach of refreshing the IAM auth token and rebuilding the JedisPool is correct given the 15‑minute validity, but you can reduce churn by timing the refresh closer to expiry, for example around 12–13 minutes after generation. If possible, consider switching to a Redis client that supports AWS credential providers natively, as that removes the need to manage pool recreation logic. Also ensure your scheduler logic handles token generation failures gracefully to avoid dropping all connections. For production, test the switchover under load to confirm no spikes in latency during pool replacement.
Thanks and regards,
Taz
Relevant content
- asked 2 years ago
- asked a year ago

Thank you for you response!! This is very much useful!
I've few follow up questions:
AWSCredentialsProvider, that refreshes creds for example every 1 hour and valid for like 6 hours (like something mentioned here:https://medium.com/expedia-group-tech/service-slow-to-retrieve-aws-credentials-ebc02a38e95b), this shouldn't cause any intermittent failures of invalid auth token right?