The in-memory cache is available only in the Node.js SDK and Sidecar. Other backend SDKs (Python, Ruby, Go, Java, .NET) perform direct API calls for every entitlement check and do not maintain a local cache.
- Redundancy - data is available on your Redis cluster even in case of an API outage
- Low latency - including < 10ms credit balance retrieval via
getCreditEntitlement() - Fewer requests from your services to the Stigg API
- Reduce the memory footprint of the SDK in your services
- Reducing cache coherence issues
- Increased cache hits/misses ratio
Overview
Stigg’s persistent cache relies on a running persistent-cache-service as part of your app deployment process. The service connects to a dedicated AWS SQS queue (owned and managed by Stigg), consumes messages that carry the state changes from the originating environment, and keeps your Redis cache instance with up-to-date data. The service can be scaled horizontally to keep up with the rate of arriving messages. In case of a cache miss, the SDK will fetch the data over the network directly from API, and update the cache to serve future requests.
Running the service
In order for the persistent cache to be updated properly in near real-time, you’ll need to install and run at least one instance of persistent-cache-service.Prerequisites
- An SQS provisioned by Stigg, to consume messages originating from your environment
- Redis cluster to persist entitlements and usage for a future read operation
Usage
Run the service, replacing<tag> with the latest version in the ECR Public Gallery:
Starting from version 2.37.0, the service uses IAM role-based authentication for SQS access.
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are no longer required - the service will automatically use the IAM role attached to the host (EC2 instance, ECS task, EKS pod, etc.).
*Required fields
Health
The service exposes the following HTTP endpoints:GET /livez
Returns 200 if the service is alive.
Healthy response: {"status":"UP"}
GET /readyz
Returns 200 if the service is ready to receive messages.
Healthy response: { "status": "UP", "consumers": 10, "redis": "CONNECTED" }
Unhealthy response: { "status": "DOWN", "consumers": 0, "redis": "DISCONNECTED" }
GET /metrics
Returns service metrics in Prometheus format.
This endpoint includes both system-level and cache specific metrics. These metrics are helpful for monitoring the health and performance of the service.
Configure the SDK
To configure the SDK to use the Redis cache, provide theredis config during initialization:
Disabling Redis expiration must be set on both sides. If you want cache entries to persist indefinitely (e.g. to keep serving entitlements through extended Stigg Cloud outages), the negative TTL must be configured on both the reader side and the writer side:
- Node SDK:
redis.ttl: -1 - Sidecar:
REDIS_KEYS_TTL_IN_SECS=-1 persistent-cache-service:KEYS_TTL_IN_SECS=-1
Deploying the Service in Kubernetes
You can install the Service using eitherhelm or kustomize. For detailed instructions, resources, and examples, visit our GitHub repository.
Benchmarks
Based on internal benchmarks, a single instance of thepersistent-cache-service runs efficiently with the following configuration:
- CPU and memory: 1 vCPU and 512MB RAM.
- CPU usage: Averages around 60%, with a range between 30% and 90% under constant load (i.e., when messages are consistently present in the queue).
- Memory footprint: Approximately 250MB.
- Throughput: Handles up to 100 messages per second, depending on message type and processing complexity.
- Storage: Does not use any disk storage. The minimal container image size is sufficient.
- Scalability: The service is stateless and can be horizontally scaled as needed to meet higher throughput demands.
