Tile servers: Mapnik vs Martin

Posted on Nov 19, 2023

Mapnik stands out as an excellent tile server, garnering praise for its capabilities. However, the absence of recent releases has prompted many, including myself, to seek potential substitutes. In my exploration, I experimented with Martin , written in Rust and supported by the awesome MapLibre collective — compelling reasons to give it a try. While more detailed performance analyses exist on the web for both Mapnik and Martin, this brief post provides an overview of the Mapnik vs. Martin comparison based on simple and uncomplicated GET requests.

Specs

Performance was my primary focus. Comparing Martin (Rust) to Mapnik (C++) promised an intriguing evaluation. Setting the stage, this took place in a Kubernetes cluster with a single node. Here are the specifications for both deployments:

Limits:
  cpu:     600m
  memory:  1Gi
Requests:
  cpu:      300m
  memory:   512Mi

Nothing fancy. In terms of database, here are the (GCP) specs: Database

type: n2-standard-4
cpu: 4-vCPU
memory: 16GB

The PostgreSQL was 15 with PostGIS 3.3. Once again, nothing too flashy.

Benchmarks

In the top row, the numbers represent the request quantities for every 5 minutes, such as 1800 requests in a 5-minute window, 2100 requests in a 5-minute window, and so on. All values are normalised, ranging between 0 to 100. Although additional tests with heavier loads were intended, the database reached 100% CPU after exceeding 2200 requests, limiting the tests to two.

Martin

type 1800 2100 avg
K8s CPU 9 12 10.5
K8s Mem 28 19 23.5
DB CPU 57 76 66.5

Mapnik

type 1800 2100 avg
K8s CPU 72 63 68
K8s Mem 36 27 31.5
DB CPU 50 66 58

Results

Judging with only two tests makes it challenging, but considering the numbers, Martin has performed remarkably well — just look at the CPU average! The difference in DB CPU between the two tile servers is expected. Martin relies on MVT transformations at the database level, while Mapnik only gets the data and handles MVT transformations in-house. Nonetheless, the proximity of results was unexpected; I anticipated Mapnik to be the clear winner at the database level, but it only marginally outperformed Martin.

To me, the most exciting part is that Martin can be run in tiny Kubernetes deployment in terms of specs. For instance, Martin would do just fine with the following:

Limits:
  cpu:     75m
  memory:  125Mi
Requests:
  cpu:      38m
  memory:   64000Ki

That’s a tiny deployment! Incredible 💪🏽

Bonus

Beyond performance, equally crucial are the features each offers. Mapnik keeps it simple—a robust tile server with in-house MVT transformations, which is a significant advantage in my opinion. I’m not a fan of Martin’s heavy reliance on PostGIS. On the flip side, Martin excels in the variety of sources it can add. In addition to PostGIS connections, Martin can load mbtiles and pmtiles; and it provides useful utilities for mbtiles processing, including copy bulk, metadata, and diffing.

Kudos to MapLibre and everyone involved in Martin!

Enjoy!