Skip to content

Testing Martin tiler server #1279

Closed
Closed

Description

@Rub21

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) as source-layer values, 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.

Activity

  1. erictheise commented on Feb 4, 2026

    @erictheise
    Contributor

    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.

  2. 1ec5 commented on Feb 5, 2026

    @1ec5
    Member

    map styles need source-layer updates to match mview names (scriptable via JSON find/replace).

    The tile viewer is showing layer names like water_areas rather than mv_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 *_areas and *_lines makes the schema less flexible than mainstream OSM schemas.

    URL changes: Martin accesses data differently—it constructs URLs by explicitly listing the materialized views (mviews) needed for a given request.

    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.

  3. Rub21 commented on Feb 5, 2026

    @Rub21
    MemberAuthor

    The tile viewer is showing layer names like water_areas rather than mv_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?

    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/5

    Internally, 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.

    Image

    Currently, the Tegola tiles are structured as follows: https://vtiles.openhistoricalmap.org/maps/osm/13/1324/2855.pbf. The 2855.pbf file 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.

    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

    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..

    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.

    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.

  4. Rub21 commented on Feb 5, 2026

    @Rub21
    MemberAuthor

    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.

  5. 1ec5 commented on Feb 6, 2026

    @1ec5
    Member

    That would be great, since some clients other than MapLibre apparently lack TileJSON support and can only consume the tiles via tile URL templates.

  6. Rub21 commented on Mar 10, 2026

    @Rub21
    MemberAuthor

    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.

  7. Rub21 commented on Mar 10, 2026

    @Rub21
    MemberAuthor

    Also with some adjustments on the scripts and nginx config we can generate TileJOSN endpoints https://martin.ohmstaging.org/maps/ohm.json

  8. Rub21 commented on Apr 19, 2026

    @Rub21
    MemberAuthor
  9. Rub21 commented on Apr 30, 2026

    @Rub21
    MemberAuthor

    As part of the improvements to Martin, Varnish has been placed in front of Martin. Our current architecture is: Varnish → nginx → Martin.

    • We use Varnish to cache the tiles.
    • nginx handles the composite layer for all the layers.
    • Martin serves the tiles.

    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:

    • Z0–2: 24h
    • Z3–5: 12h
    • Z6–7: 6h
    • Z8–9: 3h
    • Z10–12: 2h
    • Z13–15: 1h
    • Z16–20: 30m

    Currently, tiles will be banned less frequently and will serve fresh tiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions