GIS Engineering · Vector Tiles · Cloud Architecture

Cloud-Native Web Mapping: PMTiles, Martin & PostGIS

How PMTiles on Cloudflare R2, Rust-powered microservices, and PostGIS optimization are replacing legacy GeoServer stacks and cutting infrastructure costs by up to 90%.

Talha WaheedCo-Founder & Head of Engineering18 min read
Cloud-native geospatial architecture network diagram showing PMTiles, Martin, and PostGIS
← Back to Blog

For almost two decades, Java-based mapping servers like GeoServer and MapServerwere the backbone of web mapping infrastructure. They worked. But "it works" and "it scales economically" are very different things.

The core problem is architectural: every map pan, zoom, and tile request must travel to a centralized application server, spin up JVM threads, negotiate a database connection, execute spatial queries, serialize geometries, and return a payload in real time. Under heavy production load, that pipeline becomes an expensive bottleneck.

Infrastructure Cost Reduction
90%
Sakay production migration benchmark
PMTiles v3 Initial Payload
16 KB
97% reduction vs v2 (512 KB)
PostGIS Polygon Speedup
87%
CARTO ST_AsMVTGeom benchmark
JVM Garbage Collection Stalls
0 ms
Rust / Go native compilation

Why Monolithic GIS Servers Are Failing Modern Applications

GeoServer deployments require deliberate JVM memory configuration. Its official production guidance documents heap sizing, garbage collection, and related Java settings that add state and capacity planning to an otherwise elastic cloud deployment.

JVM ParameterFunctionScalability Impact
-XmsInitial heap size on startupWastes idle cloud resources if set too high
-XmxMaximum memory allocation poolLimits concurrent tile rendering threads
-XX:MaxPermSizeClass bytecode storage (PermGen)Exhaustion causes catastrophic server crashes
Diagram showing monolithic GIS server pipeline

Cloud-Native Geospatial Formats: The Foundation

The paradigm shift does not just replace one server with a faster one. It removes the server entirely for the majority of use cases, leveraging a class of cloud-native file formats built around HTTP range requests.

Legacy Format
Shapefile / MBTiles

Requires local file downloads or running database middleware to extract geometry.

Cloud-Native Format
PMTiles / GeoParquet

Clients query only specific byte ranges directly from standard S3/R2 storage with zero compute.

The OGC Cloud Optimized GeoTIFF standard established this methodology for raster data. The GeoParquet specification brings interoperable geospatial types to columnar analytics, while FlatGeobuf documents its HTTP range-request and spatial-indexing model.

PMTiles: The Gold Standard for Static Map Delivery

For spatial data with update cycles measured in days, weeks, or months, PMTiles is the premier static delivery mechanism. The PMTiles v3 specification defines a single-file tile archive whose directories and tile payloads can be retrieved with HTTP range requests, completely bypassing tile servers.

Hilbert Curve Addressing in PMTiles v3

PMTiles v3 replaces older Z/X/Y directory structures with 64-bit Hilbert Curve ordering. Geographically adjacent tiles map to contiguous byte sequences, maximizing CDN cache locality and shrinking initial directory requests to 16 KB.

Hilbert curve tile ordering in PMTiles v3

Infrastructure Economics: Escaping the Egress Trap

PMTiles’ technical brilliance only matters if you can serve it economically at scale. Traditional hyperscale cloud providers charge punishing egress fees on high-traffic range queries.

The Cloudflare R2 Advantage

Cloudflare R2 provides zero-egress fee object storage. In production case studies like Sakay, migrating map basemaps to PMTiles on Cloudflare R2 resulted in documented 90% cost reductions.

Dynamic Data: Rust-Powered Vector Tile Microservices (Martin)

When data updates in real time, static PMTiles are paired with dynamic tile servers. Martin, written in Rust and maintained under the MapLibre organization, generates vector tiles directly from PostGIS functions with zero JVM overhead.

# Martin configuration (config.yaml)
postgres:
  connection_string: 'postgresql://postgres:secret@db.internal:5432/spatial_db'
  auto_publish:
    tables:
      from_schema: 'public'
    functions:
      from_schema: 'public'

pmtiles:
  sources:
    basemap: '/data/planet.pmtiles'

PostGIS Optimization: The ST_AsMVT Pipeline

PostGIS aggregates binary Mapbox Vector Tiles using ST_AsMVT() and transforms geometry into tile coordinate space using ST_AsMVTGeom().

WITH mvt_geom AS (
  SELECT
    ST_AsMVTGeom(
      geom,
      ST_TileEnvelope(z, x, y),
      4096, 64, true
    ) AS geom,
    id, name, category
  FROM spatial_parcels
  WHERE geom && ST_TileEnvelope(z, x, y)
)
SELECT ST_AsMVT(mvt_geom.*, 'parcels')
FROM mvt_geom
WHERE mvt_geom.geom IS NOT NULL;

Multi-Tiered Caching: The Final Performance Layer

Vector tile URLs are completely deterministic. Modern pipelines deploy multi-tier caching across CDN edges, Nginx reverse proxies, and Martin's internal memory cache.

Multi-tier caching architecture from CDN to PostGIS

Ready to Modernize Your Spatial Architecture?

Migrate from Legacy GIS Servers to Cloud-Native

Infryne TechWorks builds modern geospatial infrastructure for teams moving off bloated GIS servers: PMTiles deployment, Martin configuration, and PostGIS optimization.

Primary Sources

Related Infryne Articles