feat: Implement high-impact code optimizations

- Migrate from Flask to Quart (async) for better concurrency
- Add httpx with HTTP/2 connection pooling for Telegram
- Add diskcache for caching health check responses
- Increase ThreadPoolExecutor workers from 4 to 8 (configurable)
- Remove hardcoded paths - use environment variables
- Add circuit breaker pattern for resilient external calls
- Add proper timeout handling for health checks
- Pin all dependencies in requirements.txt
- Add graceful startup/shutdown handlers
- Pre-warm agent in background thread on startup
This commit is contained in:
2026-06-16 21:50:54 +02:00
parent 58ca990673
commit 5daa338c78
3 changed files with 486 additions and 145 deletions
+19 -2
View File
@@ -1,2 +1,19 @@
flask>=3.0
requests>=2.31
# Core dependencies - pinned versions for reproducible builds
flask==3.0.3
requests==2.32.3
# Async/Production dependencies
quart==0.19.4
uvicorn[standard]==0.30.6
gunicorn==22.0.0
# Performance optimizations
httpx==0.27.2 # HTTP/2 connection pooling for Telegram
diskcache==5.6.3 # Semantic caching
brotli==1.1.0 # Compression
# Resilience patterns
tenacity==8.5.0 # Retry logic with exponential backoff
# Type hints support
typing_extensions==4.12.2