One of the projects I worked on when I was on the maps team at MapQuest was Avecado, a library for building Mapnik vector tiles, along with language bindings for Python and some utility programs. For the upcoming OpenStreetMap Carto hstore work I needed to benchmark database performance for rendering, without the overhead of generating the images. I had a number of requirements for parallelism and connection reuse to accurately simulate a real workload, and realized that avecado_server
could meet my needs.
Avecado isn’t the easiest program to build, requiring very recent versions of Mapnik and Boost that are not packaged in most OS distributions. The precise versions needed are frequently changing, so as with any guide, be sure to read the documentation for any changes.
Since I was going to be benchmarking, I immediately turned to a server I use only for that. VMs are handy, but their performance is subject to too much variation, making them unsuited for the type of benchmarking I was going to be doing.
The overall plan for getting Avecado installed is to prepare the server, install pre-requisites, compile Boost, compile Mapnik, and finally compile Avecado.
This article assumes familiarity with Linux and compiling software.
Preparing the server
The first step is always to update the software on the server, which was running Ubuntu 14.04.
1 2 |
|
Installing pre-requisites
There’s a fair number of pre-requisites for a full Mapnik install with support for all the plugins and formats, but I just needed a minimal set that would let me do a basic build. Mapnik and Avecado have many dependencies in common.
1 2 3 4 5 |
|
Because the versions of Boost and Mapnik needed are not packaged, they need to be built from source alongside Avecado.
1 2 3 4 5 6 |
|
Building boost
Boost can take a long time to compile if you build everything, but fortunately we only need some of the libraries and can speed up the build by specifying them.
1 2 3 4 5 6 7 8 |
|
If you want to install all of boost, --with-libraries
can be omitted.
Building Mapnik
Mapnik makes heavy use of C++ templates and takes a lot of RAM and a long time to compile, sometimes an hour on slower machines.
Mapnik releases are very infrequent, with the last release almost two years ago, so a development version needs to be used, and specified by the git commit hash. This specific version is likely to change in the future, so be sure to check the documentation.
1 2 3 4 5 6 7 8 |
|
Building Avecado
We can now build Avecado, configuring it to use the previously installed Boost and Mapnik. It comes with a test-suite which can also be used to check everything works.
1 2 3 4 5 6 7 8 9 |
|
With the way Boost and Mapnik were installed, it’s necessary to specify LD_LIBRARY_PATH
when running any of the Avecado command-line utilities.
The avecado
utility can be run with LD_LIBRARY_PATH="$HOME/boost/lib:$HOME/mapnik/lib" ~/avecado/bin/avecado
. This utility will allow rendering vector tiles, raster tiles, or bulk rendering vector tiles.
avecado_server
is more useful for testing, and servers vector tiles over HTTP. It doesn’t do any caching, so even for previews it should be put behind a caching proxy like Varnish or Apache’s mod_cache. It can be run with LD_LIBRARY_PATH="$HOME/boost/lib:$HOME/mapnik/lib" ~/avecado/bin/avecado_server
.
Next steps
The next step for my benchmarking is to load a database, point avecado_server
at a suitable stylesheet and fetch vector tiles in parallel.