How to speed update Route operation

I have core 3.0 installed as service to provide route service in springboot application.

Graph loaded with below codes:

    hopper = new GraphHopper();
    hopper.setOSMFile(fileName);
    hopper.setGraphHopperLocation(graphPath);

// hopper.setEncodingManager(EncodingManager.create(“car”));

    hopper.setProfiles(
            Arrays.asList(
                    new Profile(GraphhopperConstant.PROFILE_STD)
                            .setVehicle(GraphhopperConstant.VEHICLE_CAR)
                            .setWeighting(RouteWeight.fastest),
                    new CustomProfile(GraphhopperConstant.PROFILE_CUSTOM)
                            .setCustomModel(new CustomModel())
                            .setVehicle(GraphhopperConstant.VEHICLE_CAR)
            )
    );
    hopper.getCHPreparationHandler().setCHProfiles(
            new CHProfile(GraphhopperConstant.VEHICLE_CAR)
    );

    hopper.getLMPreparationHandler().setLMProfiles(
            new LMProfile(GraphhopperConstant.PROFILE_CUSTOM)
    );

    hopper.importOrLoad();

then tried to route w and w/o custom model as:

    GHRequest req = new GHRequest(fromXY[1], fromXY[0], toXY[1], toXY[0])
            .setLocale(Locale.CHINA);

    if (Objects.isNull) {
        req.setProfile(GraphhopperConstant.PROFILE_STD);
    } else { 
        req.setProfile(GraphhopperConstant.PROFILE_CUSTOM).setCustomModel(customModel);
        req.getHints().putObject(Parameters.CH.DISABLE, true);
        req.getHints().putObject("instructions", false);
        req.getHints().putObject("calc_points", false);
    }

    GHResponse rsp = ghOsmService.getHopper().route(req);

We have tested the QPS for the route service. Results as below:

based on China map:

  1. with custom model: 50 QPS
  2. without custom model: 500 QPS

based on Monaco map:

  1. with custom model: 1400 QPS
  2. without custom model: 1600 QPS

while the performance is significant different with bigger and smaller maps.

So my question will be:
Is there any way to improve performance with bigger maps? eg, are we able to restrict the seach area per request to increase qps? As in most cases, we don’t need route across the contry but in cities, if we could define the seach area, is it possible to reduce the calculationt time?

Thanks!

1 Like

Did you only increase the map size (China instead of Monaco) or did you also use origins/destinations that were further apart? The map size can be significant for performance, but the distance between origin and destination is even more critical. It would not make sense to compare random queries across China with queries across Monaco for example. So a better experiment would be using a small map of some part of China (say one city) and then a bigger map of all of China, but only run the queries within the that city (the area of the small map). I would expect the performance difference to be much smaller than what you saw.

And do you even change the custom model per request? Otherwise you can just use CH for both your profiles and they should be equally fast.

You should also take a look at the runtime distribution of your requests. I assume there are some requests that are much slower than others?

GraphHopper has an option to limit the number of visited nodes per request: You can use something like max_visited_nodes=100 for your request or routing.max_visited_nodes: 100 in your server-side config and this will limit the number of visited nodes to 100. If the destination has not been found when the limit is reached you will get a ‘connection not found’ error.

The other thing you could try is landmark area splitting. This allows you to split your map into separate regions (you won’t be able to route from one to the other), but query speed could be faster. Or maybe all you need is increasing the number of landmarks (take a look at LMPreparationHandler)

Both map files are download and graph generated with same configuration.
As we can’t find a osm file per city for China, maybe I shall try to export from the openstreetmap.
We composed the request with similar distance from start and destination with similar custom model, block a polygon.
Will try as a smaller part and bigger map file with same city.

The service is not published yet, only one client during the test.

Will try this option. Hope we won’t get the error ‘connection not found’;

Thanks for you reply. Appreciated.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.