This commit is contained in:
Zsolt Ero
2024-06-11 01:40:26 +02:00
parent d95248ca9c
commit c05fd0801b
5 changed files with 14 additions and 14 deletions

View File

@@ -62,7 +62,7 @@ It does the following:
- checks the most up-to-date files in the public buckets - checks the most up-to-date files in the public buckets
- downloads/extracts them locally, if needed - downloads/extracts them locally, if needed
- mounts the downloaded BTRFS images in `/mnt/ofm` - mounts the downloaded Btrfs images in `/mnt/ofm`
- creates the correct TileJSON file - creates the correct TileJSON file
- creates the correct nginx config - creates the correct nginx config
- reloads nginx - reloads nginx
@@ -75,7 +75,7 @@ _note: Tile generation is 100% optional, as we are providing the processed full
The `tile_gen` scripts downloads a full planet OSM extract and runs it through Planetiler. The `tile_gen` scripts downloads a full planet OSM extract and runs it through Planetiler.
The created .mbtiles file is then extracted into a BTRFS partition image using the custom [extract_mbtiles](scripts/tile_gen/extract_mbtiles) script. The partition is shrunk using the [shrink_btrfs](scripts/tile_gen/shrink_btrfs) script. The created .mbtiles file is then extracted into a Btrfs partition image using the custom [extract_mbtiles](scripts/tile_gen/extract_mbtiles) script. The partition is shrunk using the [shrink_btrfs](scripts/tile_gen/shrink_btrfs) script.
Finally, it's uploaded to a public Cloudflare R2 bucket using rclone. Finally, it's uploaded to a public Cloudflare R2 bucket using rclone.
@@ -95,11 +95,11 @@ Currently it's running in warning-only mode, DNS updates need manual confirmatio
See [self hosting docs](docs/self_hosting.md). See [self hosting docs](docs/self_hosting.md).
## BTRFS images ## Btrfs images
Production-quality hosting of 300 million tiny files is hard. The average file size is just 450 byte. Dozens of tile servers have been written to tackle this problem, but they all have their limitations. Production-quality hosting of 300 million tiny files is hard. The average file size is just 450 byte. Dozens of tile servers have been written to tackle this problem, but they all have their limitations.
The original idea of this project is to avoid using tile servers altogether. Instead, the tiles are directly served from BTRFS partition images + hard links using an optimised nginx config. I wrote [extract_mbtiles](scripts/tile_gen/extract_mbtiles) and [shrink_btrfs](scripts/tile_gen/shrink_btrfs) scripts for this very purpose. The original idea of this project is to avoid using tile servers altogether. Instead, the tiles are directly served from Btrfs partition images + hard links using an optimised nginx config. I wrote [extract_mbtiles](scripts/tile_gen/extract_mbtiles) and [shrink_btrfs](scripts/tile_gen/shrink_btrfs) scripts for this very purpose.
This replaces a running service with a pure, file-system-level implementation. Since the Linux kernel's file caching is among the highest-performing and most thoroughly tested codes ever written, it delivers serious performance. This replaces a running service with a pure, file-system-level implementation. Since the Linux kernel's file caching is among the highest-performing and most thoroughly tested codes ever written, it delivers serious performance.
@@ -112,7 +112,7 @@ I run some [benchmarks](docs/quick_notes/http_benchmark.md) on a Hetzner server,
You can directly download the processed full planet runs on the following URLs: You can directly download the processed full planet runs on the following URLs:
https://planet.openfreemap.com/20240607_232801_pt/tiles.mbtiles // 89 GB, mbtiles file https://planet.openfreemap.com/20240607_232801_pt/tiles.mbtiles // 89 GB, mbtiles file
https://planet.openfreemap.com/20240607_232801_pt/tiles.btrfs.gz // 86 GB, BTRFS partition image https://planet.openfreemap.com/20240607_232801_pt/tiles.btrfs.gz // 86 GB, Btrfs partition image
Replace the `20240607_232801_pt` part with any newer run, from the [index file](https://planet.openfreemap.com/index.txt). Replace the `20240607_232801_pt` part with any newer run, from the [index file](https://planet.openfreemap.com/index.txt).

View File

@@ -112,7 +112,7 @@ def write_tile_files(c, *, dir_path):
tile_path.hardlink_to(dedupl_path_fixed) tile_path.hardlink_to(dedupl_path_fixed)
print(f'hard link created {i}/{total} {i / total * 100:.1f}%: {tile_path}') print(f'hard link created {i}/{total} {i / total * 100:.1f}%: {tile_path}')
except OSError as e: except OSError as e:
# fixing BTRFS's 64k max link limit # fixing Btrfs's 64k max link limit
if e.errno == 31: if e.errno == 31:
bug_fix_dict.setdefault(dedupl_path, 0) bug_fix_dict.setdefault(dedupl_path, 0)
bug_fix_dict[dedupl_path] += 1 bug_fix_dict[dedupl_path] += 1

View File

@@ -19,8 +19,8 @@ SMALLEST_SIZE = 256 * 1024 * 1024
) )
def cli(btrfs_img: Path): def cli(btrfs_img: Path):
""" """
Shrinks a BTRFS image Shrinks a Btrfs image
// I cannot believe that BTRFS is over 15 years old, // I cannot believe that Btrfs is over 15 years old,
// yet there is no resize2fs tool which can shrink a disk image // yet there is no resize2fs tool which can shrink a disk image
// to minimum size. // to minimum size.
// It cannot even tell you how much should be the right size, // It cannot even tell you how much should be the right size,

