Skip to content

faster 'big data' routing e.g. where only distance/time is needed #904

Closed

Description

@kodonnell

I see a few key use cases where only distance/time are needed and not the actual route:

  • data analytics/science (my field of work) - we often do things like 'how far is the customer from a store' or 'how far apart are customer's transactions', etc.
  • isochrones where all you care about is the distance/time of travel from a given point
  • map matching - while creating transition probabilities one needs the (routed) distance between two points. (And e.g. if you've got 1000 well-separated points on your GPX track, and we assume, say, 5 candidates per point, then that's approximately 25k routing requests.)

Obviously, none of this is really a problem when dealing with individual small data sets. However, we often deal with millions (and now billions) of streaming rows that we could route, and speed becomes of the essence. I'm not sure if there's any 'big data' offering for routing.

This issue is more of a discussion of the use cases - but we may decide they're not relevant. I've also got a few ideas for solutions, which we can evaluate. (I've decided to make it an issue as opposed to discuss elsewhere, as this way it can be referred to later, even if we close it.)

So, can you offer your thoughts on a) whether you think it's something graphhopper could/should include and, if so, b) your comments on the use cases/solutions (and any others).

Possible solution 1

@karussell has suggested we could simply retrieve the distance/time directly and avoid calling extractPath. This might give us some speedup. In addition, there are probably other faster algorithms we can use, etc. - but, as below, they may still be too slow (and a lot slower than an array lookup in a distance matrix).

Possible solution 2

This is the fun one = ) Ours is a specific use case where we're doing trillions of routing requests - so even though things are already very fast per route (we're using DijkstraOneToMany - possibly incorrectly), they won't be fast enough to keep up with real-time data feeds unless we throw mountains of resource at them. So I'm currently working on a distance-matrix solution, the idea being do a lot of pre-processing to speed up our eventual routing. This has a few steps:

  • precompute the distance from every node in the country (230k nodes in this case) to every other node. DijkstraOneToMany is awesome (!), so this part is easy and only takes six hours or so.
  • fitting it in memory is a problem - storing as shorts would be about 100Gb, which we'd prefer to avoid. There are other options (e.g. memory mapping), but we're currently working on compressing each row of the matrix in memory. (We take advantage of the fact that we can have an upper limit of say 50km on our routes, which means most of the entries are zero, and hence a naive and fast count-based compression should be sufficient.) The decompressing for access should (still need to get it working) be relatively unimportant as in our case we can structure things to do multiple (sequential) queries on a single row.
  • actually routing - I'm yet to implement this, but it will just be handling the case of correctly getting the final route length from two possibly virtual nodes (shouldn't be too hard).

I don't think it'd be too hard to make this into a new routing algorithm. I suspect it'll only be relevant to 'big data' or analytics users, or (possibly) those needing very high throughput. I'm not sure, but I suspect it could become a relatively general solution as I think most countries could be loaded into a distance matrix this way, depending on the amount of RAM available (and many such users will have a lot), the max distance cutoff, and the compression algorithm used.

That all said - it may be too specific, and it'd mean adding something that needs to be supported. On the other hand, it's actually pretty simple as there's not really any routing going on - the main considerations are RAM.

Possible solution 3

Using a distributed processing framework like Spark which e.g. could allow you to have a thousand GH instances routing on different CPUs/nodes. Many 'big data' users will be using Spark (and the number appears to be growing), so this seems like a solid option. In addition, it's also not limited to just distance/time outputs - it's the full graphhopper functionality. As an aside, we've managed to get it working in Spark, though it's pretty messy.

The 'spark-graphhopper' would probably be done in a separate repo as a spark plugin, and just as a wrapper around the graphhopper core. However there could be some tweaks to the core to make it a lot easier.

Activity

  1. changed the title [-]feature request/use case: faster 'big data' routing (where only distance/time is needed)[/-] [+]faster 'big data' routing e.g. where only distance/time is needed[/+] on May 30, 2017
  2. romulogoncalves commented on Aug 13, 2018

    @romulogoncalves

    A 'spark-graphhopper' plugin would be very welcomed.

  3. karussell commented on Aug 13, 2018

    @karussell
    Member

    You are welcome to contribute this. But I think we won't include it here, still we can easily link from here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions