Decreasing Graphhoppers loading time

For my academic project, I need do routing in OSM on a Servlet that is deployed on a server. As I can’t store any soft state due to restrictions on the environment, I need to load the Graphhopper engine every time a new request comes in. I have currently changed Graphhopper so that rather than reading and writing the graph from files, read it from a database (Redis). However, still graphhopper takes around 350 milliseconds to fully load (~100ms to load the graph (Berlin Map)) when loading the graph (I’m not considering importing the graph from pbf files).

I was wondering how I could extract a minimal Graphhopper engine and speed up the process so that I could decrease the load time for each request.

What does ‘loading’ in your case mean? Copying the data from redis? Isn’t 100ms okay for a ~30MB file?

speed up the process so that I could decrease the load time for each request.

If the storage supports ‘memory mapping’ you can load instantly and kind of load on demand later on while routing. Otherwise when reading the whole graph you’ll always have some delay just for copying the data, at least that is my understanding. Also you can try to tweak the segment size and see if this improves the copying somehow (I fear: no)

1 Like

I acknowledge the time required to transfer the data, but other than the loading time, we still have other processes going on which increase the overall startup time. One way that I found that I could decrease this time was to use GraphHopper for Desktop rather than GraphHopper for Server (from 350 ms to 150 ms). Is there any other optimizations or speeds up (writing soft state to file rather than calculating it) that I could do to speed up this process?

Sorry, really no experience with your special use case. To find out the bottleneck just profile it :slight_smile:

One way that I found that I could decrease this time was to use GraphHopper for Desktop rather than GraphHopper for Server (from 350 ms to 150 ms)

So your time measurement is loading of the data plus routing? If yes, you could try to disable CH while import, so routing will be slower but the data itself is smaller too which could improve your timing for short routes.