[GIS] Increase Tiles Caching Speed (TileStache)

cachepostgispythontilestachevector-tiles

I am serving vector tiles using TileStache, I have everything set up like I want. My data is stored in Postgres and I am using the VecTiles provider to serve GeoJSON tiles.

I want to cache all my tiles to make the tiles serve faster. I am using tilestache-seed.py to seed my cache. I am running tilestache-seed on several machines. Tilestache-seed worked really well uptill zoom level 13, but after that it is taking way too long to cache the tiles. Just for Zoom Level 16 I have 5023772 tiles to cache, and I am only getting 100k-200k tiles per day on each machine.

How can I make my tiles cache faster? Is there a way to fine tune tilestache-seed.py and make it seed faster?

Update: I have tried building spatial indexes on my tables (on the geometry column and the columns used for filtering data through the where clause) and I still haven't seen a significant increase in tiling speed. At this rate only Zoom 17 will take me a month and this time will only increase exponentially as I move towards Zoom 21

Update 2: I tried making materialized views as well and there is no discernible change in performance, so optimizing the database is not working. I think I will need to optimize the tilestache-seed.py itself, or devise a new way to cache the tiles.

Hardware Info I am running the caching processes on 8 different PCs, one of which is an i7 with 32gb ram and another is an i3 with 4gb ram but they both give me almost the same caching speed (approximately 100k tiles per day)

Best Answer

I would say that for zoom greater than 15, if you split your area of interest into smaller areas(Bounding box), you will be able to cache them in much less time by running multiple processes on a single machine.

For example, you are running zoom 16 (having 50,000,00 tiles) on a machine and according to your average tile-caching speed, this process will complete in about 40-50 days. Lets say you split these tiles in to two and run them simultaneously on the machine then you will be able to cache them in 20-25 days because tilestache seeding process uses only about 30 percent of your processor for a single tile caching process and I know this because i have the same issue once and up to some extant this solved my problem.

It won't effect the tile-caching speed if you are running a single process on a machine or multiple processes but the CPU usage will be increased.

I hope this will help you.

Related Question