View File

@@ -36,7 +36,7 @@ I'm Zsolt Ero ([X](https://x.com/hyperknot), [blog](https://blog.hyperknot.com/)
## Why did you build this project? ## Why did you build this project?
OpenStreetMap is one of the most important collective projects in history. It began almost 20 years ago, and today, 3 million edits are made each day! OpenStreetMap is one of the most important collective projects in history. It began 20 years ago, and today, 3 million edits are made each day!
Unfortunately, when you want to use the map on your website or app, you need to look for a commercial map tile provider and hope your site doesn't become too popular. Otherwise, you might end up with a $10,000 bill in a single day, as Hoodmaps [did](https://x.com/levelsio/status/1730659933232730443). Unfortunately, when you want to use the map on your website or app, you need to look for a commercial map tile provider and hope your site doesn't become too popular. Otherwise, you might end up with a $10,000 bill in a single day, as Hoodmaps [did](https://x.com/levelsio/status/1730659933232730443).
@@ -56,7 +56,7 @@ If this project helps you save on your map hosting costs, please consider subscr
## How can I follow this project? ## How can I follow this project?
X: [hyperknot](https://x.com/hyperknot) (details) and [OpenFreeMapOrg](https://x.com/OpenFreeMapOrg) (announcements) X: [hyperknot](https://x.com/hyperknot) (more details) and [OpenFreeMapOrg](https://x.com/OpenFreeMapOrg) (announcements)
GitHub: [openfreemap](https://github.com/hyperknot/openfreemap) and [openfreemap-styles](https://github.com/hyperknot/openfreemap-styles) GitHub: [openfreemap](https://github.com/hyperknot/openfreemap) and [openfreemap-styles](https://github.com/hyperknot/openfreemap-styles)
@@ -64,11 +64,11 @@ GitHub: [openfreemap](https://github.com/hyperknot/openfreemap) and [openfreemap
The map schema is [OpenMapTiles](https://github.com/openmaptiles/openmaptiles), the tiles are generated by [Planetiler](https://github.com/onthegomap/planetiler). The [styles](https://github.com/hyperknot/openfreemap-styles) are forked and heavily modified. The map schema is [OpenMapTiles](https://github.com/openmaptiles/openmaptiles), the tiles are generated by [Planetiler](https://github.com/onthegomap/planetiler). The [styles](https://github.com/hyperknot/openfreemap-styles) are forked and heavily modified.
There is no tile server running, only BTRFS partition images with 300 million hard-linked files. I haven't read anyone else doing this in production, but it works really well. There is no tile server running; only Btrfs partition images with 300 million hard-linked files. This was my idea; I haven't read about anyone else doing this in production, but it works really well.
There is no cloud, just dedicated servers. The HTTPS server is nginx on Ubuntu.
There is no cloud, just dedicated servers. The HTTP server is nginx on Ubuntu.
Currently, it is behind Cloudflare.
## Attribution ## Attribution

View File

@@ -114,7 +114,7 @@
<label for="col5" class="col-lbl">Self-hosting</label> <label for="col5" class="col-lbl">Self-hosting</label>
<div class="col-cnt"> <div class="col-cnt">
<p> <p>
You can also download our processed planet MBTiles and BTRFS images if you want to self-host You can also download our processed planet MBTiles and Btrfs images if you want to self-host
yourself. Details can be found on yourself. Details can be found on
<a href="https://github.com/hyperknot/openfreemap" target="_blank">GitHub</a>. <a href="https://github.com/hyperknot/openfreemap" target="_blank">GitHub</a>.
</p> </p>