Wow, that's really nice work Vincent! And areally needed improvement as well

Will checkout your PR's for sure and review it where I can.

Also something we discussed with Niko during the COC, but that's more of an 
feature than a performance tuning,
is partitioning of schedulers, that would also be something to think about.

Once again nice to see such performance improvements.
And indeed Dev-iL, it would be great to see the performance impact of async API 
as well once done,
would be nice if those 2 improvements in 3.5!

Kind regards,
David

On 2026-11-24 15:06 UTC Vincent Beck via dev wrote:
> Hey all,
> 
> At Community Over Code in Glasgow, I got inspired by a talk from OpenAI about 
> how they had to modify Airflow to sustain their heavy load. It gave me the 
> idea of improving the Airflow scheduler so it can handle more load, 
> especially with multiple schedulers. Hence this email :)
> 
> When multiple schedulers run in one Airflow environment, the first bottleneck 
> I found is the scheduler's critical section. Only one scheduler at a time 
> moves task instances to QUEUED while the others skip their turn, so the work 
> done under that lock sets how fast tasks start.
> 
> I created six PRs that make that work cheaper:
> 
> - Speed up the scheduler selection query when many tasks are waiting: 
> https://github.com/apache/airflow/pull/77545
> - Build task workloads after releasing the scheduler critical section: 
> https://github.com/apache/airflow/pull/77546
> - Make task heartbeats cheaper by dropping the ti_heartbeat index: 
> https://github.com/apache/airflow/pull/77547
> - Speed up scheduler concurrency counts with many running tasks: 
> https://github.com/apache/airflow/pull/77548
> - Drain executor events without scanning all tracked tasks in Python: 
> https://github.com/apache/airflow/pull/77549
> - Reset orphaned task instances in bulk to shorten scheduler stalls: 
> https://github.com/apache/airflow/pull/77550
> 
> I ran some benchmarks on each individual PR, you can find the results in each 
> PR description. I also ran some benchmarks on all PRs combined and here are 
> the results (I ran them on AWS with 4 schedulers and an RDS PostgreSQL 14 
> database):
> 
> - Starting 70,000 tasks at once: it takes 94 seconds instead of 252 (63% 
> faster), and the database does a quarter of the work.
> - 10,000 tasks with Airflow's default settings: done in 155 seconds instead 
> of 208 (25% faster).
> - One scheduler crashes while it is in charge of about 35,000 tasks: the 
> other scheduler recovers them in 21 seconds instead of 14 minutes, and 
> everything is running again after about 2 minutes instead of 18.
> - With tasks on ECS (2,000 tasks on Fargate): all done in 521 seconds instead 
> of 616 (15% faster), and the database writes 70% less to disk, mostly because 
> task heartbeats no longer update an index.
> 
> To make sure nothing regresses for a "normal" environment, I also ran a 
> normal load (one scheduler, Airflow's default settings, about two thirds of 
> the task slots busy): nothing gets slower and the database load is the same. 
> The slowest task starts get faster (1.4 seconds -> 0.5) and the database 
> writes about a third less to disk.
> 
> As usual, reviews are super welcome, especially if you are familiar with the 
> scheduler area.
> 
> Thanks,
> Vincent
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to