phani8996 closed pull request #3989: [AIRFLOW-1945] Autoscale celery workers
for airflow added
URL: https://github.com/apache/incubator-airflow/pull/3989
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/airflow/bin/cli.py b/airflow/bin/cli.py
index 09bd0c1806..19ff220d9f 100644
--- a/airflow/bin/cli.py
+++ b/airflow/bin/cli.py
@@ -1055,12 +1055,16 @@ def worker(args):
from airflow.executors.celery_executor import app as celery_app
from celery.bin import worker
+ autoscale = args.autoscale
+ if autoscale is None and conf.has_option("celery", "worker_autoscale"):
+ autoscale = conf.get("celery", "worker_autoscale")
worker = worker.worker(app=celery_app)
options = {
'optimization': 'fair',
'O': 'fair',
'queues': args.queues,
'concurrency': args.concurrency,
+ 'autoscale': autoscale,
'hostname': args.celery_hostname,
}
@@ -1932,6 +1936,9 @@ class CLIFactory(object):
('-d', '--delete'),
help='Delete a user',
action='store_true'),
+ 'autoscale': Arg(
+ ('-a', '--autoscale'),
+ help="Minimum and Maximum number of worker to autoscale"),
}
subparsers = (
@@ -2074,7 +2081,7 @@ class CLIFactory(object):
'func': worker,
'help': "Start a Celery worker node",
'args': ('do_pickle', 'queues', 'concurrency', 'celery_hostname',
- 'pid', 'daemon', 'stdout', 'stderr', 'log_file'),
+ 'pid', 'daemon', 'stdout', 'stderr', 'log_file',
'autoscale'),
}, {
'func': flower,
'help': "Start a Celery Flower",
diff --git a/airflow/config_templates/default_airflow.cfg
b/airflow/config_templates/default_airflow.cfg
index bb4ab208d7..a1806a5dee 100644
--- a/airflow/config_templates/default_airflow.cfg
+++ b/airflow/config_templates/default_airflow.cfg
@@ -349,6 +349,13 @@ celery_app_name = airflow.executors.celery_executor
# your worker box and the nature of your tasks
worker_concurrency = 16
+# The minimum and maximum concurrency that will be used when starting workers
with the
+# "airflow worker" command. Pick these numbers based on resources on
+# worker box and the nature of the task. If autoscale option is available
worker_concurrency
+# will be ignored.
+#
http://docs.celeryproject.org/en/latest/reference/celery.bin.worker.html#cmdoption-celery-worker-autoscale
+# worker_autoscale = 12,16
+
# When you start an airflow worker, airflow starts a tiny web server
# subprocess to serve the workers local log files to the airflow main
# web server, who then builds pages and sends them to users. This defines
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services