Land cover · vector
Not a sample or a selection: the official map of how all of mainland Portugal is used, from the national mapping agency. 842,413 shapes in 93 classes, with no gaps between them. TerraServe serves it two ways at the same time, from one process holding 75 MB of memory.

The approach
Most big map datasets are things dotted about: buildings, roads, points. This one tiles the entire country: every square metre belongs to exactly one of 93 classes, and neighbouring shapes share their borders exactly. That's much harder to serve, because no matter where you look there's always something to draw. There's no empty space to skip.
The same layer answers as WMS, where the server draws a picture and sends it, which is what desktop GIS expects, and as vector tiles, where the raw shapes go to the browser and it does the drawing, so you can restyle and click individual parcels. Same data, same process, two completely different jobs.
The file is never loaded. TerraServe uses its spatial index to fetch only the shapes inside the area you asked for, so memory tracks your screen, not the dataset. It starts in 8 seconds and settles around 75 MB, small enough that we run two copies behind a load balancer for redundancy.
How it's served
This is the real command behind the live demo: two identical copies of it, load-balanced. Every flag, explained below.
terraserve serve # land cover of Portugal, WMS + vector tiles --vector /data/cos2023v1.fgb --vec-style /data/cos2023.sld --src-crs EPSG:3763 --name cos2023 --mvt-style /data/cos2023.mvt-style.json --mvt-min-feature-px 0 --no-safety-limit --raster-min-feature-px 0 # every polygon --tms-grid WebMercatorQuad --tile-max-age 3600 --tile-encoding br --pmtiles /data-cache/cos2023.mvt.z14.zstd.pmtiles --raster-pmtiles /data-cache/cos2023.raster.z14.pmtiles --mvt-cache 0 --wms-cache 4096 --max-inflight 8 --public-url https://terraserve.io/demo/cos2023/wms # and one environment variable, which matters more than it looks: TERRASERVE_FGB_MAX_QUERY_FEATURES=2000000
| --vector | The data file: a FlatGeoBuf holding all 842,413 land-cover shapes. It carries a spatial index, which is what lets the server read just the piece you're looking at instead of loading the file. |
| --vec-style | How to colour it for the picture view: a standard SLD that gives every land-cover class its own fill. |
| --src-crs | The map projection the data is stored in (Portugal's national grid, EPSG:3763). |
| --name | What the layer is called. This one name has to match in four places: the WMS layer, the vector-tile source, the style, and the viewer URL. |
| --mvt-style | A second style, for the vector-tile view the browser draws itself. Same data, different renderer, so it needs its own colours. |
| --mvt-min-feature-px 0 --no-safety-limit | Draw every polygon at every zoom, with no size gate and no per-tile cap: the map is 100 % complete. The heavy zoomed-out vector tiles are why the picture archive below exists. |
| --raster-min-feature-px 0 | The same for the picture paths (WMS, WMTS, TMS): nothing skipped. |
| --tms-grid WebMercatorQuad | Publish the tile grid for WMTS and TMS, so the viewer can draw the picture underlay from the archive below. |
| --tile-max-age 3600 | Every tile carries an ETag; this adds an hour of browser caching, so revisiting a view costs no requests at all. |
| --tile-encoding br | Send live vector tiles as brotli, measured smaller than gzip and faster to produce. A browser that does not accept brotli still gets gzip. |
| --pmtiles | A pre-baked vector archive of zooms 0 to 14, stored as zstd. A request in that range is a straight read off disk: about 5 ms, no drawing at all. |
| --raster-pmtiles | The same zooms pre-baked as pictures (3.25 GB), for WMTS and TMS: the underlay shows every polygon at zoomed-out views without a browser having to decode them. |
| --mvt-cache 0 | No in-memory tile cache needed on top of the archive: a read from it is already a few milliseconds, and the operating system keeps the hot parts in RAM for free. |
| --wms-cache 4096 | Remember recently-drawn pictures (up to 4 GB) so an identical repeat costs nothing. This is what makes panning back over ground you have already seen instant. |
| --max-inflight 8 | Draw at most 8 maps at once: one per CPU core. Drawing is CPU-bound, so allowing more would just make everything queue behind everything else. |
| --public-url | The public address to advertise to GIS clients. The server sits behind a proxy, and QGIS takes the address for every follow-up request from this value. Get it wrong and QGIS lists the layer but draws nothing. |
| TERRASERVE_FGB_MAX_QUERY_FEATURES | A safety limit on how many shapes one request may decode, raised above this layer’s 842,413. It's a correctness setting, not a speed one: left at its default, a wide request quietly stops early and whole regions go missing behind a perfectly normal-looking response. |
Brotli on the wire, zstd on disk. Since 0.3.3 live tiles go out as brotli (--tile-encoding br, measured smaller than gzip and faster to produce), and the pre-baked archive stores its tiles as zstd: 922 MB to 888 MB (-3.7 %; tiles holding many small polygons leave little to gain), converted from gzip with terraserve pmtiles-recompress, every tile checked identical. A browser that accepts zstd gets the archive bytes straight off disk; one that does not, such as Safari, gets a brotli copy made once and cached; anything else gets gzip.
Measured on the live server: 75 MB of memory per copy, 8 s to start. Map tiles take about 150 ms each the first time and 5 ms once cached; the pre-baked zoom levels come back in about 5 ms. The honest exception: asking for the entire country as one image, which QGIS does if you hit "zoom to full extent", takes around 35 s the first time, because there's no pre-simplified copy to fall back on. Every repeat after that is instant.
Source & attribution. Data: Direção-Geral do Território (DGT), Carta de Uso e Ocupação do Solo (COS), Série 2, 2023, Portugal Continental. DGT publishes this same layer in their Visualizador SMOS, served from their own GeoServer. That's the same GeoServer this dataset was benchmarked against.