mmd-osm / Overpass-API

Performance optimized Overpass API fork
GNU Affero General Public License v3.0
19 stars 3 forks source link
openstreetmap overpass-api performance

Experimental Overpass API fork

:wave: Welcome!

NEWS

Read more about the 2022 planet import challenge:

Overview

:tada: New features

:bug: Bugfixes

:boom: Incompatible database format changes

Three conversion tools are available for easy conversion from the official database file format to the custom one.

All conversion tools need to be executed without an active dispatcher instance.

A full attic database using lz4 compression for bin+map needs about 400G on 0.7.59 (mmd), based on 01/2023 data.

:hourglass: Performance

(List does not include some rather technical changes)

Example syntax for changeset 46503970: (syntax is subject to change)

[adiff:"2017-03-01T20:28:34Z","2017-03-01T20:28:42Z"];
(node(changed!46503970);way(bn);way(changed!46503970);relation(changed!46503970););out meta geom qt;

:x: Removed features

:recycle: Cleanup

:zap: Performance metrics

Performance test results

Test setup:

Results:

Query runtime:

mean           0.054 s
min            0.000 s
max          205.513 s
quantile     runtime (in s)
---------------------------
10%            0.002
50%            0.007
90%            0.042
95%            0.111
99%            0.601
99.5%          1.065
99.9%          5.829
99.95%        12.425
99.99%        30.380
99.995%       56.768
99.999%      120.544
99.9999%     148.805

(-> 99.5% of all queries take less than 1 second)

Used supervisord config settings

environment=
    OVERPASS_FCGI_MAX_REQUESTS=10000,
    OVERPASS_FCGI_MAX_ELAPSED_TIME=900,
    OVERPASS_REGEXP_ENGINE="PCREJIT",
    OVERPASS_DEFAULT_TIMEOUT=60,
    OVERPASS_MAX_TIMEOUT=120,
    OVERPASS_MAX_SPACE_LIMIT=8589934592,
    OSMIUM_POOL_THREADS=1,
    OVERPASS_LOG_LEVEL=2

Installation

Base image: Ubuntu 20.04

Clone source code

git clone https://github.com/mmd-osm/Overpass-API.git
cd Overpass-API
git checkout test7591
git submodule update --init

Install dependencies

sudo apt-get update -qq || true
sudo apt-get install -y g++ git make autoconf automake ca-certificates libtool \
       libfcgi-dev libxml2-dev zlib1g-dev \
       expat libexpat1-dev liblz4-dev libbz2-dev libicu-dev \
       libfmt-dev libpcre2-dev libcereal-dev libgoogle-perftools-dev \
      --no-install-recommends

Compiling and installing binaries

C++17 compiler support is mandatory to build binaries.

pushd src/
chmod u+x test-bin/*.sh
autoscan
aclocal
autoheader
libtoolize
automake --add-missing
autoconf
popd
mkdir -p build
cd build
../src/configure CXXFLAGS="-Werror=implicit-function-declaration  -D_FORTIFY_SOURCE=2 -fexceptions -fpie -Wl,-pie -fpic -shared -fstack-protector-strong -Wl,--no-as-needed -pipe -Wl,-z,defs -Wl,-z,now -Wl,-z,relro -fno-omit-frame-pointer -flto -fwhole-program -march=native -O2 -ftree-vectorize -g3 -ggdb" LDFLAGS="-ltcmalloc -flto -fwhole-program -lpcre2-8 -lfmt" --prefix=$EXEC_DIR --enable-lz4 --enable-fastcgi --enable-tests
make V=0 -j3
make install

(also see docker/ directory for examples)

supervisord config

/etc/supervisor/conf.d/overpass.conf

[fcgi-program:interpreter]
socket=unix:///var/run/interpreter.socket
socket_owner=www-data
socket_mode=0660
environment=
    OVERPASS_FCGI_MAX_REQUESTS=10000,
    OVERPASS_FCGI_MAX_ELAPSED_TIME=900,
    OVERPASS_REGEXP_ENGINE="PCREJIT"
command=/home/user/osm3s/fcgi-bin/interpreter
numprocs=6
priority=999
process_name=%(program_name)s_%(process_num)02d
user=www-data
autorestart=true
autostart=true
startsecs=1
startretries=3
stopsignal=QUIT
stopwaitsecs=10
redirect_stderr=true
stdout_logfile=/var/log/interpreter.log
stdout_logfile_maxbytes=10MB

Apache config

Forwarding calls to /api/interpreter to local socket managed by supervisord. Requires mod_proxy_fcgi.

   ProxyPass /api/interpreter unix:///var/run/interpreter.socket|fcgi://localhost/api/interpreter

Replacing /api/map shell script: use Apache rewrite engine to use /api/interpreter endpoint instead:

   <LocationMatch "^/api/map$">
      RewriteEngine On
      RewriteCond %{QUERY_STRING} ^bbox=([\-0-9\.]+),([\-0-9\.]+),([\-0-9\.]+),([\-0-9\.]+)$
      RewriteRule ".*" "/api/interpreter?data=[timeout:300][maxsize:2000000000][bbox:%2,%1,%4,%3];(node(%2,%1,%4,%3);way(bn);node(w););(._;(rel(bn)->.a;rel(bw)->.a;);rel(br););out meta;" [PT]
   </LocationMatch>

   <LocationMatch "^/api/map\.pbf$">
      RewriteEngine On
      RewriteCond %{QUERY_STRING} ^bbox=([\-0-9\.]+),([\-0-9\.]+),([\-0-9\.]+),([\-0-9\.]+)$
      RewriteRule ".*" "/api/interpreter?data=[out:pbf][timeout:300][maxsize:2000000000][bbox:%2,%1,%4,%3];(node(%2,%1,%4,%3);way(bn);node(w););(._;(rel(bn)->.a;rel(bw)->.a;);rel(br););out meta;" [PT]
   </LocationMatch>