This commit is contained in:
Zsolt Ero
2023-12-15 03:47:46 +01:00
parent 578f81d320
commit 71d7d7fe95
16 changed files with 135 additions and 40 deletions

View File

@@ -1 +1,4 @@
# openfreemap # openfreemap
# TODO
not deleted dedupl files

View File

@@ -0,0 +1,4 @@
* soft nofile 1048576
* hard nofile 1048576
root soft nofile 1048576
root hard nofile 1048576

View File

@@ -59,10 +59,6 @@ http {
'"http_referrer": "$http_referer", ' '"http_referrer": "$http_referer", '
'"http_x_forwarded_for": "$http_x_forwarded_for", ' '"http_x_forwarded_for": "$http_x_forwarded_for", '
'"http_user_agent": "$http_user_agent", ' '"http_user_agent": "$http_user_agent", '
'"upstream_response_time": "$upstream_response_time", '
# '"upstream_connect_time": "$upstream_connect_time", '
'"upstream_header_time": "$upstream_header_time", '
'"upstream_cache_status": "$upstream_cache_status", '
'"host": "$host", ' '"host": "$host", '
'"uri": "$uri", ' '"uri": "$uri", '
'"http_cf_connecting_ip": "$http_cf_connecting_ip", ' '"http_cf_connecting_ip": "$http_cf_connecting_ip", '

View File

@@ -1,4 +1,4 @@
vm.swappiness = 1 vm.swappiness = 1
net.core.somaxconn = 65535 net.core.somaxconn = 65535
fs.file-max = 100000

View File

@@ -1 +0,0 @@
specify UID when creating user

View File

@@ -5,9 +5,10 @@ import click
from dotenv import dotenv_values from dotenv import dotenv_values
from fabric import Config, Connection from fabric import Config, Connection
from ssh_lib.config import scripts from ssh_lib.benchmark import benchmark, c1000k, k6
from ssh_lib.config import config, scripts
from ssh_lib.kernel import set_cpu_governor, setup_kernel_settings from ssh_lib.kernel import set_cpu_governor, setup_kernel_settings
from ssh_lib.nginx import certbot, k6, nginx from ssh_lib.nginx import certbot, nginx
from ssh_lib.pkg_base import pkg_base, pkg_clean, pkg_upgrade from ssh_lib.pkg_base import pkg_base, pkg_clean, pkg_upgrade
from ssh_lib.planetiler import TILE_GEN_BIN, install_planetiler from ssh_lib.planetiler import TILE_GEN_BIN, install_planetiler
from ssh_lib.utils import add_user, enable_sudo, put, reboot, setup_time, sudo_cmd from ssh_lib.utils import add_user, enable_sudo, put, reboot, setup_time, sudo_cmd
@@ -52,7 +53,18 @@ def prepare_tile_gen(c):
def prepare_http_host(c): def prepare_http_host(c):
nginx(c) nginx(c)
certbot(c) certbot(c)
k6(c) c1000k(c)
def debug_tmp(c):
c.sudo('rm -rf /data/ofm/logs')
c.sudo('mkdir -p /data/ofm/logs')
put(c, f'{config}/nginx/nginx.conf', '/etc/nginx/')
put(c, f'{scripts}/http_host/nginx_site.conf', '/data/nginx/sites')
c.sudo('nginx -t')
c.sudo('service nginx restart')
benchmark(c)
@click.command() @click.command()
@@ -110,9 +122,5 @@ def main(hostname, user, port, tile_gen, http_host, skip_shared, do_reboot, debu
reboot(c) reboot(c)
def debug_tmp(c):
k6(c)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@@ -3,8 +3,19 @@ tcp_fin_timeout
tcp_max_syn_backlog tcp_max_syn_backlog
TCP max buffer size TCP max buffer size
Increase File Descriptors Limit
Disable Swapping Disable Swapping
fs.file-max # not needed, recent Ubuntu has it on high by default
net.core.netdev_max_backlog = 262144
net.core.rmem_max = 16777216
net.core.somaxconn = 262144
net.core.wmem_max = 16777216
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_max_tw_buckets = 6000000
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_wmem = 4096 65536 16777216

View File

@@ -0,0 +1,29 @@
local counter = 1
local lines = {}
local base_path = "/planet/20231208_091355/tiles/"
local file_path = "/data/ofm/benchmark/path_list_small.txt"
for line in io.lines(file_path) do
table.insert(lines, base_path .. line)
end
local function getNextUrl()
-- Get the next URL from the list
local url_path = lines[counter]
counter = counter + 1
-- If we've gone past the end of the list, wrap around to the start
if counter > #lines then
counter = 1
end
return url_path
end
request = function()
-- Return the request object with the current URL path
local path = getNextUrl()
local headers = {}
headers["Host"] = "ofm"
return wrk.format('GET', path, headers, nil)
end

View File

@@ -0,0 +1,5 @@
mkdir -p mnt_ro
sudo mount -v \
-t btrfs \
-o ro \
image.btrfs mnt_ro

View File

@@ -0,0 +1,17 @@
server {
server_name ofm tiles.openfreemaps.org;
# test with
# curl -H "Host: ofm" http://localhost/planet/20231208_091355/tiles/7/72/48.pbf
#access_log /data/ofm/logs/nginx-access.log access_json;
access_log off;
error_log /data/ofm/logs/nginx-error.log;
location /planet/20231208_091355 {
gzip off;
alias /data/ofm/runs/planet_20231208_091355/mnt_ro/extract;
autoindex on; # Enables listing of directory
}
}

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
sudo umount mnt || true sudo umount mnt_rw || true
rm -rf mnt rm -rf mnt_rw
rm -f image.btrfs rm -f image.btrfs
@@ -16,21 +16,21 @@ mkfs.btrfs -v \
# https://btrfs.readthedocs.io/en/latest/btrfs-man5.html#mount-options # https://btrfs.readthedocs.io/en/latest/btrfs-man5.html#mount-options
# compression doesn't make sense, data is already gzip compressed # compression doesn't make sense, data is already gzip compressed
mkdir -p mnt mkdir -p mnt_rw
sudo mount -v \ sudo mount -v \
-t btrfs \ -t btrfs \
-o noacl,nobarrier,noatime,max_inline=4096 \ -o noacl,nobarrier,noatime,max_inline=4096 \
image.btrfs mnt image.btrfs mnt_rw
sudo chown ofm:ofm -R mnt sudo chown ofm:ofm -R mnt_rw
../../tile_gen/venv/bin/python ../../tile_gen/extract.py output.mbtiles mnt/extract \ ../../tile_gen/venv/bin/python ../../tile_gen/extract.py output.mbtiles mnt_rw/extract \
> "extract_out.log" 2> "extract_err.log" > "extract_out.log" 2> "extract_err.log"
sudo umount mnt sudo umount mnt_rw
../../tile_gen/venv/bin/python ../../tile_gen/shrink_btrfs.py image.btrfs ../../tile_gen/venv/bin/python ../../tile_gen/shrink_btrfs.py image.btrfs
# pigz -k image.btrfs --fast

36
ssh_lib/benchmark.py Normal file
View File

@@ -0,0 +1,36 @@
from ssh_lib.config import scripts
from ssh_lib.utils import apt_get_install, apt_get_update, put, put_str, sudo_cmd
def k6(c):
sudo_cmd(
c,
'curl https://dl.k6.io/key.gpg '
'| gpg --dearmor '
'| tee /usr/share/keyrings/k6-archive-keyring.gpg >/dev/null',
)
put_str(
c,
'/e' 'tc/apt/sources.list.d/k6.list',
'deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main',
)
apt_get_update(c)
apt_get_install(c, 'k6')
def c1000k(c):
c.run('wget https://github.com/ideawu/c1000k/archive/master.zip -O tmp.zip')
c.run('unzip -o tmp.zip')
c.run('rm tmp.zip')
c.run('cd c1000k-master && make')
# usage
# ./server 7000
# ./client 127.0.0.1 7000
# make sure it runs till 1 million
def benchmark(c):
apt_get_install(c, 'wrk')
c.sudo('mkdir -p /data/ofm/benchmark')
put(c, f'{scripts}/benchmark/wrk_custom_list.lua', '/data/ofm/benchmark')

View File

@@ -3,7 +3,8 @@ from ssh_lib.utils import apt_get_install, apt_get_purge, put, put_str
def setup_kernel_settings(c): def setup_kernel_settings(c):
put(c, f'{config}/sysctl/60-optim.conf', '/etc/sysctl.d/') put(c, f'{config}/sysctl/60-ofm.conf', '/etc/sysctl.d/')
put(c, f'{config}/limits/limits-ofm.conf', '/etc/security/limits.d/')
def set_cpu_governor(c): def set_cpu_governor(c):

View File

@@ -64,19 +64,3 @@ def certbot(c):
apt_get_purge(c, 'certbot') apt_get_purge(c, 'certbot')
c.sudo('snap install --classic certbot', warn=True) c.sudo('snap install --classic certbot', warn=True)
def k6(c):
sudo_cmd(
c,
'curl https://dl.k6.io/key.gpg '
'| gpg --dearmor '
'| tee /usr/share/keyrings/k6-archive-keyring.gpg >/dev/null',
)
put_str(
c,
'/etc/apt/sources.list.d/k6.list',
'deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main',
)
apt_get_update(c)
apt_get_install(c, 'k6')

View File

@@ -39,6 +39,8 @@ def pkg_base(c):
'lsb-release', 'lsb-release',
'wget', 'wget',
'git', 'git',
'build-essential',
'unzip',
# #
'gnupg2', 'gnupg2',
'gnupg-agent', 'gnupg-agent',