Add gunicorn support for API server with rolling worker restarts #60940
+1,438
−8
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.
Related #60804 & #60919
This PR adds an optional
gunicornserver type for the API server, providing:Usage
Configuration
New
[api]configuration options:server_type:uvicorn(default) orgunicornworker_refresh_interval: Seconds between worker refresh cycles (0 = disabled)worker_refresh_batch_size: Workers to refresh per cycle (default: 1)reload_on_plugin_change: Reload on plugin file changes (default: False)Architecture
Rolling Restart Flow
batch_sizenew workers (SIGTTIN)/api/v2/monitor/health)batch_sizeold workers (SIGTTOU - kills oldest)Gotchas vs Uvicorn mode
Why Gunicorn is Optional
Gunicorn is an optional extra (
apache-airflow-core[gunicorn]) rather than a required dependency because:When to use gunicorn:
Known Limitations / Follow-up Items
Log Format Inconsistency
Gunicorn subprocess uses its own logging format which differs from Airflow's structlog format:
This means API server logs will have mixed formats when using gunicorn mode. A follow-up PR should add
--logconfigto gunicorn to match Airflow's format for consistent log parsing/export.