Repository navigation
Description
Our current tile server uses Tegola which has served us well so far with some delays in certain areas, and sometimes takes time. [#1177, #239, #1189] and more.
I've already applied many optimizations to the Tiler database—most notably, moving all layers into materialized views so they're read-only and require no additional processing at query time. [ohm-deploy#669, #917]. Currently we have around 123 materialized views that serve the vtiles.
Past days I've been testing Martin (v0.14.2), a vector tile server from the MapLibre ecosystem, as a replacement. Martin is written in Rust, actively maintained, and significantly lighter (2-3x faster than Tegola). I've built a working prototype that is already running at https://martin.openhistoricalmap.net/. it load the ohm tiles faster then tegola
If we use this what changes
- No more manual config. Instead of 23 TOML files as we do with Tegola.
- Auto-discovery: Python script runs at container startup, connects to PostgreSQL, discovers all our materialized views automatically, and generates the Martin configuration. If we add new views to the database, Martin picks them up on the next restart—no config file to edit.
⚠️ Source-layer naming difference: Martin uses exact materialized view names (mv_water_areas_z0_2,mv_landuse_areas_z6_7) assource-layervalues, while Tegola used custom layer names from config. All map styles need source-layer updates to match mview names (scriptable via JSON find/replace).
URL changes: Martin accesses data differently—it constructs URLs by explicitly listing the materialized views (mviews) needed for a given request.
Example:
https://martin.openhistoricalmap.net/mv_admin_maritime_lines_z0_5_v2,mv_admin_maritime_lines_z6_9,mv_admin_maritime_lines_z10_15/3/4/3.pbf, but with config we can ensure the the right mview es server according to the zoom level https://github.com/OpenHistoricalMap/ohm-deploy/blob/test_vtiles_martin/images/tiler-server-martin/config/config.yaml
What stays the same
- PostgreSQL materialized views remain unchanged
- MView refresh process continues as-is
This is just a test, but the rendering speed with Martin looks promising.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Production
Activity
erictheise commentedon Feb 4, 2026
I've been using Martin in my own projects for a year or more now without complaint. For my work it's especially helpful that it generates glyphs from regular font files (e.g.,
.otf,.ttf) at boot time.1ec5 commentedon Feb 5, 2026
The tile viewer is showing layer names like
water_areasrather thanmv_water_areas_z0_2. Is that because you haven’t ported all the materialized views over to Martin yet, or because we still have a mechanism to customize the layer names?If anything, we should gradually consolidate layers and give them more logical names. That would allow style designers to take better advantage of data-driven styling for better performance and easier code maintenance. We’ve previously gotten feedback from style designers that the schema feels too “raw”: hiddewie/OpenRailwayMap-vector#246 (comment). Even the distinction between
*_areasand*_linesmakes the schema less flexible than mainstream OSM schemas.Would style authors also need to change the tile URL pattern in their stylesheets to enumerate the material views? TileJSON can mitigate the inconvenience somewhat, but this is also a lot more raw than I’m used to seeing.
On the other hand, Martin’s on-the-fly processing sounds promising for eventually being able to do things like accept a
?language=parameter that filters the tiles to contain names in only the requested language, or?date=for only the features in the requested time period.Rub21 commentedon Feb 5, 2026
This is just to show layer examples. For the water_areas layer, we make a request for all layers:
https://martin.openhistoricalmap.net/mv_water_areas_z0_2,mv_water_areas_z3_5,mv_water_areas_z6_7,mv_water_areas_z8_9,mv_water_areas_z10_12,mv_water_areas_z13_15,mv_water_areas_z16_20/4/7/5Internally, I've configured Martin to select the appropriate Material View based on zoom level. That's why when we navigate and click on an object, it shows the materialized view corresponding to that zoom level.
Currently, the Tegola tiles are structured as follows: https://vtiles.openhistoricalmap.org/maps/osm/13/1324/2855.pbf. The
2855.pbffile contains all source layers internally named as water_areas, transport_lines, etc.I've tried to mask a URL https://martin.openhistoricalmap.net/maps/osm/13/1324/2855.pbf with nginx and pass all layers to Martin, but internally Martin would use the materialized view names for the source layers, such as mv_water_areas_z13_15, mv_transport_lines_z13_15, mv_building_z13_15, etc., which would break the current style sheets.
I agree. I think we could do some refactoring on the names but nos sure if using with nginx we could help maintain legacy support for a while while providing the new layers.
Additionally, Martin offers TileJSON schema v3 in its configuration https://martin.openhistoricalmap.net/mv_admin_boundaries_areas_z0_2, compared to Tegola which we're still in the process of incorporating in a PR..
I think this is very promising. Additionally, with Martin we no longer need to clean the tile cache - we just need to update the materialized views and Martin automatically extracts them fresh with each new request.
Rub21 commentedon Feb 5, 2026
I'm exploring the documentation further, and I think it's possible to serve the same format we had with Tegola, which would mean we wouldn't need to change our stylesheets.
1ec5 commentedon Feb 6, 2026
That would be great, since some clients other than MapLibre apparently lack TileJSON support and can only consume the tiles via tile URL templates.
Rub21 commentedon Mar 10, 2026
I’ve deployed Martin on a subdomain: https://martin.ohmstaging.org/.
Compatible endpoints: I've successfully replicated Tegola’s endpoint structure using Martin. With an Nginx configuration, it now serve the same sources and layers under identical URLs.
Tile caching: Nginx is configured to cache tiles for 1 hour. This means all vector tiles are stored in the Nginx cache temporarily —no manual cache invalidation needed.
Automatic attribute detection: The script that generates Martin functions now automatically reads column names from materialized views and exposes them as feature attributes. This eliminates the need to manually define attributes in TOML files, which simplifies maintenance.
MViews for each zoom level: In our imposm configuration, we have multiple materialized views with simplification for different zoom levels for almos all layers. Martin is configured to fetch data from the appropriate view based on the requested zoom level.
Rub21 commentedon Mar 10, 2026
Also with some adjustments on the scripts and nginx config we can generate TileJOSN endpoints https://martin.ohmstaging.org/maps/ohm.json
Rub21 commentedon Apr 19, 2026
Martin is already running in production for a week seems good to close this ticket: https://vtiles.openhistoricalmap.org/#13.87/47.75667/-121.76432
Rub21 commentedon Apr 30, 2026
As part of the improvements to Martin, Varnish has been placed in front of Martin. Our current architecture is: Varnish → nginx → Martin.
In addition, we continue using
tiler_sqs_cleaner, which allows us to clear the cache or ban tiles as they expire from Imposm. It works the same way it did before with Tegola, but in this case we no longer delete tiles from S3 — we only ban the tiles in Varnish.With this change, the TTL period is eliminated:
Currently, tiles will be banned less frequently and will serve fresh tiles.