Redis Session Store - Odoo Redis Sessions for Load Balancer and Multiple Servers
by Modvanta https://modvantaapps.tech/odoo-apps/redis-session-store/$ 11.97
Redis Session Store for Odoo 19 - Shared Sessions for Multiple Servers
Odoo keeps every login session in files on the local disk, so two Odoo servers behind a load balancer log users out each other. This module moves the sessions to Redis: every Odoo process reads the same sessions, they expire by themselves, and if Redis goes down Odoo keeps working on the filesystem.
Server wide moduleodoo.conf or environmentPassword and TLSKey prefixExpiry by TTLFilesystem fallbackDisk to Redis migrationDevice logoutStatus screen37 automated tests | 2 lines in odoo.conf to switch on | 0 code changes in Odoo | 30 s default retry after an outage |
What it does
The module replaces Odoo's session store with a Redis one. It is loaded as a server wide module, so it is active before any database is opened - the login page, the database selector and every request use Redis.
Sessions are stored as JSON under a key prefix you choose, with a time to live that is refreshed on every request, so idle sessions disappear by themselves. Odoo's own session rotation, logout, device revocation (log out of other devices) and the session garbage collector keep working.
If Redis cannot be reached, the module logs one warning, writes sessions to the filesystem and retries Redis after 30 seconds. When Redis is back, sessions written during the outage are moved to Redis the next time they are used. A button moves all existing disk sessions in one go, keeping their remaining lifetime.
Who it is for
Several Odoo servers or containers Run Odoo behind a load balancer without sticky sessions and without users being logged out. | Kubernetes and Docker set-ups Pods come and go; sessions live in Redis instead of the pod's disk. | Busy single servers Stop millions of small session files from piling up in the data directory. |
Key Features
Screenshots from an Odoo 19 test server started with the module in server_wide_modules and a local Redis 5.0.
| 1Status at a glance |
| Active backend, Redis version, memory, number of sessions, key prefix, expiry, Odoo's inactivity limit, and where each setting comes from (odoo.conf, environment or default). |
![]() Sessions stored in Redis |
| 2Keeps working when Redis is down |
| Redis was stopped on purpose: Odoo switched to the filesystem, logged a warning and counted the fallback events. Users could still log in. |
![]() Automatic filesystem fallback |
| 3Move disk sessions to Redis |
| One click copies every session file to Redis with its remaining lifetime and deletes the file - nobody is logged out when you switch. |
![]() Disk sessions moved to Redis |
| 4Test the connection |
| Checks the configured server, password and TLS settings and reports the Redis version and response time. |
![]() Connection test |
| 5Session garbage collection |
| Redis expires sessions by TTL. When Odoo's inactivity limit is shorter than the expiry, idle sessions are removed by Odoo's own daily clean-up or on demand. |
![]() Garbage collection on demand |
Everything included
| Sessions in Redis for every Odoo process | Session rotation and logout as in standard Odoo |
| Loaded with server_wide_modules or --load | Log out other devices (device revocation) |
| Settings in odoo.conf or environment variables | Session GC with Odoo's inactivity limit |
| Host, port, database number, username, password | Filesystem fallback with retry interval |
| redis:// and rediss:// URLs | Outage sessions moved back to Redis automatically |
| TLS with CA, client certificate and key | Bulk move of existing disk sessions |
| Key prefix to share one Redis between instances | Status screen for administrators |
| Expiry (TTL) refreshed on every request | Old configuration names of other modules accepted |
How it works
1 Install the package pip install redis in the Odoo environment and install the module in a database. | 2 Configure redis_session_enabled = True plus host, port, password, prefix and expiry in odoo.conf (or ODOO_REDIS_SESSION_* variables). | 3 Load it server wide server_wide_modules = base,web,mdv_redis_session_store and restart Odoo. | 4 Check Settings -> Redis Sessions shows the backend, the session count and the configuration. |
Settings
| redis_session_enabled | True to use Redis (env ODOO_REDIS_SESSION=1). |
| redis_session_host / _port / _db | Redis server, default localhost, 6379, database 0. |
| redis_session_url | Full redis:// or rediss:// URL instead of host and port. |
| redis_session_username / _password | Redis ACL user and password. |
| redis_session_ssl, _ssl_ca_certs, _ssl_certfile, _ssl_keyfile, _ssl_cert_reqs | TLS connection settings. |
| redis_session_prefix | Key prefix, default odoo:session: - use one per Odoo instance. |
| redis_session_expiry | Session lifetime in seconds, default 7 days, refreshed on each request. |
| redis_session_timeout / _retry_interval | Socket timeout (2 s) and pause before retrying after a failure (30 s). |
FAQ
Compatibility
Depends on base and web. Python package: redis. Not for Odoo Online or Odoo.sh, where you cannot change the server configuration.
EMAIL |
AUTHOR Modvanta |
INCLUDED Module, updates for Odoo 19, email support |
Support: modvantaapps@gmail.com - questions before buying are welcome.
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 627 |
| Technical Name |
mdv_redis_session_store |
| License | OPL-1 |
| Website | https://modvantaapps.tech/odoo-apps/redis-session-store/ |
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.





Please log in to comment on this module