potiuk commented on a change in pull request #18356:
URL: https://github.com/apache/airflow/pull/18356#discussion_r712050719



##########
File path: docs/apache-airflow/concepts/scheduler.rst
##########
@@ -138,12 +141,101 @@ The following databases are fully supported and provide 
an "optimal" experience:
 
   Microsoft SQLServer has not been tested with HA.
 
+
+Fine-tuning your Scheduler
+--------------------------
+
+When you deploy Airflow in production you often would like to optimize its 
performance and
+fine-tune Scheduler behaviour. Firs of all you need to remember that Scheduler 
performs two
+operations:
+
+* continuously parses DAG files and updates their starts in ``Serialized DAG`` 
form in the database
+* continuously finds and schedules for execution the next tasks to run and 
sends those tasks for
+  execution to the executor you have configured
+
+Those two tasks are executed in parallel by scheduler, they are fairly 
independent from each other and
+they are run using different processes. You can fine tune the behaviour of 
both components, however
+in order to fine-tune your scheduler, you need to included a number of factors:
+
+* The kind of deployment you have
+    * what kind of filesystem you have to share the DAGS
+    * how fast the filesystem is (in many cases of distributed cloud 
filesystem you can pay extra to get
+      more throughput/faster filesystem
+    * how much memory you have for your processing
+    * how much CPU you have available
+    * how much networking throughput you have available
+
+* The logic and definition of your DAG structure:
+    * how many DAG files you have
+    * how many DAGs you have in your files
+    * how large the DAG files are (remember scheduler needs to read and parse 
the file every n seconds)
+    * how complex they are
+    * whether parsing your DAGs involves heavy processing (Hint! It should 
not. See:doc:`/best-practices`)
+
+* The scheduler configuration
+   * How many schedulers you have
+   * How many parsing processes you have in your scheduler
+   * How much time scheduler waits between re-parsing of the same DAG (it 
happens continuously)
+   * How many task instances scheduler processes in one loop
+   * How many new dag runs should be created/scheduled per loop
+   * Whether to execute "mini-scheduler" after completed task to speed up 
scheduling dependent tasks
+   * How often the scheduler should perform cleanup and check for orphaned 
tasks/adopting them
+   * Whether scheduler uses row-level locking
+
+
+Airflow gives you a lot of "knobs" to turn to fine tune the performance but 
it's a separate task,
+depending on your particular deployment, your DAG structure, hardware 
availability and expectations,
+to decide which knobs to turn to get best effect for you. Part of the job when 
managing the
+deployment is to decide what you are going to optimize for. Some users are ok 
with
+30 seconds delays of new DAG parsing, at the expense of lower CPU usage, where 
some other users
+expect the DAGs to be parsed almost instantly when they appear in the DAGs 
folder at the
+expense of higher CPU usage for example.
+
+Airflow gives you the flexibility to decide, but you should find out what 
aspect of performance is
+most important for you and decide which knobs you want to turn in which 
direction.
+
+Generally for fine-tuning, your approach should be the same as for any 
performance improvement and
+optimizations (we will not recommend any specific tools - just use the tools 
that you usually use
+to observe and monitor your systems):
+
+* decide which aspect of performance is most important for you (what you want 
to improve)
+* observe your system to see where your bottlenecks are: CPU, memory, I/O are 
the usual limiting factors
+* based on your expectations and observations - decide what is your next 
improvement and go back to
+  the observation of your performance, bottlenecks. Performance improvement is 
an iterative process
+
+The improvements that you can consider are:
+
+* improve utilization of your resources. This is when you have a free capacity 
in your system that
+  seems underutilized (again CPU, memory I/O, networking are the prime 
candidates) - you can take
+  actions like increasing number of schedulers, parsing processes or 
decreasing intervals for more
+  frequent actions might bring improvements in performance at the expense of 
higher utilization of those.
+* increase hardware capacity (for example if you see that CPU is limiting you 
or tha I/O you use for
+  DAG filesystem is at its limits). Often the problem with scheduler 
performance is
+  simply because your system is not "capable" enough and this might be the 
only way. For example if
+  you see that you are using all CPU you have on machine, you might want to 
add another scheduler on
+  a new machine - in most cases, when you add 2nd or 3rd scheduler, the 
capacity of scheduling grows
+  linearly (unless the shared database or filesystem is a bottleneck).
+* experiment with different values for the "scheduler tunables". Often you 
might get better effects by
+  simply exchanging one performance aspect for another. For example if you 
want to decrease the
+  cpu usage, you might increase file processing interval (but the result will 
be that new DAGs will
+  appear with bigger delay). Usually performance tuning is the art of 
balancing different aspects.
+* sometimes you change scheduler behaviour slightly (for example change 
parsing sort order)
+  in order to get better fine-tuned results for your particular deployment.
+
+In order to perform fine-tuning, it's good to understand how Scheduler works 
under-the-hood.
+You can take a look at the ``Airflow Summit 2021``
+`Deep Dive into the Airflow Scheduler talk <https://youtu.be/DYC4-xElccE>`_ to 
perform the fine-tuning.
+
+Here are the most important tunables you can use to impact various performance 
aspects of the Scheduler:
+
 .. _scheduler:ha:tunables:
 
-Scheduler Tuneables
-"""""""""""""""""""
+Scheduler Tunables

Review comment:
       Good for me . The "tunables" word sounds nice but is a bit strange indeed




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to