From 48b925931e2fd9bf99eb899ddce75f35d6b876f7 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 3 Apr 2024 14:59:48 +0000 Subject: [PATCH] django: Skip running config and database checks on process start. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The process of running Django's built-in database and config checks can be very heavy-weight, potentially taking multiple seconds: ``` $ hyperfine './manage.py print_initial_password iago@zulip.com' './manage.py print_initial_password iago@zulip.com --skip-checks' Benchmark 1: ./manage.py print_initial_password iago@zulip.com Time (mean ± σ): 4.943 s ± 0.722 s [User: 4.434 s, System: 0.311 s] Range (min … max): 4.415 s … 6.835 s 10 runs Benchmark 2: ./manage.py print_initial_password iago@zulip.com --skip-checks Time (mean ± σ): 1.786 s ± 0.113 s [User: 1.598 s, System: 0.162 s] Range (min … max): 1.576 s … 1.999 s 10 runs Summary './manage.py print_initial_password iago@zulip.com --skip-checks' ran 2.77 ± 0.44 times faster than './manage.py print_initial_password iago@zulip.com' ``` This extends the window during which nginx is forced to serve 502's to clients. f5f6a3789baf added an explicit `manage.py check` during server restarts, and fa77be6e6c2b added one during upgrades; as such, we expect that any check failures will already have been caught when performing a restart or upgrade, and there is no point in running them on process startup. --- .../templates/supervisor/zulip-once.conf.template.erb | 4 ++-- puppet/zulip/templates/supervisor/zulip.conf.template.erb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/puppet/zulip/templates/supervisor/zulip-once.conf.template.erb b/puppet/zulip/templates/supervisor/zulip-once.conf.template.erb index 9228a7a3ae..f5300c7df0 100644 --- a/puppet/zulip/templates/supervisor/zulip-once.conf.template.erb +++ b/puppet/zulip/templates/supervisor/zulip-once.conf.template.erb @@ -1,5 +1,5 @@ [program:zulip_deliver_scheduled_emails] -command=nice -n15 /home/zulip/deployments/current/manage.py deliver_scheduled_emails +command=nice -n15 /home/zulip/deployments/current/manage.py deliver_scheduled_emails --skip-checks environment=HTTP_proxy="<%= @proxy %>",HTTPS_proxy="<%= @proxy %>" priority=350 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) @@ -14,7 +14,7 @@ stdout_logfile_backups=3 ; # of stdout logfile backups (default 10) directory=/home/zulip/deployments/current/ [program:zulip_deliver_scheduled_messages] -command=nice -n15 /home/zulip/deployments/current/manage.py deliver_scheduled_messages +command=nice -n15 /home/zulip/deployments/current/manage.py deliver_scheduled_messages --skip-checks environment=HTTP_proxy="<%= @proxy %>",HTTPS_proxy="<%= @proxy %>" priority=350 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) diff --git a/puppet/zulip/templates/supervisor/zulip.conf.template.erb b/puppet/zulip/templates/supervisor/zulip.conf.template.erb index d98472b647..bb2b488ff5 100644 --- a/puppet/zulip/templates/supervisor/zulip.conf.template.erb +++ b/puppet/zulip/templates/supervisor/zulip.conf.template.erb @@ -26,7 +26,7 @@ directory=/home/zulip/deployments/current/ <% if @tornado_ports.length > 1 -%> [program:zulip-tornado] -command=/home/zulip/deployments/current/manage.py runtornado 127.0.0.1:98%(process_num)02d +command=/home/zulip/deployments/current/manage.py runtornado 127.0.0.1:98%(process_num)02d --skip-checks process_name=zulip-tornado-port-98%(process_num)02d environment=PYTHONUNBUFFERED=1,HTTP_proxy="<%= @proxy %>",HTTPS_proxy="<%= @proxy %>" priority=200 ; the relative start priority (default 999) @@ -43,7 +43,7 @@ directory=/home/zulip/deployments/current/ numprocs=<%= @tornado_ports.length %> <% else -%> [program:zulip-tornado] -command=/home/zulip/deployments/current/manage.py runtornado 127.0.0.1:9800 +command=/home/zulip/deployments/current/manage.py runtornado 127.0.0.1:9800 --skip-checks environment=PYTHONUNBUFFERED=1,HTTP_proxy="<%= @proxy %>",HTTPS_proxy="<%= @proxy %>" priority=200 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) @@ -61,7 +61,7 @@ directory=/home/zulip/deployments/current/ <% if @queues_multiprocess %> <% @queues.each do |queue| -%> [program:zulip_events_<%= queue %>] -command=nice -n10 /home/zulip/deployments/current/manage.py process_queue --queue_name=<%= queue %> +command=nice -n10 /home/zulip/deployments/current/manage.py process_queue --queue_name=<%= queue %> --skip-checks environment=HTTP_proxy="<%= @proxy %>",HTTPS_proxy="<%= @proxy %>" priority=300 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true) @@ -77,7 +77,7 @@ directory=/home/zulip/deployments/current/ <% end -%> <% else %> [program:zulip_events] -command=nice -n10 /home/zulip/deployments/current/manage.py process_queue --multi_threaded <%= @queues.join(' ') %> +command=nice -n10 /home/zulip/deployments/current/manage.py process_queue --multi_threaded <%= @queues.join(' ') %> --skip-checks environment=HTTP_proxy="<%= @proxy %>",HTTPS_proxy="<%= @proxy %>" priority=300 ; the relative start priority (default 999) autostart=true ; start at supervisord start (default: true)