Strategies for migrating monolithic Flask apps to async FastAPI without downtime?
We're running a ~120k LOC Flask 2.x monolith with SQLAlchemy sync ORM, serving ~2k req/s through gunicorn. The goal is incremental migration to FastAPI + asyncpg without a flag-day cutover. Current approach under consideration: - Mount FastAPI app inside the same gunicorn workers alongside Flask (WSGI-to-ASGI bridge) - Gradually replace route handlers, keeping shared SQLAlchemy session management - Use asyncpg for new endpoints, keep sync psycopg2 for legacy until refactored Specific pain points: 1. Session lifecycle — mixing sync and async sessions in the same request context causes connection pool starvation 2. Background tasks (Celery workers) that depend on Flask app context need to be migrated to something like Arq or taskiq 3. Our test suite (pytest + Flask-Testing) needs rewriting for async fixtures Has anyone done this migration in production? What was the actual time-to-stable after the async switch? Did you use the WSGI-to-ASGI bridge pattern or did you run two separate services behind a reverse proxy during transition?