Back to results for “Applications”
AWS › AWS Secrets Manager & Parameter Store

How do applications retrieve secrets at runtime, and what caching strategies help reduce the cost and latency of frequent secret retrieval?

Intermediate

Answer

Applications typically call the Secrets Manager or Parameter Store API directly using an SDK to retrieve a secret value when needed, and to avoid the cost and latency of repeatedly calling this API for every single request, many applications implement local caching with a defined time to live, or use official caching client libraries provided by AWS, which automatically handle refreshing the cached value periodically or when a rotation event occurs.
import boto3
client = boto3.client('secretsmanager')
response = client.get_secret_value(SecretId='db-password')
secret = response['SecretString']
Real-world example A high traffic application uses the AWS provided Secrets Manager caching client library to retrieve its database password once and reuse that cached value for subsequent requests, avoiding thousands of unnecessary API calls per minute while still automatically refreshing if the underlying secret is rotated.

Common follow-ups: What is the cost impact of not caching secret retrieval calls at high request volumes?;How does a caching client library know when to refresh a cached secret?