Serving Vector Tiles, Fast

(spatialists.ch)

98 points | by altilunium a day ago ago

17 comments

  • stevage a day ago

    The term "serving" is a bit misleading here. Most of the time, vector tile servers are serving pre generated tiles, which is extremely fast. This analysis is about generating tiles on the fly from PostGIS through a custom web server.

    • vlovich123 a day ago

      Yup but super impressive just how much faster Martin was than all the other competition by significant margins with Bbox (Rust) and Tegola (Go) trailing at ~2-4x slower. That indicates the author(s) of Martin really optimized the data structures & algorithms to achieve a new Pareto frontier. Neat - would be nice if there were an accessible summary of the tricks employed to make it so fast that were missing in competitors.

      • darksaints 20 hours ago

        The trick that makes Martin so fast is not doing any geospatial processing, and just being focused on making quick, non-blocking requests to Postgres. All geospatial processing is done by PostGIS, which is essentially just using the C++ geos library (which is by far the most comprehensive and well optimized geospatial processing library).

      • GrayShade a day ago

        Martin has an in-memory tile cache, which probably makes a difference: https://github.com/maplibre/martin/pull/1105. BBOX caches to a file instead.

        • darksaints 20 hours ago

          The benchmarking repository has config files used for the test, and they did not use the tile cache feature.

          • vlovich123 19 hours ago

            It defaults to 512MiB if not configured explicitly to 0 which it’s not in the repository.

            • darksaints 18 hours ago

              Oh that’s interesting, and I’m actually kinda peeved by any database-connected system that caches responses by default. Caching should be reserved as a performance optimization with serious correctness tradeoffs.

              Regardless, I don’t think caching came into play here, at least according to how I’m reading this repository. I would expect cold caches for everything.

      • stevage a day ago

        Yeah, that's definitely interesting - I'm surprised there is so much room for variation considering PostGIS is (if I'm not mistaken) doing most of the work.

        I couldn't find any description of what test 1, 2, 3 etc actually are though.

    • n4r9 a day ago

      Not sure I agree; it sounds like the vector tiles are generated in advance of testing the servers. This description is from the linked GitHub:

      > six open-source vector tiles servers (BBOX, Ldproxy, Martin, pg_tileserv, Tegola, and TiPg) are set up and configured using Docker in a public cloud. Vector tiles are created for each server from the vector data of the PostGIS database. Various test scenarios with Apache JMeter are used to determine which server can deliver the vector tiles the fastest.

      • GrayShade a day ago
        • n4r9 a day ago

          Yes, true. I had the impression that the tiles themselves were being stored as geometric data in the postgres DB, then fetched and served. But I might have been confused by the article starting "Once you have created your vector tiles...". The GitHub page is a little ambiguous tbh.

          • stevage a day ago

            >The GitHub page is a little ambiguous tbh.

            Agreed.

  • pbsurf a day ago

    I've built a server for generating OpenStreetMap vector tiles on demand from a GeoDesk database, which is barely larger than an .osm.pbf (100GB vs. 80GB for current planet.osm.pbf) - much smaller than a PostGIS instance: https://github.com/styluslabs/geodesk-tiles

  • durkie 19 hours ago

    another option that would have been interesting to see here is serving PostGIS GeoJSON export -> tippecanoe encode. Tippecanoe is super fast, parallelizes well and built solely for generating vector tile data (with lots of configurable options that PostGIS lacks)

  • pluto_modadic 20 hours ago

    okay, do they mean vectors, or tiles, because that's like saying "serving PNG JPEGs" or "serving JPEG PNGs". Some servers chuck back /a picture/, some servers chuck back /an SVG/ or line data.

    • chipsa 20 hours ago

      They mean vector tiles. It’s tiles of vectorized images, usually of a map (or other geographic data). They’re so named because they are a vectorized replacement for raster tiles, which were PNGs. If the server chucks back a picture, it’s not a vector tile server.

    • andrewljohnson 20 hours ago

      In GIS world, a vector tile is a chunk of geographic data (the vectors) limited to a geographic region (the tile boundaries which fit into the projected checkerboard of your map).

      You use a vector tile instead of a png or jpeg tile because you don’t want an image representation of the data, you want the raw “vector” data so you can style it, search it, and do other things with it on client devices.