Add production-ready uvicorn/gunicorn API deployment configuration module#234
Draft
Add production-ready uvicorn/gunicorn API deployment configuration module#234
Conversation
…iguration Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Co-authored-by: QMasterMoo <3915399+QMasterMoo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add default uvicorn/gunicorn API deployment configuration
Add production-ready uvicorn/gunicorn API deployment configuration module
Oct 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces a new
libs/python/api_deploymentmodule that provides production-ready deployment configuration for Python API applications using gunicorn with uvicorn workers. This addresses the need for a standardized, reusable deployment configuration that can be easily integrated into FastAPI and other ASGI applications.Problem
Currently, API applications in the repository run uvicorn directly (e.g.,
uvicorn.run(app, host="0.0.0.0", port=8000)), which is suitable for development but not production. Production deployments require:Each application would need to implement this configuration separately, leading to duplication and inconsistency.
Solution
The new
api_deploymentmodule provides:1. Production-Ready Configuration (
config.py)(CPU cores * 2) + 1max_requests=1000and jitteruvicorn.workers.UvicornWorkerfor ASGI compatibility2. Command-Line Interface (
cli.py)--productionflag)--workers,--port,--timeout,--log-levelflags3. Easy Integration
Before:
After:
Usage:
What's Included
Core Module (6 files, ~650 lines)
config.py: Configuration functionscli.py: Command-line interfacetest_config.py,test_cli.py: Comprehensive test coverage (20 tests)BUILD.bazel: Bazel build integration__init__.py: Package exportsDocumentation (4 files, ~1,270 lines)
libs/python/api_deployment/README.md: Module documentationdocs/API_DEPLOYMENT.md: Complete deployment guide with examplesdocs/API_DEPLOYMENT_HELM.md: Integration with Helm chartsdocs/API_DEPLOYMENT_SUMMARY.md: Implementation detailsExamples (4 files, ~265 lines)
demo/hello_fastapi/main_with_deployment.py: Full CLI exampledemo/hello_fastapi/example_minimal.py: Minimal integrationdemo/hello_fastapi/Dockerfile.example: Docker deploymentdemo/hello_fastapi/k8s-deployment-example.yaml: Kubernetes manifestsValidation
tools/scripts/validate_api_deployment.py: Automated validation scriptKey Features
Integration with Existing Infrastructure
With Helm Charts
With Containers
With Kubernetes
Testing
Documentation
Comprehensive documentation is provided at multiple levels:
Files Changed
Breaking Changes
None. This is a new module that doesn't modify any existing functionality.
Next Steps
Future enhancements could include:
This implementation provides a solid foundation for deploying Python API applications in production while maintaining flexibility and ease of use.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.