t-rex-tileserver / t-rex

t-rex is a vector tile server specialized on publishing MVT tiles from your own data
https://t-rex.tileserver.ch/
MIT License
545 stars 68 forks source link

Trex don't generate all tiles if nodes are specified #246

Closed dmitrykinakh closed 3 years ago

dmitrykinakh commented 3 years ago

Hi there,

I want to write about a possible issue with generating tiles using several nodes. Please take a look at commands I'm executing and stats (count of files I'm receiving each time).

According to https://t-rex.tileserver.ch/doc/generate/#cache-generation I've tried to generate a single zoom level (14) for my project using 12 threads. For that you can I've used the command you see below.

admin@myproject-pr1-trex-master:/opt$ docker-compose run --name 2_TILES_85 --rm trex-master sh -c 't_rex generate --tileset nc_property_records_county --nodeno 1 --nodes 12 --overwrite true --minzoom 14 --maxzoom 14 --extent -79.273567,35.603160,-78.402557,35.954943 --config /storage/trex/myproject.toml;'
2021-06-15 07:53:11.822 INFO Reading configuration from '/storage/trex/myproject.toml'
2021-06-15 07:53:12.765 INFO Tile cache directory: /storage/tiles/tiles_cache
Generating tileset 'nc_property_records_county'...
Level 14: 70 / 840 [====================>-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]  
Statistics:
feature_count.nc_property_records_county.nc_property_records_county.14: #measurements: 70, min: 0, max: 2665, mean: 423.2857142857 +/- 593.7685008933
tile_ms.nc_property_records_county.nc_property_records_county.14: #measurements: 70, min: 1, max: 3821, mean: 493.6857142857 +/- 763.6368161232

As a result, I've got 98 objects, 2.3 MB.

After that, I've tried more threads - 40

admin@myproject-pr1-trex-master:/opt$ docker-compose run --name 2_TILES_85 --rm trex-master sh -c 't_rex generate --tileset nc_property_records_county --nodeno 1 --nodes 40 --overwrite true --minzoom 14 --maxzoom 14 --extent -79.273567,35.603160,-78.402557,35.954943 --config /storage/trex/myproject.toml;'
2021-06-15 08:01:56.955 INFO Reading configuration from '/storage/trex/myproject.toml'
2021-06-15 08:01:57.986 INFO Tile cache directory: /storage/tiles/tiles_cache
Generating tileset 'nc_property_records_county'...
Level 14: 21 / 840 [======>-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------]  
Statistics:
feature_count.nc_property_records_county.nc_property_records_county.14: #measurements: 21, min: 0, max: 2008, mean: 569.9047619048 +/- 683.0018409486
tile_ms.nc_property_records_county.nc_property_records_county.14: #measurements: 21, min: 0, max: 2184, mean: 603.1428571429 +/- 736.1054069004

As a result, I've got 34 objects, 919.1 KB. image

Above is an example of generating tiles with 4 nodes.

I was confused as noticed my tiles are incomplete and contain holes if I use multiple nodes for a generation.

So, I've decided to do one more attempt and generate that zoom level one more time but without specifying --nodeno and --nodes parameters.

admin@myproject-pr1-trex-master:/opt$ docker-compose run --name 2_TILES_85 --rm trex-master sh -c 't_rex generate --tileset nc_property_records_county  --overwrite true --minzoom 14 --maxzoom 14 --extent -79.273567,35.603160,-78.402557,35.954943 --config /storage/trex/myproject.toml;'
2021-06-15 08:09:26.548 INFO Reading configuration from '/storage/trex/myproject.toml'
2021-06-15 08:09:27.574 INFO Tile cache directory: /storage/tiles/tiles_cache
Generating tileset 'nc_property_records_county'...
Level 14: 840 / 840 [=======================================================================================================================================================================================================================================================]  
Statistics:
feature_count.nc_property_records_county.nc_property_records_county.14: #measurements: 840, min: 0, max: 2895, mean: 446.3357142857 +/- 577.2085507903
tile_ms.nc_property_records_county.nc_property_records_county.14: #measurements: 840, min: 0, max: 3305, mean: 438.3559523810 +/- 597.5449321323

As a result, I've got 728 objects, 28.9 MB and there were no holes for the area I was generating. image

So, could you please let me know if that Trex has an issue or I'm executing multi-threading in the wrong way?

pka commented 3 years ago

Multi-threading and nodes are two different things. You need nodes for for producing tiles on multiple machines. So if you have 3 machines, you start t-rex on these nodes with --nodes 3 --nodeno 0, --nodes 3 --nodeno 1 and --nodes 3 --nodeno 2. Each machine produces 1/3 of the tiles.

Before 0.13.0, using multiple nodes on a single machine was a trick to parallelize tile production. But since 0.13.0 t-rex automatically uses one thread per core.

knowname commented 1 year ago

Thanks a lot @pka. I checked https://t-rex.tileserver.ch/doc/generate/ for information on multithreading and also fell for the "--nodes" option. Adding this information to the help / reference might be helpful :)