REDIS Provider
The REDIS provider uses Redis as an in-memory data store for documents and sessions. Redis is ideal for cluster deployments where multiple webPDF Server nodes need to share document metadata and session data.
Overview
- Provider Name:
REDIS - Supports: Document Storage, Session Storage
- Configuration File:
provider-redis.yaml(Redisson configuration format) - Use Case: Cluster deployments, high-performance caching, distributed sessions
Features
- ✓ High-performance in-memory data store
- ✓ Cluster-ready with shared state
- ✓ Persistence options (RDB, AOF)
- ✓ Replication and high availability support
- ✓ Low latency access
- ✓ Batch operations for optimized performance
- ✓ Distributed locking with watchdog mechanism
- ✓ Namespace-based key isolation
- ✓ JSON serialization with Java time support
- ✓ Connection health monitoring
- ✓ Event manager integration for async operations
- ✓ Session reconciliation and expiration processing
- ✗ Limited by available RAM
- ✗ Requires external Redis server
Prerequisites
- Redis server 6.0 or later
- Network connectivity from webPDF Server to Redis
- Redis connection details (host, port, credentials)
Configuration
provider.json
{
"documentStorage": {
"name": "REDIS",
"checks": {
"enabled": true,
"interval": 5000
}
},
"sessionStorage": {
"name": "REDIS",
"checks": {
"enabled": true,
"interval": 5000
}
}
}
provider-redis.yaml
The configuration file uses the Redisson YAML format. Redisson is a Redis client that provides advanced features for distributed applications.
The provider-redis.yaml file is a standard Redisson configuration file, not a webPDF-specific format. Refer to the Redisson documentation for all available configuration options.
Single Server Configuration
For standalone Redis servers:
singleServerConfig:
address: "redis://localhost:6379"
password: "your-password"
database: 0
connectionPoolSize: 64
connectionMinimumIdleSize: 24
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
Cluster Configuration
For Redis Cluster deployments:
clusterServersConfig:
nodeAddresses:
- "redis://redis-node1:6379"
- "redis://redis-node2:6379"
- "redis://redis-node3:6379"
password: "your-password"
scanInterval: 1000
readMode: "SLAVE"
subscriptionMode: "MASTER"
Sentinel Configuration
For Redis Sentinel high availability:
sentinelServersConfig:
masterName: "mymaster"
sentinelAddresses:
- "redis://sentinel1:26379"
- "redis://sentinel2:26379"
- "redis://sentinel3:26379"
password: "your-password"
database: 0
Configuration Attributes
Single Server Settings
| Attribute | Type | Description | Default |
|---|---|---|---|
address | string | Redis server address (format: redis://host:port) | - |
password | string | Redis authentication password | null |
database | integer | Redis database number (0-15) | 0 |
connectionPoolSize | integer | Connection pool size | 64 |
connectionMinimumIdleSize | integer | Minimum idle connections | 24 |
idleConnectionTimeout | integer | Idle connection timeout (ms) | 10000 |
connectTimeout | integer | Connection timeout (ms) | 10000 |
timeout | integer | Command timeout (ms) | 3000 |
retryAttempts | integer | Number of retry attempts | 3 |
retryInterval | integer | Retry interval (ms) | 1500 |
Cluster Server Settings
| Attribute | Type | Description | Default |
|---|---|---|---|
nodeAddresses | array | List of cluster node addresses | - |
password | string | Redis authentication password | null |
scanInterval | integer | Cluster topology scan interval (ms) | 1000 |
readMode | string | Read mode: SLAVE, MASTER, MASTER_SLAVE | SLAVE |
subscriptionMode | string | Subscription mode: MASTER, SLAVE | MASTER |
Sentinel Server Settings
| Attribute | Type | Description | Default |
|---|---|---|---|
masterName | string | Name of the master server | - |
sentinelAddresses | array | List of sentinel addresses | - |
password | string | Redis authentication password | null |
database | integer | Redis database number | 0 |
Environment Variables
Since the configuration uses Redisson YAML format, environment variables can be used within the YAML file using standard YAML syntax:
singleServerConfig:
address: "redis://${REDIS_HOST:localhost}:${REDIS_PORT:6379}"
password: "${REDIS_PASSWORD}"
database: ${REDIS_DATABASE:0}
Health Checks
Health checks monitor Redis connectivity and availability:
{
"documentStorage": {
"name": "REDIS",
"checks": {
"enabled": true,
"interval": 5000
}
}
}
enabled: Enable health checks (recommended:true)interval: Check interval in milliseconds (recommended:5000-10000)
Namespace Support
Redis keys are automatically prefixed with the namespace of the cluster: <prefix>:v<main>.<minor>-r<revision> (for example webpdf-prod:v10.0-r1). It identifies the installation and its data format, so that several clusters and several versions of webPDF can share one Redis without touching each other's data.
The key <namespace>:owner holds the owner of the namespace: a second cluster on the same namespace does not start (see One Namespace, One Cluster).
Key Structure
Keys follow this pattern:
<namespace>:<domain>:<type>:<identifier>
Where:
- namespace:
<prefix>:v<main>.<minor>-r<revision>, for examplewebpdf-prod:v10.0-r1 - domain: Key domain (
session,document,event,history) - type: Key type (
data,index,lock) - identifier: Unique ID (session ID, document ID, etc.)
Key Domains
| Domain | Purpose | Example Keys |
|---|---|---|
session | Session management | <ns>:session:data:<sessionId> |
document | Document storage | <ns>:document:data:<sessionId>:<documentId> |
event | Event notifications | <ns>:event |
history | Document history | <ns>:history:data:<sessionId>:<documentId> |
Index Keys
Index keys are used for listing and searching:
<namespace>:session:index
<namespace>:document:index:<sessionId>
<namespace>:document:index:<sessionId> lists the documents of one session and is removed together with the session.
There is no index of all documents of the namespace.
Sessions and Documents
A document is created only while its session exists. If the session is logged out or deleted after expiry in the same moment, creating the document fails with WEBSERVICE_SESSION_TOKEN_NOT_FOUND (-60) and nothing remains in Redis or in the file storage; this also applies to a request that stores its result only after the logout. Each new document costs two additional read accesses to Redis.
The end of a session is stored in Redis. A request with a token of an external identity provider that ends later than the stored end (a later exp) extends the session and stores the new end, at most once per new token. Without this, a session ended at the end it was opened with (the default lifetime of an access token from its first request), however long it was in use, and its documents were deleted. A session that has ended or expired is not extended again. A single server without a cluster is unchanged.
A token of an external identity provider points to the current session of its identity. The pointer is a key under the lock prefix, <namespace>:session:lock:principal:<hash>, where <hash> is a SHA-256 hash (64 hexadecimal characters) of the identity: issuer, user and application. The pointer is removed when the session ends and is replaced by the next request after that. Its time to live is only a safety net: at least one hour, or twice the remaining lifetime of the session if that is longer. Because the pointer is part of the session state, it needs the same noeviction memory policy as the sessions; with a volatile-* policy the pointers are evicted first (the server warns at startup, see Redis Server Configuration), and the next request of the user then opens a new, empty session.
Lock Keys
Distributed locks use dedicated keys:
<namespace>:session:lock:<sessionId>
<namespace>:session:lock:principal:<hash>
<namespace>:session:lock:expiration
<namespace>:session:lock:reconciliation
<namespace>:session:lock:expiration-marker:<sessionId>
<namespace>:document:lock:<sessionId>:<documentId>
See Namespace Configuration for more details on configuring namespaces.
All keys that webPDF writes lie under the namespace. In addition, Redisson derives the channel redisson_lock__channel:{<namespace>:…} and the key redisson_unlock_latch:{<namespace>:…}:<id> for every lock. A Redis that several installations share needs the memory policy noeviction and enough maxmemory for all of them. For the rules for a shared Redis, restricted access rights and emptying the area of a namespace, see Operating Rules.
Security Considerations
- Authentication – Always use Redis authentication (
requirepassin Redis config) - TLS/SSL – Enable SSL for connections over untrusted networks
- Network Security – Use firewalls to restrict Redis access
- Password Strength – Use strong, randomly generated passwords
- Database Separation – Use different database numbers for documents and sessions
Never store Redis passwords in configuration files. Use environment variables or secure configuration management.
High Availability
For production deployments, consider:
- Redis Sentinel – Automatic failover and monitoring
- Redis Cluster – Horizontal scaling across multiple nodes
- Replication – Master-slave replication for read scaling
- Persistence – Enable RDB or AOF for data durability
Performance Tuning
Batch Operations
The provider uses batch operations to optimize performance for multiple operations:
- Batch Execution: Multiple Redis commands are grouped and executed together
- Reduced Latency: Minimizes network round trips
- Atomic Operations: Batch operations are executed atomically
- Use Case: Document retrieval, session cleanup, bulk operations
Distributed Locking
Distributed locks ensure data consistency across cluster nodes:
- Lock Timeout:
2000milliseconds (default) - Lock Lease Time:
-1(watchdog enabled for automatic extension) - Lock Keys: Separate locks for sessions and documents
- Global Locks: Used for expiration processing and reconciliation
The watchdog mechanism automatically extends lock lease time as long as the lock-holding thread is alive, preventing premature lock release.
Data Serialization
JSON serialization with Java time support:
- Format: JSON for the records of sessions and documents and for the event stream; plain text for the indexes and the revision counters
- Codec: set by webPDF Server for every structure; a
codecin the Redisson YAML does not affect the stored data - Benefits: Human-readable data, cross-platform compatibility
- Types: Supports all Java time types (Instant, LocalDateTime, etc.)
Connection Health Monitoring
Automatic connection monitoring:
- Connection Listeners: Monitor connection status changes
- Health Status: Real-time connection state tracking
- Reconnection: Automatic reconnection on failure
- Health Checks: Scheduled health check validation
Event Manager Integration
Asynchronous event processing:
- Async Operations: Non-blocking event notifications
- Event Queue: Decoupled event processing
- Performance: Operations don't wait for event processing
- Use Case: Notifications, logging, monitoring
Session Management
Advanced session handling:
- Session Reconciliation: Periodic consistency checks across cluster
- Expiration Processing: Automated cleanup of expired sessions
- Session ID Generation: Random 128-bit IDs (32 hexadecimal characters) that the server assigns itself, independent of any token
- Session Table: Maintains session metadata and state
Deletion of Expired and Logged-Out Sessions
In a cluster, a session that expires or is logged out is deleted asynchronously, together with its documents in Redis
and in the document storage. The node that detects the expiration, or that receives the logout, writes a deletion
event into the event stream of the namespace (<namespace>:event). All nodes read this stream through one shared
consumer group, so each event is processed by exactly one node.
The end of the session takes effect before the event is queued: logout and closing by an administrator set the stored
state of the session to expired first, so no node reaches the session or its documents afterwards, however long the
deletion takes. If the state cannot be set (the session is locked by another operation), nothing is queued and the
request fails with -65; repeat it. A session whose time is over is recognized as expired when it is read, without
waiting for the check.
- Each session is handed over once. The expiration check runs every second. While the deletion of a session is
pending, the check does not hand the session over again: a marker key per session
(
<namespace>:session:lock:expiration-marker:<sessionId>) records the hand-over and is removed together with the session. If the deletion fails, the marker expires after its lifetime and the session is handed over once more. - Redis without its data. If Redis restarts without its data (no persistence) or the event stream is deleted, the
nodes re-create the consumer group of the event stream on their own and continue deleting. The server log of a node
that re-creates the group shows the warning
Re-created the missing consumer group. Sessions and documents that existed before the data was lost are unknown to Redis afterwards; their objects in the document storage are not deleted automatically. - Full event queue. Each node writes its deletion events through a queue of limited size. When the queue is full,
a logout or a document deletion waits until its event is written; the expiration check does not wait, it hands the
session over in its next round and logs a warning. The current length of the queue is published as the metric
event_writer_queue_size. - Shutdown. A node that shuts down stops accepting new events but still writes the events it has already accepted. If Redis cannot be reached at that moment, every attempt waits for the timeout of the Redis client, and the shutdown of the event pipeline can take up to about twice its shutdown timeout (default 20 seconds); events still waiting then are discarded, and the expiration check hands their sessions over again once their markers have expired. Plan the stop timeout of a container accordingly.
- Dead letter store. Events that cannot be written or processed are kept in the file
dlq-replay-store.jsonin thelogsfolder and replayed later. Every change replaces the file as a whole, so an interrupted write leaves the previous content intact. A store file that cannot be read at startup is renamed todlq-replay-store.json.corrupt-<timestamp>(UTC) and kept; the server starts with an empty store and logs an error that names the kept file. - Cost of a deletion. Deleting a document addresses exactly the keys of this document and its revisions; the time
it takes no longer depends on the number of documents in the namespace, so document deletions keep up under
sustained load. Deleting a session and listing the documents of a session use the index of that session
(
<namespace>:document:index:<sessionId>), so they do not depend on the number of documents in the namespace either.
| Environment variable | System property | Default | Description |
|---|---|---|---|
WEBPDF_REDIS_SESSION_STORAGE_EXPIRATION_MARKER_TTL | -Dwebpdf.redis.session.storage.expiration.marker.ttl | 300000 | Lifetime of the hand-over marker in milliseconds. 0 or less hands every expired session over in every check (the behavior of earlier versions). |
WEBPDF_CLUSTER_EVENTS_WRITER_QUEUE_SIZE | -Dwebpdf.cluster.events.writer.queue.size | 10000 | Maximum number of deletion events that wait for Redis on a node. 0 or less leaves the queue unlimited (the behavior of earlier versions). |
WEBPDF_CLUSTER_EVENTS_SHUTDOWN_TIMEOUT | -Dwebpdf.cluster.events.shutdown.timeout | 20000 | Time in milliseconds that the shutdown of a node waits for each part of the event pipeline, among them the writing of the accepted events. |
Redis Server Configuration
# redis.conf optimizations
maxmemory 4gb
maxmemory-policy noeviction
tcp-backlog 511
timeout 300
tcp-keepalive 60
Use maxmemory-policy noeviction. Redis holds the sessions, the document records and the deletion events of the
cluster. With an eviction policy such as allkeys-lru it silently deletes keys when it reaches maxmemory: users lose
their sessions, documents disappear, and deletions can leave content behind in the document storage. With
noeviction a full Redis rejects new writes instead, and the affected requests fail with an error of the document or
session storage rather than losing data unnoticed. Size maxmemory for the peak number of sessions and documents, and
monitor the memory use (info memory) and the evicted keys (evicted_keys in info stats), which must stay 0.
Checks by webPDF Server. webPDF Server reads the memory status of Redis when it starts and then every 60 seconds,
without any setting. The check only reads (INFO memory and INFO stats) and changes nothing on Redis. It covers every
master: all masters of a cluster, the current master of a Sentinel setup, and the master of a single, master/replica or
replicated setup. Replicas are not read. The first check runs in the background, so it neither delays the start of
webPDF Server nor stops it when Redis cannot be read.
| Log level | When |
|---|---|
WARN | A master reports a maxmemory-policy other than noeviction (allkeys-*, volatile-* or a policy that is not known yet). The line names each such master with its policy and maxmemory. It is written once per check; after the start check only when the policy of a master changes to such a value. Under a volatile-* policy Redis deletes the keys with an expiry first, among them all locks. |
INFO | The start check finds every master on noeviction. |
INFO | The memory status of a master cannot be read (INFO renamed or not permitted, no answer within 5 seconds), and when it can be read again. webPDF Server keeps running; check the policy of Redis yourself. The check needs the permission for the INFO command; without it, set WEBPDF_REDIS_MEMORY_CHECK_INTERVAL to 0 to stop the repeated attempts, and monitor Redis outside webPDF Server. |
ERROR | A master evicted keys since the last report. At most one line per minute, with the number of keys and the number per master. Data of webPDF Server may be among them (sessions, documents, locks). The counter covers all keys of Redis, also those of other applications. |
WARN | A lock was no longer held when webPDF Server released it, because it expired or Redis evicted it. Mutual exclusion was not guaranteed for that one operation. The result of the operation is reported as usual. |
If a master restarts, fails over, or is reset with CONFIG RESETSTAT, the counting continues from the new value of that
master without an alarm.
Managed services often preset an evicting policy: Azure Cache for Redis and the node-based clusters of
Amazon ElastiCache use volatile-lru by default. Set noeviction in the advanced settings of the cache or in a
parameter group of the cluster. Amazon ElastiCache Serverless fixes volatile-lru; there the start warning is
written at every start, and the ERROR line and the metric cache_server_evicted_keys_total (see
Metrics Reference) are your monitoring.
Environment settings. The interval is the only setting. It has no XML configuration and no Admin Portal dialog.
| Environment setting | System property | Default | Description |
|---|---|---|---|
WEBPDF_REDIS_MEMORY_CHECK_INTERVAL | -Dwebpdf.redis.memory.check.interval | 60000 | Time between two checks in milliseconds. 0 or less switches the running check off: the start check still runs, but there is no ERROR line for evicted keys, the metric does not rise, and the cluster status is not updated. A value from 1 to 999 is raised to 1000 with a warning. |
To go back to the default, remove the setting and restart webPDF Server. Environment settings take precedence over the defaults.
Cluster status. The cluster status of the Admin REST interface (GET /admin/cluster/status) shows the result of the
last check as the optional field cacheServer. It is missing when no storage provider uses Redis and until the first
check has finished. Every server node reads Redis itself, so the field shows the view of the node that answers the
request.
| Field | Description |
|---|---|
cacheServer.provider | REDIS |
cacheServer.checkedAt | Time of the last finished check in milliseconds since 1970-01-01T00:00:00Z. |
cacheServer.nodes[] | One entry per master. |
nodes[].address | Address of the master as host:port. |
nodes[].readable | true if the master answered the check and reported all three of the following values. Read the three values only when this is true. |
nodes[].maxMemoryPolicy | The maxmemory-policy as the server reports it. Every policy except noeviction is unsafe for webPDF. |
nodes[].maxMemory | The maxmemory limit in bytes; 0 means no limit. |
nodes[].evictedKeys | The evicted_keys counter of the master since its start or since CONFIG RESETSTAT; it must stay 0. |
If readable is false, the fields maxMemoryPolicy, maxMemory and evictedKeys are left out. Clients that fill a
missing field with a default value (for example 0) must therefore check readable first. evictedKeys is the counter
of Redis itself: after an eviction it stays above 0 until Redis restarts or CONFIG RESETSTAT resets it. The metric
cache_server_evicted_keys_total counts differently: every server node counts the evictions it observed since its own
start.
Connection Pool Tuning
Adjust pool settings in the Redisson configuration based on load:
singleServerConfig:
address: "redis://localhost:6379"
connectionPoolSize: 256
connectionMinimumIdleSize: 64
subscriptionConnectionPoolSize: 50
subscriptionConnectionMinimumIdleSize: 10
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
Troubleshooting
Cannot Connect to Redis
- Verify Redis is running:
redis-cli ping - Check network connectivity:
telnet redis-host 6379 - Verify credentials are correct
- Check firewall rules
High Memory Usage
- Monitor Redis memory:
redis-cli info memory - Check that
evicted_keys(info stats) is0; keepmaxmemory-policy noeviction(see Redis Server Configuration) - Review data retention policies
- Consider increasing Redis server memory
Slow Response Times
- Check Redis server load:
redis-cli info stats - Monitor network latency
- Review slow log:
redis-cli slowlog get 10 - Optimize connection pool settings
Examples
Basic Single Server Setup
singleServerConfig:
address: "redis://localhost:6379"
Redis with Authentication
singleServerConfig:
address: "redis://redis.example.com:6379"
password: "secure-password"
database: 0
connectionPoolSize: 64
connectionMinimumIdleSize: 24
Redis with SSL/TLS
singleServerConfig:
address: "rediss://redis.example.com:6380"
password: "secure-password"
database: 0
sslEnableEndpointIdentification: true
Redis Cluster Configuration
clusterServersConfig:
nodeAddresses:
- "redis://redis-node1:6379"
- "redis://redis-node2:6379"
- "redis://redis-node3:6379"
password: "secure-password"
scanInterval: 1000
readMode: "SLAVE"
subscriptionMode: "MASTER"
Redis Sentinel Configuration
sentinelServersConfig:
masterName: "mymaster"
sentinelAddresses:
- "redis://sentinel1.example.com:26379"
- "redis://sentinel2.example.com:26379"
- "redis://sentinel3.example.com:26379"
password: "secure-password"
database: 0