Redis session backend
Apache::Session::Browseable::Redis is the fastest shareable session backend
Setup
Install and launch a Redis server. Install Apache::Session::Browseable::Redis Perl module.
With Sentinel, make sure you are using at least version 1.3.8 of Apache::Session::Browseable, this might require installing it from Debian Backports or CPAN.
In the manager: set
Apache::Session::Browseable::Redis
in General parameters » Sessions » Session storage »
Apache::Session module and add the connection parameters for your Redis server(s).
This backend uses the perl bindings for Redis database provided by the Redis perl module. A complete list of supported constructor/connection options can be found in the module documentation.
E.g., Parameters (case sensitive):
Name |
Comment |
Example |
|---|---|---|
server |
Redis server @ IP:PORT |
127.0.0.1:6379 |
sock |
Redis server @ unix socket |
unix:/path/to/redis.sock |
sentinels |
Redis sentinels list |
127.0.0.1:26379,127.0.0.2:26379,127.0.0.3:26379 |
service |
Sentinel service name |
mymaster |
password |
password (== requirepass) |
ChangeMe |
database |
Redis DB |
1 |
Index |
Fields to index |
Additional sentinel parameters |
Comment |
Default |
|---|---|---|
sentinels_ssl |
Use SSL |
0 |
sentinels_username |
Login |
|
sentinels_password |
Password |
|
sentinels_cnx_timeout |
Connection timeout |
0.1 |
sentinels_write_timeout |
Write timeout |
1 |
sentinels_read_timeout |
Read timeout |
1 |
no_sentinels_list_update |
Use only one Sentinel |
0 |
Indexes
Each field listed in Index has one Redis set per value, holding the ids
of the sessions with this value. A search on a field which is not in
Index reads every key of the Redis database, see List of fields to index by session type.
Attention
Use at least version 1.3.19 of Apache::Session::Browseable: older
versions don’t remove the purged sessions from these sets, which then
grow without limit and slow down every search.
Redis doesn’t build these sets from the stored sessions: a session is added to them only when it is saved. So:
Removing a field from
Indexis safe: the searches on this field read every session. Its sets stay in Redis until they are deleted.Adding a field to
Indexmakes the searches on this field use its index at once: they miss every session stored before, without error, until this session is saved again. Long-lived sessions (persistent sessions, offline refresh tokens) may never be. Re-save the stored sessions, or add the field to the sets, right after the change.
Security
Restrict network access to the redis server. For remote servers, you can use SOAP session backend in cunjunction to increase security for remote server that access through an unsecure network