Slow rendering with base OSM-Bright style
Hi,
I've installed my own tileserver and imported the whole France to test (the goal being to serve the entire planet).
But the rendering is VERY VERY slow, like even for zoom 12 tiles it takes sometimes over than one minute to render (and I'm the only one on the server, so one minute to render a few zoom 12 tiles, it is really slow).
I really don't know why it takes so long, I've followed the instructions on switch2osm, the only difference being that I choosed to use the OSM-Bright theme, customized for my needs. But to be sure it wasn't my custom style which impacted the perfs, I've also tried with the original OSM-Bright and it is the same rendering time.
Here is my configuration:
- Intel Xeon E3-1245v2 (4c / 8t - 3,4GHz)
- 32GB DDR3 1333MHz
- SSD
- apache/mod_tile/postgresql running in docker container
I've imported the data with this osm2pgsql command:
osm2pgsql -d gis --create --slim -G --hstore --hstore-match-only -C 4000 --number-processes 8 -S custom.style --flat-nodes /path/to/flat_nodes.bin data.osm.pbf
But I've also tried without my custom style and without flat-nodes, it doesn't make any relevant difference.
While monitoring the server process and ram usage, I've noticed that it was postgresql and not renderd which was taking a long time, and using all process cores at there maximum (which make sense because from what I understood, the postgresql queries are the slowest part of the process).
Following the [small tutorial][1] of Paul Norman, I've logged theses queries, returning over and over (the log file is almost only composed of queries like theses ones):
SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext) FROM (SELECT ST_Extent(way) as ext from planet_osm_polygon) as tmp
SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext) FROM (SELECT ST_Extent(way) as ext from planet_osm_line) as tmp
With an average time of 1/2secs by queries, so it's probably what slows down the process.
For the record, I haven't enable update yet, so the only queries running are the ones I use for testing rendering. Also, I've tried multiple postgresql confs (following again Paul Newman and Frederik Ramm recommandations), but haven't noticed any big improvment (the time being actually around 1 minute for a zoom 12, I expect it to be closer to a second at this level, am I wrong?).
For higher zoom levels, it become faster (but still a bit slow I think):
- z16 : 1.5s
- z15 : 2.7s
- z14 : 6.2s
Does anybody have any idea of why even with the basic OSM-Bright style and this specs I'm facing this very slow rendering time? This SLOWWWW rendering time It doesn't make any sense to me...
Thanks!
[1]: http://www.paulnorman.ca/blog/2016/08/sampling-slow-postgres-queries/