From e20fc2961c6d4dca7387cd0b5a6dc61a8fef4664 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Sun, 17 Nov 2019 15:16:39 +0000 Subject: [PATCH] Better CPU/IO scheduling for cron on tilecaches --- cookbooks/systemd/resources/service.rb | 3 +++ cookbooks/systemd/templates/default/service.erb | 9 +++++++++ cookbooks/tilecache/recipes/default.rb | 10 ++++++++++ 3 files changed, 22 insertions(+) diff --git a/cookbooks/systemd/resources/service.rb b/cookbooks/systemd/resources/service.rb index 282b36178..4758f7af5 100644 --- a/cookbooks/systemd/resources/service.rb +++ b/cookbooks/systemd/resources/service.rb @@ -62,6 +62,9 @@ property :no_new_privileges, [TrueClass, FalseClass] property :tasks_max, Integer property :timeout_sec, Integer property :pid_file, String +property :nice, Integer +property :io_scheduling_class, [Integer, String] +property :io_scheduling_priority, Integer action :create do service_variables = new_resource.to_hash diff --git a/cookbooks/systemd/templates/default/service.erb b/cookbooks/systemd/templates/default/service.erb index 46b8aa575..188404508 100644 --- a/cookbooks/systemd/templates/default/service.erb +++ b/cookbooks/systemd/templates/default/service.erb @@ -114,6 +114,15 @@ TimeoutSec=<%= @timeout_sec %> <% if @pid_file -%> PIDFile=<%= @pid_file %> <% end -%> +<% if @nice -%> +Nice=<%= @nice %> +<% end -%> +<% if @io_scheduling_class -%> +IOSchedulingClass=<%= @io_scheduling_class %> +<% end -%> +<% if @io_scheduling_priority -%> +IOSchedulingPriority=<%= @io_scheduling_priority %> +<% end -%> <% unless @dropin -%> [Install] diff --git a/cookbooks/tilecache/recipes/default.rb b/cookbooks/tilecache/recipes/default.rb index 1068b1b0d..63de8a529 100644 --- a/cookbooks/tilecache/recipes/default.rb +++ b/cookbooks/tilecache/recipes/default.rb @@ -109,6 +109,16 @@ template "/etc/logrotate.d/squid" do mode 0o644 end +# Configure cron with lower cpu and IO priority +systemd_service "cron-load" do + service "cron" + dropin "load" + nice 19 + io_scheduling_class "best-effort" + io_scheduling_priority 7 + notifies :restart, "service[cron]" +end + nginx_site "default" do action [:delete] end -- 2.43.2