PMTiles vs MBTiles: choosing the right map tile format for 2025
PMTiles and MBTiles compared for hosting performance cost and tooling. Why PMTiles is winning for cloud-native map tile delivery.
PMTiles vs MBTiles: Choosing the right map tile format for 2025
Selecting the right tile format for your mapping application can significantly impact performance, hosting costs, and user experience. As map rendering technologies evolve, developers increasingly face the choice between PMTiles and MBTiles for hosting and serving vector tiles. Understanding the nuances of these formats, how they integrate with cloud hosting and CDNs, and the growing usability of tools like Protomaps can help you make a well-informed decision.
Understanding PMTiles and MBTiles
MBTiles overview
MBTiles is a widely used format for storing tilesets, primarily raster tiles. It encapsulates tiles in a single SQLite database file, making it easy to store, transport, and serve. This format has been around for over a decade and is supported by various mapping libraries and frameworks like Leaflet and Mapbox GL JS.
From the developer's perspective, MBTiles simplifies local tile management but introduces challenges when it comes to cloud-hosting and caching. As the size of the tile set grows, managing and serving tiles efficiently can become cumbersome, especially under high load conditions.
PMTiles overview
PMTiles was designed to address some of the limitations inherent in MBTiles, particularly for vector tile formats. By employing a more efficient storage mechanism, PMTiles allows for tiles to be served from a multi-file object format that can reside directly on a CDN, significantly improving load times and reducing latency.
With its focus on vector tiles and support for web-friendly protocols, PMTiles is poised to meet the needs of modern mapping applications. It enables developers to deliver rich, interactive experiences with faster load times, which can be a critical differentiator in user engagement.
Hosting options and CDN support
Hosting MBTiles
When hosting MBTiles, a common approach involves uploading the SQLite file to a server and serving tiles through a web application. For larger datasets, configuring a CDN becomes necessary. However, some pitfalls can occur:
- Loading times: Depending on the CDN setup, tiles may take longer to load, particularly for dynamically requested tiles.
- Cost: A high volume of requests can lead to increased operational costs, especially if the CDN setup requires frequent cache invalidation.
To illustrate how to serve MBTiles using a Node.js server, consider the following example:
const express = require('express');
const mbtiles = require('@mapbox/mbtiles');
const app = express();
app.get('/tiles/:z/:x/:y.png', (req, res) => {
const z = req.params.z;
const x = req.params.x;
const y = req.params.y;
new mbtiles('path/to/your.tiles', (err, mbtiles) => {
if (err) return res.status(500).send(err);
mbtiles.getTile(z, x, y, (err, tile, headers) => {
if (err) return res.status(404).send('Tile not found');
res.set(headers);
res.send(tile);
});
});
});
app.listen(3000, () => console.log('Server running on port 3000'));
Hosting PMTiles
Given the advances with PMTiles, hosting becomes significantly more straightforward. Since PMTiles can be stored in various object-friendly storage, it allows for a more efficient use of cloud resources. CDNs can serve tiles directly from the object store, leading to faster access times.
An example of how to host and serve PMTiles would look much simpler:
const express = require('express');
const axios = require('axios');
const app = express();
app.get('/tiles/:z/:x/:y.pmb', async (req, res) => {
const { z, x, y } = req.params;
const endpoint = `https://your-cdn-url/tiles/${z}/${x}/${y}.pmb`;
try {
const response = await axios.get(endpoint, { responseType: 'arraybuffer' });
res.set('Content-Type', 'application/octet-stream');
res.send(response.data);
} catch (error) {
return res.status(404).send('Tile not found');
}
});
app.listen(3000, () => console.log('Server running on port 3000'));
CDN integration
Both formats can benefit from using CDNs, but PMTiles enjoys more seamless integration due to its structure. Platforms like Bunny CDN or specialized providers that support vector tiles can optimize delivery. For example, with PMTiles, all you need is to upload your tiles to your storage solution and point your CDN to serve them directly. This often results in faster response times and lower costs.
Comparing PMTiles and MBTiles
The differences between PMTiles and MBTiles can dramatically affect the architecture of your geospatial applications. Below is a comparison across key dimensions to help in your decision-making:
| Feature | MBTiles | PMTiles |
|---|---|---|
| Tile format | Primarily raster | Vector, optimized for web |
| File structure | Single SQLite file | Multi-file object storage |
| CDN compatibility | Requires custom setup | Direct integration supported |
| Performance under load | Slower with larger datasets | Better support for high load |
| Hosting flexibility | Less flexible, database-centric | Highly flexible, storage-agnostic |
| Cache invalidation | Manual cache management | CDN can handle automatically |
Further options for hosting tile formats
For those looking for hosted solutions or further options, providers like Maptiler and Mapbox also offer tile hosting services that cater to different needs alongside PMTiles.
Conclusion
Deciding between PMTiles and MBTiles hinges on your application requirements and future scaling needs. If you are committed to a modern mapping solution with a focus on interactivity, consider leaning more towards PMTiles, as its architecture supports greater flexibility and performance. Evaluating your CDN strategy and hosting environment early will set you up for success with whichever format you choose.
FAQ
See also
Start building with Mapsi — free
No credit card required. Free tier includes 10,000 requests/month.
curl "https://api.mapsi.dev/geocode?q=Berlin&key=YOUR_KEY" - EU-hosted on Hetzner — GDPR compliant
- Open-source core — Pelias + Valhalla
- Store results forever — no lock-in