From b88e04237dcfbf1d7c4b7aa6023465f8e4a34f44 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 14 Dec 2023 17:43:25 +0000 Subject: [PATCH 1/1] Limit the number of threads used for low zoom renders --- cookbooks/tile/recipes/default.rb | 5 ++++- cookbooks/tile/templates/default/render-lowzoom.erb | 2 +- cookbooks/tile/templates/default/update-lowzoom.erb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cookbooks/tile/recipes/default.rb b/cookbooks/tile/recipes/default.rb index 40486dac6..4ceba4a18 100644 --- a/cookbooks/tile/recipes/default.rb +++ b/cookbooks/tile/recipes/default.rb @@ -282,6 +282,8 @@ end nodejs_package "carto" +lowzoom_threads = [node.cpu_cores - 1, node[:memory][:total].to_f / 4194304].min.floor + systemd_service "update-lowzoom@" do description "Low zoom tile update service for %i layer" user "tile" @@ -312,7 +314,7 @@ node[:tile][:styles].each do |name, details| owner "root" group "root" mode "755" - variables :style => name + variables :style => name, :threads => lowzoom_threads end service "update-lowzoom@#{name}" do @@ -606,6 +608,7 @@ template "/usr/local/bin/render-lowzoom" do owner "root" group "root" mode "755" + variables :threads => lowzoom_threads end systemd_service "render-lowzoom" do diff --git a/cookbooks/tile/templates/default/render-lowzoom.erb b/cookbooks/tile/templates/default/render-lowzoom.erb index 834eecc30..eb3e2e84e 100644 --- a/cookbooks/tile/templates/default/render-lowzoom.erb +++ b/cookbooks/tile/templates/default/render-lowzoom.erb @@ -16,7 +16,7 @@ function update_<%= style %> --timestamp=${timestamp} \ --tile-dir=/srv/tile.openstreetmap.org/tiles \ --socket=/var/run/renderd/renderd.sock \ - --num-threads=<%= node.cpu_cores - 1 %> \ + --num-threads=<%= @threads %> \ --map="<%= style %>" \ --max-load=<%= node.cpu_cores - 1 %> \ --min-zoom=0 --max-zoom=12 diff --git a/cookbooks/tile/templates/default/update-lowzoom.erb b/cookbooks/tile/templates/default/update-lowzoom.erb index 81e138076..0455493d9 100644 --- a/cookbooks/tile/templates/default/update-lowzoom.erb +++ b/cookbooks/tile/templates/default/update-lowzoom.erb @@ -12,7 +12,7 @@ function update_tiles --timestamp=$(stat -c %Y "/srv/tile.openstreetmap.org/styles/<%= @style %>/project.xml") \ --tile-dir=/srv/tile.openstreetmap.org/tiles \ --socket=/var/run/renderd/renderd.sock \ - --num-threads=<%= node.cpu_cores - 1 %> \ + --num-threads=<%= @threads %> \ --map="<%= @style %>" \ --max-load=<%= node.cpu_cores - 1 %> \ --min-zoom=0 --max-zoom=12 -- 2.39.5