Skip to content

Scheduler is spending most of its time in clear_not_launched_queued_tasks function #34877

Closed

Description

@dirrao

Apache Airflow version

2.7.1

What happened

Airflow running the clear_not_launched_queued_tasks function on a certain frequency (default 30 seconds). When we run the airflow on a large Kube cluster (pods more than > 5K). Internally the clear_not_launched_queued_tasks function loops through each queued task and checks the corresponding worker pod existence in the Kube cluster. Right this existence check using list pods Kube API. The API is taking more than 1s. if there are 120 queued tasks, then it will take ~ 120 seconds (1s * 120). So, this leads the scheduler to spend most of its time in this function rather than scheduling the tasks. It leads to none of the jobs being scheduled or degraded scheduler performance.

What you think should happen instead

It would be nice to get all the airflow worker pods in a one/few batch calls rather than for each task. These batch calls helps to speed the processing of clear_not_launched_queued_tasks function call.

How to reproduce

Run the airflow on large Kube clusters (> 5K pods). Simulate the airflow to run the 100 parallel DAG runs for every minute.

Operating System

Cent OS 7

Versions of Apache Airflow Providers

2.3.3, 2.7.1

Deployment

Other Docker-based deployment

Deployment details

Terraform based airflow deployment

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. dirrao commented on Oct 13, 2023

    @dirrao
    ContributorAuthor

    @ROVAN1220
    Thanks for the inputs.

    I am working on the MR to address the performance issue.

  2. mattp- commented on Oct 13, 2023

    @mattp-
    Contributor

    @dirrao I think that may be a chatgpt AI comment lol

  3. eladkal commented on Oct 15, 2023

    @eladkal
    Contributor

    So, this leads the scheduler to spend most of its time in this function rather than scheduling the tasks

    This is interesting.
    I believe this is the K8s equivalent for #8854 ?
    cc @jedcunningham @ephraimbuddy

  4. dirrao commented on Oct 16, 2023

    @dirrao
    ContributorAuthor

    @eladkal They are related. Its more close to #7542

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions