You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "trau-sca (via GitHub)" <gi...@apache.org> on 2025/10/14 19:02:05 UTC
[I] Slow API server website load times [airflow]
trau-sca opened a new issue, #56635:
URL: https://github.com/apache/airflow/issues/56635
### Apache Airflow version
3.1.0
### If "Other Airflow 2/3 version" selected, which one?
_No response_
### What happened?
Hi, we've been battling issues for the past few weeks on our api-server pod being very slow to display the website information (up to a minute to load the dags card screen). Sometimes the api server pod even restarts due to the liveness probe. I don't see any errors when it happens either.
Quite a few requests look long, but the biggest one is `dags?dag_runs_limit=14&limit=50&offset=0&exclude_stale=true&order_by=-dag_display_name` taking 51s, but even `dags?is_favorite=true` takes 4 seconds.
When remoting into the dag-processor and doing a curl command for the first one - it also takes 51s. I used the private endpoint assigned to the api-server while I was in the dag-processor.
We are running on airflow 3.1.0 and the 1.18.0 helm chart in an Azure Kubernetes cluster with an Azure PostgreSQL database.
No pods are going past their resource requests when this issue occurs, and the resources for the database are very low in usage.
I have disabled sqlalchemy pooling, and use pgbouncer in airflow as well as in the PostgreSQL database.
I have the following configuration for airflow:
```
pgbouncer:
enabled: true
maxClientConn: 500
metadataPoolSize: 50
resultBackendPoolSize: 10
extraIni: |
pool_mode = transaction
```
On PostgreSQL, I have pgbouncer's pool_mode set to session, and the default_pool_size is 100.
We have 16 DAGs, and have a daily job that runs a db clean for anything older than 90 days.
### What you think should happen instead?
_No response_
### How to reproduce
Clicking on DAGs card screen - I have 16 DAGs running with an Azure PostgreSQL backend.
### Operating System
Azure Kubernetes
### Versions of Apache Airflow Providers
_No response_
### Deployment
Official Apache Airflow Helm Chart
### Deployment details
Azure PostgreSQL 16.9, Azure Kubernetes v1.32.7
### Anything else?
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3541585677
> > It is possible to deploy the execution_api and public/ui api separately. This will completely remove the issue you have with UI potentially blocking the api server.
>
> [@pierrejeambrun](https://github.com/pierrejeambrun) Can you expand on this? i.e. Is it something that is possible to configure today or is it just something that is conceptually possible?
You can do it any time now - depends how you deploy Airflow - `api-server` is just a component that you can use - if you have several of them exposed under `api-server-for-web.my_url.com` behind log balancer and `api-server-for-tasks.my-url.com` and configure your webserver to talk to the first but your talks talk to the other, this will **just work**.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3403204491
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "rcampos87 (via GitHub)" <gi...@apache.org>.
rcampos87 commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3404559725
We are experiencing the same on both 3.0.6 and 3.1.0, running on AWS EKS backed by mysql. Loading dags takes a long time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3427232743
@trau-sca How many dag runs do you have? I suspect that querying the dag runs table is the issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3456040061
We enabled the sqlalchemy query logging we saw a lot of n+1 type of queries in our testing environment. It seems that `DagRun` has relationship to `task_instances`, `task_instance_histories`, `deadlines` and `dag_run_note`. It seems using `model_validate` in pydantic loads all attributes and this causes each attribute access to be a separate query though it's not used anywhere in the UI.
Since these are per dag_run on a page with 15 dags and 2135 dagruns with each dag having 3 dagruns this causes 45 (15 * 3) queries per table `task_instances`, `task_instance_histories`, `deadlines` and `dag_run_note` resulting in around 200+ queries for the page load. sqlalchemy has an option of using `noload` to not which was deprecated recently but still useful here since the fields are not used. An improved patch would be to use `DAGRunLightResponse` which will also result in reduction of fields from database and reduction in response payload.
Another issue we found is that the `pending_actions.value` which is `None` when not passed is evaluated as True in `pending_actions.value is not False` as in `None is not False` triggering extra checks on all pages even ones not using the required actions filter. A patch we applied internally as attached loads a dagslist page of 15 dags with 3 dagruns per page in 100ms compared to 700-1000ms. This also gave noticeable improvement in our testing environment with 11k dags and 500k dagruns loading in 1-2s for a dags list page of 25 dags per page.
I will raise separate tickets for each issue along with further observations. If someone can test the patch and report back the results it will be helpful.
https://github.com/pydantic/pydantic/issues/8192
https://github.com/sqlalchemy/sqlalchemy/discussions/10120
https://docs.sqlalchemy.org/en/20/orm/queryguide/relationships.html#sqlalchemy.orm.noload
```
[2025-10-28T11:24:03.322253Z] {base.py:1577} INFO - [cached since 13.18s ago] {'param_1': 'dag_110', 'param_2': 'scheduled__2025-01-01T00:00:00+00:00'}
[2025-10-28T11:24:03.324796Z] {base.py:1577} INFO - SELECT task_instance.rendered_map_index AS task_instance_rendered_map_index, task_instance.task_display_name AS task_instance_task_display_name, task_instance.id AS task_instance_id, task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_w
eight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.scheduled_dttm AS task_instance_scheduled_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.last_heartbeat_at AS task_instance_last_heartbeat_at, task_instance.pid AS task_instance_pid, task_instance.executor AS task_instance_executor, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.context_carrier AS task_instance_context_carrier, task_instance.span_status AS task_instance_span_status, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_
instance.next_kwargs AS task_instance_next_kwargs, task_instance.dag_version_id AS task_instance_dag_version_id, dag_run_1.state AS dag_run_1_state, dag_run_1.id AS dag_run_1_id, dag_run_1.dag_id AS dag_run_1_dag_id, dag_run_1.queued_at AS dag_run_1_queued_at, dag_run_1.logical_date AS dag_run_1_logical_date, dag_run_1.start_date AS dag_run_1_start_date, dag_run_1.end_date AS dag_run_1_end_date, dag_run_1.run_id AS dag_run_1_run_id, dag_run_1.creating_job_id AS dag_run_1_creating_job_id, dag_run_1.run_type AS dag_run_1_run_type, dag_run_1.triggered_by AS dag_run_1_triggered_by, dag_run_1.triggering_user_name AS dag_run_1_triggering_user_name, dag_run_1.conf AS dag_run_1_conf, dag_run_1.data_interval_start AS dag_run_1_data_interval_start, dag_run_1.data_interval_end AS dag_run_1_data_interval_end, dag_run_1.run_after AS dag_run_1_run_after, dag_run_1.last_scheduling_decision AS dag_run_1_last_scheduling_decision, dag_run_1.log_template_id AS dag_run_1_log_template_id, dag_run_1.upda
ted_at AS dag_run_1_updated_at, dag_run_1.clear_number AS dag_run_1_clear_number, dag_run_1.backfill_id AS dag_run_1_backfill_id, dag_run_1.bundle_version AS dag_run_1_bundle_version, dag_run_1.scheduled_by_job_id AS dag_run_1_scheduled_by_job_id, dag_run_1.context_carrier AS dag_run_1_context_carrier, dag_run_1.span_status AS dag_run_1_span_status, dag_run_1.created_dag_version_id AS dag_run_1_created_dag_version_id
FROM task_instance INNER JOIN dag_run AS dag_run_1 ON dag_run_1.dag_id = task_instance.dag_id AND dag_run_1.run_id = task_instance.run_id
WHERE %(param_1)s = task_instance.dag_id AND %(param_2)s = task_instance.run_id
[2025-10-28T11:24:03.325142Z] {base.py:1577} INFO - [cached since 13.18s ago] {'param_1': 'dag_110', 'param_2': 'scheduled__2025-01-01T00:00:00+00:00'}
[2025-10-28T11:24:03.329438Z] {base.py:1577} INFO - SELECT dag_run_note.user_id AS dag_run_note_user_id, dag_run_note.dag_run_id AS dag_run_note_dag_run_id, dag_run_note.content AS dag_run_note_content, dag_run_note.created_at AS dag_run_note_created_at, dag_run_note.updated_at AS dag_run_note_updated_at
FROM dag_run_note
WHERE dag_run_note.dag_run_id = %(pk_1)s
[2025-10-28T11:24:03.329716Z] {base.py:1577} INFO - [cached since 13.2s ago] {'pk_1': 421}
[2025-10-28T11:24:03.331467Z] {base.py:1577} INFO - SELECT task_instance_history.task_instance_id AS task_instance_history_task_instance_id, task_instance_history.task_id AS task_instance_history_task_id, task_instance_history.dag_id AS task_instance_history_dag_id, task_instance_history.run_id AS task_instance_history_run_id, task_instance_history.map_index AS task_instance_history_map_index, task_instance_history.try_number AS task_instance_history_try_number, task_instance_history.start_date AS task_instance_history_start_date, task_instance_history.end_date AS task_instance_history_end_date, task_instance_history.duration AS task_instance_history_duration, task_instance_history.state AS task_instance_history_state, task_instance_history.max_tries AS task_instance_history_max_tries, task_instance_history.hostname AS task_instance_history_hostname, task_instance_history.unixname AS task_instance_history_unixname, task_instance_history.pool AS task_instance_history_pool, task_ins
tance_history.pool_slots AS task_instance_history_pool_slots, task_instance_history.queue AS task_instance_history_queue, task_instance_history.priority_weight AS task_instance_history_priority_weight, task_instance_history.operator AS task_instance_history_operator, task_instance_history.custom_operator_name AS task_instance_history_custom_operator_name, task_instance_history.queued_dttm AS task_instance_history_queued_dttm, task_instance_history.scheduled_dttm AS task_instance_history_scheduled_dttm, task_instance_history.queued_by_job_id AS task_instance_history_queued_by_job_id, task_instance_history.pid AS task_instance_history_pid, task_instance_history.executor AS task_instance_history_executor, task_instance_history.executor_config AS task_instance_history_executor_config, task_instance_history.updated_at AS task_instance_history_updated_at, task_instance_history.rendered_map_index AS task_instance_history_rendered_map_index, task_instance_history.context_carrier AS task_ins
tance_history_context_carrier, task_instance_history.span_status AS task_instance_history_span_status, task_instance_history.external_executor_id AS task_instance_history_external_executor_id, task_instance_history.trigger_id AS task_instance_history_trigger_id, task_instance_history.trigger_timeout AS task_instance_history_trigger_timeout, task_instance_history.next_method AS task_instance_history_next_method, task_instance_history.next_kwargs AS task_instance_history_next_kwargs, task_instance_history.task_display_name AS task_instance_history_task_display_name, task_instance_history.dag_version_id AS task_instance_history_dag_version_id
FROM task_instance_history
WHERE %(param_1)s = task_instance_history.dag_id AND %(param_2)s = task_instance_history.run_id ORDER BY task_instance_history.dag_version_id
[2025-10-28T11:24:03.331751Z] {base.py:1577} INFO - [cached since 13.19s ago] {'param_1': 'dag_101', 'param_2': 'scheduled__2025-01-01T00:00:00+00:00'}
[2025-10-28T11:24:03.333946Z] {base.py:1577} INFO - SELECT task_instance.rendered_map_index AS task_instance_rendered_map_index, task_instance.task_display_name AS task_instance_task_display_name, task_instance.id AS task_instance_id, task_instance.task_id AS task_instance_task_id, task_instance.dag_id AS task_instance_dag_id, task_instance.run_id AS task_instance_run_id, task_instance.map_index AS task_instance_map_index, task_instance.start_date AS task_instance_start_date, task_instance.end_date AS task_instance_end_date, task_instance.duration AS task_instance_duration, task_instance.state AS task_instance_state, task_instance.try_number AS task_instance_try_number, task_instance.max_tries AS task_instance_max_tries, task_instance.hostname AS task_instance_hostname, task_instance.unixname AS task_instance_unixname, task_instance.pool AS task_instance_pool, task_instance.pool_slots AS task_instance_pool_slots, task_instance.queue AS task_instance_queue, task_instance.priority_w
eight AS task_instance_priority_weight, task_instance.operator AS task_instance_operator, task_instance.custom_operator_name AS task_instance_custom_operator_name, task_instance.queued_dttm AS task_instance_queued_dttm, task_instance.scheduled_dttm AS task_instance_scheduled_dttm, task_instance.queued_by_job_id AS task_instance_queued_by_job_id, task_instance.last_heartbeat_at AS task_instance_last_heartbeat_at, task_instance.pid AS task_instance_pid, task_instance.executor AS task_instance_executor, task_instance.executor_config AS task_instance_executor_config, task_instance.updated_at AS task_instance_updated_at, task_instance.context_carrier AS task_instance_context_carrier, task_instance.span_status AS task_instance_span_status, task_instance.external_executor_id AS task_instance_external_executor_id, task_instance.trigger_id AS task_instance_trigger_id, task_instance.trigger_timeout AS task_instance_trigger_timeout, task_instance.next_method AS task_instance_next_method, task_
instance.next_kwargs AS task_instance_next_kwargs, task_instance.dag_version_id AS task_instance_dag_version_id, dag_run_1.state AS dag_run_1_state, dag_run_1.id AS dag_run_1_id, dag_run_1.dag_id AS dag_run_1_dag_id, dag_run_1.queued_at AS dag_run_1_queued_at, dag_run_1.logical_date AS dag_run_1_logical_date, dag_run_1.start_date AS dag_run_1_start_date, dag_run_1.end_date AS dag_run_1_end_date, dag_run_1.run_id AS dag_run_1_run_id, dag_run_1.creating_job_id AS dag_run_1_creating_job_id, dag_run_1.run_type AS dag_run_1_run_type, dag_run_1.triggered_by AS dag_run_1_triggered_by, dag_run_1.triggering_user_name AS dag_run_1_triggering_user_name, dag_run_1.conf AS dag_run_1_conf, dag_run_1.data_interval_start AS dag_run_1_data_interval_start, dag_run_1.data_interval_end AS dag_run_1_data_interval_end, dag_run_1.run_after AS dag_run_1_run_after, dag_run_1.last_scheduling_decision AS dag_run_1_last_scheduling_decision, dag_run_1.log_template_id AS dag_run_1_log_template_id, dag_run_1.upda
ted_at AS dag_run_1_updated_at, dag_run_1.clear_number AS dag_run_1_clear_number, dag_run_1.backfill_id AS dag_run_1_backfill_id, dag_run_1.bundle_version AS dag_run_1_bundle_version, dag_run_1.scheduled_by_job_id AS dag_run_1_scheduled_by_job_id, dag_run_1.context_carrier AS dag_run_1_context_carrier, dag_run_1.span_status AS dag_run_1_span_status, dag_run_1.created_dag_version_id AS dag_run_1_created_dag_version_id
FROM task_instance INNER JOIN dag_run AS dag_run_1 ON dag_run_1.dag_id = task_instance.dag_id AND dag_run_1.run_id = task_instance.run_id
WHERE %(param_1)s = task_instance.dag_id AND %(param_2)s = task_instance.run_id
[2025-10-28T11:24:03.334290Z] {base.py:1577} INFO - [cached since 13.18s ago] {'param_1': 'dag_101', 'param_2': 'scheduled__2025-01-01T00:00:00+00:00'}
[2025-10-28T11:24:03.337545Z] {base.py:1577} INFO - SELECT dag_run_note.user_id AS dag_run_note_user_id, dag_run_note.dag_run_id AS dag_run_note_dag_run_id, dag_run_note.content AS dag_run_note_content, dag_run_note.created_at AS dag_run_note_created_at, dag_run_note.updated_at AS dag_run_note_updated_at
FROM dag_run_note
WHERE dag_run_note.dag_run_id = %(pk_1)s
[2025-10-28T11:24:03.413314Z] {base.py:1577} INFO - [cached since 12.74s ago] {'name_1': 'dags-folder-1'}
[2025-10-28T11:24:03.414408Z] {base.py:2630} INFO - COMMIT
[2025-10-28T11:24:03.415589Z] {base.py:2624} INFO - BEGIN (implicit)
[2025-10-28T11:24:03.415903Z] {base.py:1577} INFO - SELECT dag_bundle.name, dag_bundle.active, dag_bundle.version, dag_bundle.last_refreshed, dag_bundle.signed_url_template, dag_bundle.template_params
FROM dag_bundle
WHERE dag_bundle.name = %(name_1)s
[2025-10-28T11:24:03.416012Z] {base.py:1577} INFO - [cached since 12.74s ago] {'name_1': 'dags-folder-1'}
[2025-10-28T11:24:03.417021Z] {base.py:2630} INFO - COMMIT
[2025-10-28T11:24:03.418249Z] {base.py:2624} INFO - BEGIN (implicit)
[2025-10-28T11:24:03.418574Z] {base.py:1577} INFO - SELECT dag_bundle.name, dag_bundle.active, dag_bundle.version, dag_bundle.last_refreshed, dag_bundle.signed_url_template, dag_bundle.template_params
FROM dag_bundle
WHERE dag_bundle.name = %(name_1)s
[2025-10-28T11:24:03.418695Z] {base.py:1577} INFO - [cached since 12.74s ago] {'name_1': 'dags-folder-1'}
[2025-10-28T11:24:03.419683Z] {base.py:2630} INFO - COMMIT
[2025-10-28T11:24:03.421075Z] {base.py:2624} INFO - BEGIN (implicit)
[2025-10-28T11:24:03.421401Z] {base.py:1577} INFO - SELECT dag_bundle.name, dag_bundle.active, dag_bundle.version, dag_bundle.last_refreshed, dag_bundle.signed_url_template, dag_bundle.template_params
FROM dag_bundle
WHERE dag_bundle.name = %(name_1)s
```
patch to not load related fields not used triggering n+1 queries
```diff
diff --git a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py
index 4653a4bb0c..6c0f909ca8 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py
@@ -22,6 +22,7 @@ from typing import Annotated
from fastapi import Depends, status
from sqlalchemy import and_, func, select
+from sqlalchemy.orm import noload
from airflow.api_fastapi.auth.managers.models.resource_details import DagAccessEntity
from airflow.api_fastapi.common.db.common import (
@@ -199,13 +200,19 @@ def get_dags(
DagRun.id,
)
.order_by(recent_runs_subquery.c.run_after.desc())
+ .options(
+ noload(DagRun.task_instances),
+ noload(DagRun.task_instances_histories),
+ noload(DagRun.dag_run_note),
+ noload(DagRun.deadlines),
+ )
)
recent_dag_runs = session.execute(recent_dag_runs_select)
# Fetch pending HITL actions for each Dag if we are not certain whether some of the Dag might contain HITL actions
pending_actions_by_dag_id: dict[str, list[HITLDetail]] = {dag.dag_id: [] for dag in dags}
- if has_pending_actions.value is not False:
+ if has_pending_actions.value:
pending_actions_select = (
select(
TaskInstance.dag_id,
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3457222598
I'm updating API test to catch those early, by adding `assert_queries_count` to entities listing endpoint. That should help catch such similar problem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3451573585
It is possible to deploy the `execution_api` and `public/ui` api separately. This will completely remove the issue you have with UI potentially blocking the api server.
`It does not seem right to set number of workers to 1 for api-server`
This was due to uvicorn not sharing memory between worker, so basically scaling by increasing the number of workers was causing poor resource efficiency. The recommended way now I believe is to scale horizontally by increasing the number of api server pods.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "r-richmond (via GitHub)" <gi...@apache.org>.
r-richmond commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3540222306
> It is possible to deploy the execution_api and public/ui api separately. This will completely remove the issue you have with UI potentially blocking the api server.
@pierrejeambrun Can you expand on this? i.e. Is it something that is possible to configure today or is it just something that is conceptually possible?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3425720225
@trau-sca Can you include the full URLs that are particularly slow please?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3436133092
> While a slow response is certainly problematic is there a known reason for all responses to be blocked by a single slow response?
No, there most endpoints are 'sync' but fastAPI run them in a threadpool to not block the server, so even if 1 request is slow it shouldn't block other responses.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3446377576
> No, there most endpoints are 'sync' but fastAPI run them in a threadpool to not block the server, so even if 1 request is slow it shouldn't block other responses.
Unless **all** threads are blocked. I think it really depends what size of the Thread Pool is and whether it is dynamically growing with the traffic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3548137601
> Also, I'm a bit confused by the terminology, would core be the 'Web'/UI part?
Yes, the `core` means the RESTful API and UI part.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3427278227
Huh, yeah that shouldn't matter at all. What about manually pinging `/api/v2/dags`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "trau-sca (via GitHub)" <gi...@apache.org>.
trau-sca commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3429435396
@bbovenzi Using `api/v2/dags`, it returns the results immediately.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3480585969
All public 'list' endpoints are done. (beside pools which requires more effort, but that's usually not a bottleneck at the moment).
I plan do to the same for the UI API as a follow up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "Giuzzilla (via GitHub)" <gi...@apache.org>.
Giuzzilla commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3547084383
> > `airflow api-server` has an `--apps` option (or similar can't recall from the top of my head), those are `all` `execution_api` `core` etc... that will allow you to chose what you want to run. So you can have the core apis runing on a server and the execution api running on another server.
>
> Yes, we are able to scale the Core API and Execution API independently with `--apps` flag:
>
> https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/web-stack.html#separating-api-servers
Are there meaningful performance gains compared to simply using the default `--apps` (all) on two API servers and:
- `execution_api_server_url` pointed to the api reserved for execution
- Web/HTTP(s) server pointed to the api reserved for web access?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3452310688
Adding below in airflow.cfg also logs all the sqlalchemy queries which could also help in tracking the queries.
```ini
[sqlalchemy]
sql_alchemy_engine_args = {"echo": true}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3448439417
Those are important points @pierrejeambrun @ashb -> I think the interaction - and "noisy neighbouring" between the frontend and workers using the `api-server` is really problematic.
It does not seem right to set number of workers to 1 for api-server, it likely means that likely `async-to-sync` we have at places is really impacting the overall stability of the api-servers.
I guess - possibly - we should indeed separate api-servers used for UI and for regular workloads, unless we figure out how to prevent blocking issues from the UI.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "trau-sca (via GitHub)" <gi...@apache.org>.
trau-sca commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3427248204
@bbovenzi We have 565 rows in our dag_run table
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3456603409
Thanks @tirkarthi for the investigation, that sounds about right to me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3543289497
> `airflow api-server` has an `--apps` option (or similar can't recall from the top of my head), those are `all` `execution_api` `core` etc... that will allow you to chose what you want to run. So you can have the core apis runing on a server and the execution api running on another server.
Yes, we are able to scale the Core API and Execution API independently:
https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/web-stack.html#separating-api-servers
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "trau-sca (via GitHub)" <gi...@apache.org>.
trau-sca commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3427124945
@ashb, Sure, I used the following url in my curl command within the dag-processor pod: `10.244.4.234:8080/ui/dags?dag_runs_limit=14&limit=50&offset=0&exclude_stale=true&order_by=-dag_display_name`. This was the endpoint assigned to the api-server
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3452219396
+1 since we are also facing slower page loads in dags list and dashboard page taking 3-8 seconds. One thing we found is that the card view (7-8s) is more slower than the table view (2-3s) potentially due to loading recent queries per dag.
MySQL and Postgres have options to enable slow query logging with more debugging information that will be helpful to track the long running queries.
https://www.postgresql.org/docs/current/auto-explain.html
https://dev.mysql.com/doc/refman/8.4/en/slow-query-log.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3453803970
> This was due to uvicorn not sharing memory between worker, so basically scaling by increasing the number of workers was causing poor resource efficiency. The recommended way now I believe is to scale horizontally by increasing the number of api server pods.
Yeah. Re-read https://fastapi.tiangolo.com/deployment/docker/#one-process-per-container. - makes sense.
> Yes I think fastapi thread limit is somethwhere around 50, so if can be overloaded quite fast if we have a lot of sync stuff to run. And I guess yes having more workers could help, but on the other hands we have the shared memory problem to solve.
I think I agree with Tiangolo on one-process per container in this case - it is much better to manage with K8S without having multiple processes.
I think the problem with sync operations running in threads for webserver might happen when they do "actual" work - i.e. cpu-heavy. Which is what blocks GIL - and no matter how many threads you have, they will not run in parallel. Effectively, when we have a long-runinng, CPU-heavy sync operation it basically means "one such request per container (when you have single preocess per container)". Maybe we should look for those?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3541846840
`airflow api-server` has an `--aps` option, that is `all` `execution_api` `core` etc... that will allow you to chose what you want to run. So you can have the core apis runing on a server and the execution api running on another server.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3557137156
UI API has also been done in https://github.com/apache/airflow/issues/57561 and we should see improvement in 3.1.3.
Closing for now, we can still have some slowness related to indexes but that would be another problem and we are also working on that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun closed issue #56635: Slow API server website load times
URL: https://github.com/apache/airflow/issues/56635
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "r-richmond (via GitHub)" <gi...@apache.org>.
r-richmond commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3447976698
If it helps we have mitigated this issue somewhat. Steps we took in what we think are the rough order of importance
1. Reduced the number of workers per api-server to 1
* Opened #57273 to improve the docs here
* When this setting was not 1 it was trivial to tip over api-server pods. With it back at 1 it is no longer abysmal but still not good
1. Significantly increased the number of api-server replicas (3x our original values)
* We still see pods getting locked up and subsequently reaped due to liveness probe failures but now we have enough pods that we generally don't get unlucky enough where they are all down at the same time
1. Implemented pg-bouncer
1. disabled sql alchemy pooling
1. reduced the automatic refresh frequency from 3 seconds to 60 seconds
1. increased pg-bouncer replicas to 2
1. Created a daily dag to delete all dag runs that are not in the 30 most recent for any given dag.
* ~17k dag runs in metadb to ~3k now
Misc things we found along the way
1. As mentioned by @trau-sca simply lightly using the fronted can lock up the api-server pods causing them to fail the liveness probe leading to pod restarts and all running tasks getting marked as failed with a state mismatch error
2. The docs around api_worker recommendations were not strong enough.
Misc Thoughts
1. Having the api-server handle both the fronted & the backend/rest api has resulted in AF3 being more brittle than before. As now if there is a bug in the frontend that locks up the api-server pods it can lead to outages that cause the workers to disconnect / fail their tasks.
2. It would be nice if there was a way to disconnect the two. For now I think just a way to segregate some number of api-server replicas as for the backend (~workers/triggerer/processor) only would suffice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "r-richmond (via GitHub)" <gi...@apache.org>.
r-richmond commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3433476955
We are also experience this issue complete with the api server restarting due to failed liveliness probes which kills running jobs.
While a slow response is certainly problematic is there a known reason for all responses to be blocked by a single slow response?
Also if there are any additional stats or information that would be helpful to debug this further please let me know.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Slow API server website load times [airflow]
Posted by "vikramkoka (via GitHub)" <gi...@apache.org>.
vikramkoka commented on issue #56635:
URL: https://github.com/apache/airflow/issues/56635#issuecomment-3423458899
@bbovenzi and @pierrejeambrun Wanted to put this on your radar
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org