Mod tile

From OpenStreetMap Wiki
Jump to: navigation, search

Mod tile is a system to serve raster tiles for example to use within a slippy map. It provides a dynamic combination of efficient caching and on the fly rendering. Due to its dynamic rendering, only a small fraction of overall tiles need to be kept on disk, reducing the resources required. At the same time, its caching strategy allows for a high performance serving and can support several thousand requests per second.

Mod_tile was originally written for serving the tiles of the main OSM map (Mapnik layer), but since is being used on a variety of different servers providing maps ontop of OpenStreetMap data.


Contents

Implementation

The code is split into two parts:

Features provided by mod_tile

Installation:

Installing a tile server based on mod_tile requires a number of steps, some of which can be skipped depending on your needs:

TODO: Please expand the installation instructions

Mapnik rendering toolchain

Although not strictly necessary, nearly all installations of mod_tile use a rendering backend based on Mapnik. Therefore it is necessary to install it first and populate the PostGIS database with data first using osm2pgsql.

mod_tile

build and install the mod_tile apache module from source. If you use debian you can add this line in your source.list :

 deb http://repository.azae.net/debian/squeeze/ squeeze main

and install : libapache2-mod-tile and renderd


renderd

tile expiry

After rendering a tile, it gets cached on disk for fast serving. As OSM data is constantly updated, improved and changed, a mechanism is needed to correctly expire the cache to ensure updated tiles get re-rendered.

There are several possible mechanisms available for expiring and updating tiles (either through mod_tile or by directly re-rendering cached tiles), of which often a combination is used:

mod_tiles expiry works by comparing the time stamp of rendered tiles to the date of the last full data import into the database.

If the planet time stamp is updated, all tiles are automatically marked as in need for re-rendering (dirty) and will be submitted to the rendering backend on next visit.

For the diff-based updates of the database, expiring all tiles would be too costly, and so only those tiles for which the data was updated get expired by altering the time stamp of those tiles to date far in the past. Again there are two different scripts for doing this. One ruby script and one based on output from osm2pgsql.

Alternatively, there are a number of helper utilities that can directly talk to renderd or tirex, submitting tiles for rerendering. This is often used to re-render low-zoom tiles on a periodical basis in the background, as it would be too costly to update them through the normal diff-based expiry.

See also for more details: Tile expire methods.

HowTos

There are a number of HowTo's available to set up a tile server based upon mod_tile.

Configuration

Most config can be done in the apache config and in /etc/renderd.conf

Some special options like MAX_ZOOM can only be set on complile time in render_config.h

You will likely need to do some more preparation to load the data for rendering in mapnik.

The style sheet also needs adjusting

Testing and debugging installation

After installation and configuration, it is important to test that everything is working.

Here is a list of some of the common mistakes and problems and how to detect them:

Additional help in trouble shooting might be found in the general help system of OSM

Source code

The code is in SVN at applications/utils/mod_tile, the readme.txt file contains other important information which you should read before trying to use this code.

Use svn co http://svn.openstreetmap.org/applications/utils/mod_tile/

Bug reports and feature requests

Mod_tile has been running stable on the OSM main page and many other sites for quite some time now with little trouble. It should thus be very stable and robust. Nevertheless, as will all software, it can have bugs. If you find any problems or instability using mod_tile, please report it on our bug tacker so that any remaining issues can be fixed:

Search for mod_tile tickets on trac

Do 'login' and 'new ticket'. Set the 'component' as 'mapnik' but mention 'mod_tile' in the description. In trac you can also report feature requests, however as always, there is no guarantee that any of the feature requests will get picked up.

Alternatively some issues and enhancements are listed below

TODO


The current code has been running with few problems now for over a year but there are always some things which could be improved...

Update: REQUEST_TIMEOUT, MAX_LOAD_OLD, MAX_LOAD_MISSING, and RENDER_SOCKET can now be set in Apache Config with ModTileRequestTimeout, ModTileMaxLoadOld, ModTileMaxLoadMissing, and ModTileRenderdSocketName. Update: socket name, number of threads, and some mapnik parameters can now be set in renderd.conf.

More ideas

The current server is managing to keep up fairly well with the rendering load. In Feb 2008 the server can re-render all the present tiles within the 7 day window between planet updates. It should take less than 14 days for any new data to appear on the map tiles (up to 7 days for the next planet dump and then up to 7 days for all the tiles to be re-rendered). Often it will be less, e.g. data added on Tuesday will often appear on the map on Thursday.

TIPS

Unless specified, the configuration is read from the file /etc/renderd.conf installed with 'make install'

Personal tools
Namespaces
Variants
Actions
site
Toolbox