Adds support for Redis Sentinel failover clusters, allowing for a fully highly available OpenWebUI-Setup.
Pull Request Checklist
Before submitting, make sure you've checked the following:
Target branch: Please verify that the pull request targets the dev branch.
Description: Provide a concise description of the changes made in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Testing: Have you written and run sufficient tests for validating the changes?
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
BREAKING CHANGE: Significant changes that may affect compatibility
build: Changes that affect the build system or external dependencies
ci: Changes to our continuous integration processes or workflows
chore: Refactor, cleanup, or other non-functional code changes
docs: Documentation update or addition
feat: Introduces a new feature or enhancement to the codebase
fix: Bug fix or error correction
i18n: Internationalization or localization changes
perf: Performance improvement
refactor: Code restructuring for better maintainability, readability, or scalability
style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
test: Adding missing tests or correcting existing tests
WIP: Work in progress, a temporary label for incomplete or ongoing work
Changelog Entry
Added Redis Sentinel support for Websockets
Added Redis Sentinel support for AppConfig
Description
The PR adds support for Redis Sentinel failover clusters, allowing for a fully highly available OpenWebUI-Setup. Unfortunately, the implemention needs to work around socketio's lack of support for Redis Sentinel in a somewhat involved way, by creating a class AsyncRedisSentinelManager that inherits from socketio's AsyncRedisManager and bypasses the parent constructor. Otherwise, the Sentinel support from redis-py is used directly.
To avoid adding too many new env variables, WEBSOCKET_REDIS_URL (and REDIS_URL) is maintained as source of Redis configuration, but with the "host" part being used as Sentinel service name.
The code has been tested in a staging environment and is stable.
Added
Redis Sentinel support for Websocket and AppConfig
New envs: WEBSOCKET_SENTINEL_HOSTS, WEBSOCKET_SENTINEL_PORT, SENTINEL_HOSTS, SENTINEL_PORT
Notes
I'm not entirely sure why there are both REDIS_URL and WEBSOCKET_REDIS_URL envs. It seems like the former has only recently been picked up for AppConfig. For the moment, I have correspondingly added two sets of Sentinel environment variables. But because I'm not sure if this is supposed to stay like this, I'm currently holding back on commiting corresponding changes to the documentation.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/11148
**Author:** [@Ithanil](https://github.com/Ithanil)
**Created:** 3/4/2025
**Status:** ✅ Merged
**Merged:** 3/28/2025
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `redis_sentinel`
---
### 📝 Commits (7)
- [`3b35774`](https://github.com/open-webui/open-webui/commit/3b357746d8b5f0f24cceab56846073b62465a333) first part of adding Redis Sentinel support
- [`4370332`](https://github.com/open-webui/open-webui/commit/4370332e32730deb6db689f6d01456b0bd6e5076) second part of adding Redis Sentinel support
- [`9bf6639`](https://github.com/open-webui/open-webui/commit/9bf663934afb7e676938a6753dabf5863e53057f) fixes & add envs for Sentinel implementation
- [`9167a8b`](https://github.com/open-webui/open-webui/commit/9167a8bef0addc2f9613effa582b43acc43fe607) refac as prep for sentinel support in AppConfig
- [`e68cd9b`](https://github.com/open-webui/open-webui/commit/e68cd9b6718374f243d94bc2fb62dc4b6db25b08) Redis Sentinel support for AppConfig
- [`d0b13cf`](https://github.com/open-webui/open-webui/commit/d0b13cf38814db23842e50200991f43d00bbf688) prefix sentinel envs with redis_
- [`0615c11`](https://github.com/open-webui/open-webui/commit/0615c11a53ca67def3a45bd2c6ca3256479bb14f) fix sentinel connection being attempted for non-sentinel redis
### 📊 Changes
**6 files changed** (+128 additions, -14 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/config.py` (+5 -3)
📝 `backend/open_webui/env.py` (+6 -0)
📝 `backend/open_webui/main.py` (+6 -1)
📝 `backend/open_webui/socket/main.py` (+15 -4)
📝 `backend/open_webui/socket/utils.py` (+5 -6)
➕ `backend/open_webui/utils/redis.py` (+91 -0)
</details>
### 📄 Description
# Support for Redis Sentinel
Adds support for Redis Sentinel failover clusters, allowing for a fully highly available OpenWebUI-Setup.
## Pull Request Checklist
**Before submitting, make sure you've checked the following:**
- [x] **Target branch:** Please verify that the pull request targets the `dev` branch.
- [x] **Description:** Provide a concise description of the changes made in this pull request.
- [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [x] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
- [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [x] **Testing:** Have you written and run sufficient tests for validating the changes?
- [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [x] **Prefix:** To cleary categorize this pull request, prefix the pull request title, using one of the following:
- **BREAKING CHANGE**: Significant changes that may affect compatibility
- **build**: Changes that affect the build system or external dependencies
- **ci**: Changes to our continuous integration processes or workflows
- **chore**: Refactor, cleanup, or other non-functional code changes
- **docs**: Documentation update or addition
- **feat**: Introduces a new feature or enhancement to the codebase
- **fix**: Bug fix or error correction
- **i18n**: Internationalization or localization changes
- **perf**: Performance improvement
- **refactor**: Code restructuring for better maintainability, readability, or scalability
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
- **test**: Adding missing tests or correcting existing tests
- **WIP**: Work in progress, a temporary label for incomplete or ongoing work
# Changelog Entry
- Added Redis Sentinel support for Websockets
- Added Redis Sentinel support for AppConfig
### Description
The PR adds support for Redis Sentinel failover clusters, allowing for a fully highly available OpenWebUI-Setup. Unfortunately, the implemention needs to work around socketio's lack of support for Redis Sentinel in a somewhat involved way, by creating a class AsyncRedisSentinelManager that inherits from socketio's AsyncRedisManager and bypasses the parent constructor. Otherwise, the Sentinel support from redis-py is used directly.
To avoid adding too many new env variables, WEBSOCKET_REDIS_URL (and REDIS_URL) is maintained as source of Redis configuration, but with the "host" part being used as Sentinel service name.
The code has been tested in a staging environment and is stable.
### Added
- Redis Sentinel support for Websocket and AppConfig
- New envs: WEBSOCKET_SENTINEL_HOSTS, WEBSOCKET_SENTINEL_PORT, SENTINEL_HOSTS, SENTINEL_PORT
### Notes
~~I'm not entirely sure why there are both REDIS_URL and WEBSOCKET_REDIS_URL envs. It seems like the former has only recently been picked up for AppConfig. For the moment, I have correspondingly added two sets of Sentinel environment variables. But because I'm not sure if this is supposed to stay like this, I'm currently holding back on commiting corresponding changes to the documentation.~~
Doc PR: https://github.com/open-webui/docs/pull/457
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/11148
Author: @Ithanil
Created: 3/4/2025
Status: ✅ Merged
Merged: 3/28/2025
Merged by: @tjbck
Base:
dev← Head:redis_sentinel📝 Commits (7)
3b35774first part of adding Redis Sentinel support4370332second part of adding Redis Sentinel support9bf6639fixes & add envs for Sentinel implementation9167a8brefac as prep for sentinel support in AppConfige68cd9bRedis Sentinel support for AppConfigd0b13cfprefix sentinel envs with redis_0615c11fix sentinel connection being attempted for non-sentinel redis📊 Changes
6 files changed (+128 additions, -14 deletions)
View changed files
📝
backend/open_webui/config.py(+5 -3)📝
backend/open_webui/env.py(+6 -0)📝
backend/open_webui/main.py(+6 -1)📝
backend/open_webui/socket/main.py(+15 -4)📝
backend/open_webui/socket/utils.py(+5 -6)➕
backend/open_webui/utils/redis.py(+91 -0)📄 Description
Support for Redis Sentinel
Adds support for Redis Sentinel failover clusters, allowing for a fully highly available OpenWebUI-Setup.
Pull Request Checklist
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
The PR adds support for Redis Sentinel failover clusters, allowing for a fully highly available OpenWebUI-Setup. Unfortunately, the implemention needs to work around socketio's lack of support for Redis Sentinel in a somewhat involved way, by creating a class AsyncRedisSentinelManager that inherits from socketio's AsyncRedisManager and bypasses the parent constructor. Otherwise, the Sentinel support from redis-py is used directly.
To avoid adding too many new env variables, WEBSOCKET_REDIS_URL (and REDIS_URL) is maintained as source of Redis configuration, but with the "host" part being used as Sentinel service name.
The code has been tested in a staging environment and is stable.
Added
Notes
I'm not entirely sure why there are both REDIS_URL and WEBSOCKET_REDIS_URL envs. It seems like the former has only recently been picked up for AppConfig. For the moment, I have correspondingly added two sets of Sentinel environment variables. But because I'm not sure if this is supposed to stay like this, I'm currently holding back on commiting corresponding changes to the documentation.Doc PR: https://github.com/open-webui/docs/pull/457
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.