[PR #168] [CLOSED] feat: Add multi-worker support for uvicorn deployment #183

Closed
opened 2026-02-15 21:15:14 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/mcpo/pull/168
Author: @LYH-RAIN
Created: 6/4/2025
Status: Closed

Base: devHead: main


📝 Commits (3)

  • 5138163 feat: Add multi-worker support for uvicorn deployment
  • 7f6510b feat: Add multi-worker support for uvicorn deployment
  • 648354b feat: Add multi-worker support for uvicorn deployment

📊 Changes

7 files changed (+1179 additions, -307 deletions)

View changed files

📝 README.md (+37 -4)
📝 pyproject.toml (+5 -1)
📝 src/mcpo/__init__.py (+10 -0)
📝 src/mcpo/main.py (+461 -196)
src/mcpo/tests/test_multi_worker.py (+462 -0)
📝 src/mcpo/utils/auth.py (+9 -13)
📝 src/mcpo/utils/main.py (+195 -93)

📄 Description

feat: Add multi-worker support and clean up unused dependencies

  • Configure uvicorn to support multiple worker processes
  • Add worker count configuration via environment variables
  • Remove unused httpx dependency to reduce package size
  • Optimize Docker deployment for better resource utilization
  • Enable horizontal scaling within single container instance

Improves application throughput and CPU utilization on multi-core systems.

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.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests to validate 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 clearly categorize this pull request, prefix the pull request title using one of the following:
    • feat: Introduces a new feature or enhancement to the codebase

Changelog Entry

Description

Add multi-worker support to uvicorn deployment for improved performance and resource utilization on multi-core systems. This enhancement enables better handling of concurrent requests and maximizes CPU utilization. Also clean up unused dependencies to reduce package footprint and improve installation speed.

Added

  • Multi-worker process support for uvicorn deployment via --workers parameter
  • Worker count configuration through environment variables and command-line options
  • Configuration serialization mechanism for sharing settings between worker processes
  • Application factory function (get_app()) for proper multi-worker initialization
  • Enhanced logging with worker process identification (PID tracking)
  • Comprehensive test suite for multi-worker functionality and configuration management
  • Performance guidelines and recommendations in documentation
  • Multi-worker examples in README with best practices

Changed

  • Updated run() function to support both single and multi-worker deployment modes
  • Modified application creation logic to support configuration sharing between workers
  • Improved logging format to include process ID for better worker identification
  • Enhanced CLI interface with --workers parameter and validation
  • Updated documentation with multi-worker usage examples and performance tips

Fixed

  • Resource utilization inefficiency on multi-core systems
  • Single-threaded bottleneck in high-concurrency scenarios
  • Application scaling limitations within single container deployments

Security

  • No security-related changes in this release

Breaking Changes

  • None. All changes are backward compatible with existing single-worker deployments.

Additional Information

Performance Impact:

  • Significant throughput improvement on multi-core systems (tested up to 16 cores)
  • Better resource utilization with recommended worker count: min(CPU_CORES * 2, 32)
  • Maintains backward compatibility with single worker mode for development

Configuration:

  • Default behavior unchanged (single worker)
  • Worker count configurable via --workers CLI parameter
  • Environment variable support for containerized deployments
  • Automatic configuration sharing between workers using serialization

Testing:

  • Added 20+ comprehensive test cases covering multi-worker scenarios
  • Tested configuration serialization/deserialization
  • Verified single worker mode compatibility
  • Performance tested with various worker counts (1, 4, 8, 16, 32)
  • All existing tests pass without modification

Documentation Updates:

  • Updated README with multi-worker examples
  • Added performance guidelines and best practices
  • Included Docker deployment examples with worker configuration
  • Added development testing instructions

Code Quality:

  • Passed Black code formatting checks
  • Passed Flake8 linting validation
  • All tests passing with pytest
  • Self-reviewed for coding standards compliance

Related Issues

  • Addresses performance limitations on multi-core deployment environments
  • Improves scalability for production deployments
  • Reduces dependency footprint for faster installations

Testing Commands Used

# Code formatting and linting
black mcpo/
flake8 mcpo/

# Test execution
pytest tests/ -v

# Performance testing
python benchmark.py constant 100 60  # 100 users, 60 seconds

Deployment tested on:

  • Single core systems (development)
  • Multi-core systems (4, 8, 16 cores)
  • Docker containers with resource limits
  • Various MCP server configurations (stdio, SSE, streamable_http)


---

<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/mcpo/pull/168 **Author:** [@LYH-RAIN](https://github.com/LYH-RAIN) **Created:** 6/4/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `main` --- ### 📝 Commits (3) - [`5138163`](https://github.com/open-webui/mcpo/commit/513816326dde017242e868703cf63c33cc8141f1) feat: Add multi-worker support for uvicorn deployment - [`7f6510b`](https://github.com/open-webui/mcpo/commit/7f6510b761d862c13ccb810c484d687a0c2c836e) feat: Add multi-worker support for uvicorn deployment - [`648354b`](https://github.com/open-webui/mcpo/commit/648354b7a5bdbace56ae19d27db33fd7c56d21e4) feat: Add multi-worker support for uvicorn deployment ### 📊 Changes **7 files changed** (+1179 additions, -307 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+37 -4) 📝 `pyproject.toml` (+5 -1) 📝 `src/mcpo/__init__.py` (+10 -0) 📝 `src/mcpo/main.py` (+461 -196) ➕ `src/mcpo/tests/test_multi_worker.py` (+462 -0) 📝 `src/mcpo/utils/auth.py` (+9 -13) 📝 `src/mcpo/utils/main.py` (+195 -93) </details> ### 📄 Description # feat: Add multi-worker support and clean up unused dependencies - Configure uvicorn to support multiple worker processes - Add worker count configuration via environment variables - Remove unused httpx dependency to reduce package size - Optimize Docker deployment for better resource utilization - Enable horizontal scaling within single container instance Improves application throughput and CPU utilization on multi-core systems. # 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] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests to validate 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 clearly categorize this pull request, prefix the pull request title using one of the following: - **feat**: Introduces a new feature or enhancement to the codebase ✅ # Changelog Entry ### Description Add multi-worker support to uvicorn deployment for improved performance and resource utilization on multi-core systems. This enhancement enables better handling of concurrent requests and maximizes CPU utilization. Also clean up unused dependencies to reduce package footprint and improve installation speed. ### Added - Multi-worker process support for uvicorn deployment via `--workers` parameter - Worker count configuration through environment variables and command-line options - Configuration serialization mechanism for sharing settings between worker processes - Application factory function (`get_app()`) for proper multi-worker initialization - Enhanced logging with worker process identification (PID tracking) - Comprehensive test suite for multi-worker functionality and configuration management - Performance guidelines and recommendations in documentation - Multi-worker examples in README with best practices ### Changed - Updated `run()` function to support both single and multi-worker deployment modes - Modified application creation logic to support configuration sharing between workers - Improved logging format to include process ID for better worker identification - Enhanced CLI interface with `--workers` parameter and validation - Updated documentation with multi-worker usage examples and performance tips ### Fixed - Resource utilization inefficiency on multi-core systems - Single-threaded bottleneck in high-concurrency scenarios - Application scaling limitations within single container deployments ### Security - No security-related changes in this release ### Breaking Changes - None. All changes are backward compatible with existing single-worker deployments. --- ### Additional Information **Performance Impact:** - Significant throughput improvement on multi-core systems (tested up to 16 cores) - Better resource utilization with recommended worker count: `min(CPU_CORES * 2, 32)` - Maintains backward compatibility with single worker mode for development **Configuration:** - Default behavior unchanged (single worker) - Worker count configurable via `--workers` CLI parameter - Environment variable support for containerized deployments - Automatic configuration sharing between workers using serialization **Testing:** - Added 20+ comprehensive test cases covering multi-worker scenarios - Tested configuration serialization/deserialization - Verified single worker mode compatibility - Performance tested with various worker counts (1, 4, 8, 16, 32) - All existing tests pass without modification **Documentation Updates:** - Updated README with multi-worker examples - Added performance guidelines and best practices - Included Docker deployment examples with worker configuration - Added development testing instructions **Code Quality:** - Passed Black code formatting checks - Passed Flake8 linting validation - All tests passing with pytest - Self-reviewed for coding standards compliance ### Related Issues - Addresses performance limitations on multi-core deployment environments - Improves scalability for production deployments - Reduces dependency footprint for faster installations ### Testing Commands Used ```bash # Code formatting and linting black mcpo/ flake8 mcpo/ # Test execution pytest tests/ -v # Performance testing python benchmark.py constant 100 60 # 100 users, 60 seconds ``` **Deployment tested on:** - Single core systems (development) - Multi-core systems (4, 8, 16 cores) - Docker containers with resource limits - Various MCP server configurations (stdio, SSE, streamable_http) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 21:15:14 -05:00
yindo closed this issue 2026-02-15 21:15:14 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-webui/mcpo#183