Osrm-backend: Traffic update scenario

Created on 14 Jun 2018  路  3Comments  路  Source: Project-OSRM/osrm-backend

I鈥檝e been looking through the issues and the wiki for this information. Could you provide an example scenario where osrm serves the api and the traffic info is updated on the backend (e.g. every 10 minutes)? Or does the osrm need to be stopped (i.d. not good for production)? Is there also a list where to get the raw data from (some known providers)?

Most helpful comment

You'll need to wait for osrm-datastore to complete before starting osrm-routed -s, but yes, that's basically the idea. Once osrm-routed -s is running, you can re-run:

./osrm-customize file.osrm --segment-speed-file newtraffic.csv
./osrm-datastore file.osrm

in a loop, and osrm-routed -s will pick up the new data seamlessly.

Note that depending on how your traffic data is structured, you may want to keep a "clean" copy of all the file.osrm* before you run osrm-customze - osrm-customize updates the files in-place, so if your traffic data is incomplete, you may end up with some edges retaining values from previous traffic updates when you'd prefer they revert to the Lua established values from osrm-extract.

All 3 comments

@zifeo You can support hot-swapping with OSRM in two ways:

  1. Use osrm-datastore to load the data into shared memory, start up osrm-routed -s which will use the already loaded data. Re-run osrm-datastore filename-new.osrm to load new data, osrm-routed will hot-swap to the new dataset without losing requests.

  2. You can start up multiple copies of osrm-routed running on the same port on Linux - we use the SO_REUSEPORT option, so you can start up a new osrm-routed with new data, and the kernel will load-balance between the two processes - you can then kill the old process gracefully with SIGHUP and no connections will be lost.

We use scenario (1) at Mapbox to support hot swapping global traffic datasets (our data isn't public unfortunately).

As far as data goes, I don't know of any public datasets, you'll have to make your own somehow.

Thanks for this amazing answer @danpat! To recap, we would have:

./osrm-extract file.osm -p profiles/car.lua
./osrm-partition file.osrm

# running before routed once, and then every x hours
./osrm-customize file.osrm --segment-speed-file traffic.csv
./osrm-datastore file.osrm

# launched in parallel
./osrm-routed -s 1 -a MLD

You'll need to wait for osrm-datastore to complete before starting osrm-routed -s, but yes, that's basically the idea. Once osrm-routed -s is running, you can re-run:

./osrm-customize file.osrm --segment-speed-file newtraffic.csv
./osrm-datastore file.osrm

in a loop, and osrm-routed -s will pick up the new data seamlessly.

Note that depending on how your traffic data is structured, you may want to keep a "clean" copy of all the file.osrm* before you run osrm-customze - osrm-customize updates the files in-place, so if your traffic data is incomplete, you may end up with some edges retaining values from previous traffic updates when you'd prefer they revert to the Lua established values from osrm-extract.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ifle picture ifle  路  5Comments

pat841 picture pat841  路  4Comments

grib0 picture grib0  路  4Comments

Oyabi picture Oyabi  路  5Comments

ryanbishop12 picture ryanbishop12  路  4Comments