ORS on premise with Docker taking forever

Hello,

I am running Open Route Service on premise with Docker on a Google Cloud Console VM. I am using it to calculate bike routes according to four profiles (cycling-regular, cycling-mountain, cycling-electric and cycling-road). I am using the OSM data for all of Europe which means I had to allocate a lot of ressources to the VM : 80 vCPUs with a total memory of 320Go.

Everything works but for some reason the results are way slower to show up than with the ORS API. For example, with a bike trip across France which computes almost instantly with the ORS API it takes more than 10 seconds when I send the exact same request to the VM. There is no spike in the CPU or Memory usage so that does not seem to be the limit.

Here is the ors-config.json, let me know if you need anything else and thank you very much for your help !

{
  "ors": {
    "info": {
      "base_url": "https://openrouteservice.org/",
      "swagger_documentation_url": "https://api.openrouteservice.org/",
      "support_mail": "support@openrouteservice.org",
      "author_tag": "openrouteservice",
      "content_licence": "LGPL 3.0"
    },
    "services": {
      "matrix": {
        "enabled": true,
        "maximum_routes": 100,
        "maximum_routes_flexible": 25,
        "maximum_search_radius": 5000,
        "maximum_visited_nodes": 100000,
        "allow_resolve_locations": true,
        "attribution": "openrouteservice.org, OpenStreetMap contributors"
      },
      "isochrones": {
        "enabled": true,
        "maximum_range_distance": [
          {
            "profiles": "any",
            "value": 50000
          },
          {
            "profiles": "driving-car, driving-hgv",
            "value": 100000
          }
        ],
        "maximum_range_time": [
          {
            "profiles": "any",
            "value": 18000
          },
          {
            "profiles": "driving-car, driving-hgv",
            "value": 3600
          }
        ],
        "fastisochrones": {
          "maximum_range_distance": [
            {
              "profiles": "any",
              "value": 50000
            },
            {
              "profiles": "driving-car, driving-hgv",
              "value": 500000
            }
          ],
          "maximum_range_time": [
            {
              "profiles": "any",
              "value": 18000
            },
            {
              "profiles": "driving-car, driving-hgv",
              "value": 10800
            }
          ],
          "profiles": {
            "default_params": {
              "enabled": false,
              "threads": 12,
              "weightings": "recommended",
              "maxcellnodes": 5000
            },
            "hgv": {
              "enabled": false,
              "threads": 12,
              "weightings": "recommended, shortest",
              "maxcellnodes": 5000
            }
          }
        },
        "maximum_intervals": 10,
        "maximum_locations": 2,
        "allow_compute_area": true
      },
      "routing": {
        "enabled": true,
        "mode": "normal",
        "routing_description": "This is a routing file from openrouteservice",
        "routing_name": "openrouteservice routing",
        "sources": [
          "/home/ors/ors-core/data/osm_file.pbf"
        ],
        "init_threads": 16,
        "attribution": "openrouteservice.org, OpenStreetMap contributors",
        "elevation_preprocessed": false,
        "profiles": {
          "active": [
            "bike-regular",
	    "bike-mountain",
	    "bike-road",
	    "bike-electric"
          ],
          "default_params": {
            "encoder_flags_size": 8,
            "graphs_root_path": "/home/ors/ors-core/data/graphs",
            "elevation_provider": "multi",
            "elevation_cache_path": "/home/ors/ors-core/data/elevation_cache",
            "elevation_cache_clear": false,
            "instructions": true,
            "maximum_distance": 10000000,
            "maximum_distance_dynamic_weights": 10000000,
            "maximum_distance_avoid_areas": 10000000,
            "maximum_waypoints": 500,
            "maximum_snapping_radius": 400,
            "maximum_avoid_polygon_area": 20000000000,
            "maximum_avoid_polygon_extent": 2000000,
            "maximum_distance_alternative_routes": 10000000,
            "maximum_alternative_routes": 3,
            "maximum_distance_round_trip_routes": 10000000,
            "maximum_speed_lower_bound": 80,
            "preparation": {
              "min_network_size": 200,
              "min_one_way_network_size": 200,
              "methods": {
                "lm": {
                  "enabled": true,
                  "threads": 1,
                  "weightings": "recommended,shortest",
                  "landmarks": 16
                }
              }
            },
            "execution": {
              "methods": {
                "lm": {
                  "active_landmarks": 8
                }
              }
            }
          },
          "profile-car": {
            "profiles": "driving-car",
            "parameters": {
              "encoder_flags_size": 8,
              "encoder_options": "turn_costs=true|block_fords=false|use_acceleration=true",
              "maximum_distance": 100000,
              "elevation": true,
              "maximum_snapping_radius": 350,
              "preparation": {
                "min_network_size": 200,
                "min_one_way_network_size": 200,
                "methods": {
                  "ch": {
                    "enabled": true,
                    "threads": 1,
                    "weightings": "fastest"
                  },
                  "lm": {
                    "enabled": false,
                    "threads": 1,
                    "weightings": "fastest,shortest",
                    "landmarks": 16
                  },
                  "core": {
                    "enabled": true,
                    "threads": 1,
                    "weightings": "fastest,shortest",
                    "landmarks": 64,
                    "lmsets": "highways;allow_all"
                  }
                }
              },
              "execution": {
                "methods": {
                  "lm": {
                    "active_landmarks": 6
                  },
                  "core": {
                    "disabling_allowed": true,
                    "active_landmarks": 6
                  }
                }
              },
              "ext_storages": {
                "WayCategory": {},
                "HeavyVehicle": {},
                "WaySurfaceType": {},
                "RoadAccessRestrictions": {
                  "use_for_warnings": true
                }
              }
            }
          },
          "profile-hgv": {
            "profiles": "driving-hgv",
            "parameters": {
              "encoder_flags_size": 8,
              "encoder_options": "turn_costs=true|block_fords=false|use_acceleration=true",
              "maximum_distance": 100000,
              "elevation": true,
              "preparation": {
                "min_network_size": 200,
                "min_one_way_network_size": 200,
                "methods": {
                  "ch": {
                    "enabled": true,
                    "threads": 1,
                    "weightings": "recommended"
                  },
                  "core": {
                    "enabled": true,
                    "threads": 1,
                    "weightings": "recommended,shortest",
                    "landmarks": 64,
                    "lmsets": "highways;allow_all"
                  }
                }
              },
              "execution": {
                "methods": {
                  "core": {
                    "disabling_allowed": true,
                    "active_landmarks": 6
                  }
                }
              },
              "ext_storages": {
                "WayCategory": {},
                "HeavyVehicle": {
                  "restrictions": true
                },
                "WaySurfaceType": {}
              }
            }
          },
          "profile-bike-regular": {
            "profiles": "cycling-regular",
            "parameters": {
              "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
              "elevation": true,
              "ext_storages": {
                "WayCategory": {},
                "WaySurfaceType": {},
                "HillIndex": {},
                "TrailDifficulty": {}
              }
            }
          },
          "profile-bike-mountain": {
            "profiles": "cycling-mountain",
            "parameters": {
              "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
              "elevation": true,
              "ext_storages": {
                "WayCategory": {},
                "WaySurfaceType": {},
                "HillIndex": {},
                "TrailDifficulty": {}
              }
            }
          },
          "profile-bike-road": {
            "profiles": "cycling-road",
            "parameters": {
              "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
              "elevation": true,
              "ext_storages": {
                "WayCategory": {},
                "WaySurfaceType": {},
                "HillIndex": {},
                "TrailDifficulty": {}
              }
            }
          },
          "profile-bike-electric": {
            "profiles": "cycling-electric",
            "parameters": {
              "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
              "elevation": true,
              "ext_storages": {
                "WayCategory": {},
                "WaySurfaceType": {},
                "HillIndex": {},
                "TrailDifficulty": {}
              }
            }
          },
          "profile-walking": {
            "profiles": "foot-walking",
            "parameters": {
              "encoder_options": "block_fords=false",
              "elevation": true,
              "ext_storages": {
                "WayCategory": {},
                "WaySurfaceType": {},
                "HillIndex": {},
                "TrailDifficulty": {}
              }
            }
          },
          "profile-hiking": {
            "profiles": "foot-hiking",
            "parameters": {
              "encoder_options": "block_fords=false",
              "elevation": true,
              "ext_storages": {
                "WayCategory": {},
                "WaySurfaceType": {},
                "HillIndex": {},
                "TrailDifficulty": {}
              }
            }
          },
          "profile-wheelchair": {
            "profiles": "wheelchair",
            "parameters": {
              "encoder_options": "block_fords=true",
              "elevation": true,
              "maximum_snapping_radius": 50,
              "ext_storages": {
                "WayCategory": {},
                "WaySurfaceType": {},
                "Wheelchair": {
                  "KerbsOnCrossings": "true"
                },
                "OsmId": {}
              }
            }
          }
        }
      }
    },
    "logging": {
      "enabled": true,
      "level_file": "DEBUG_LOGGING.json",
      "location": "/home/ors/ors-core/logs/ors",
      "stdout": true
    },
    "system_message": [
      {
        "active": false,
        "text": "This message would be sent with every routing bike fastest request",
        "condition": {
          "request_service": "routing",
          "request_profile": "cycling-regular,cycling-mountain,cycling-road,cycling-electric",
          "request_preference": "fastest"
        }
      },
      {
        "active": false,
        "text": "This message would be sent with every request for geojson response",
        "condition": {
          "api_format": "geojson"
        }
      },
      {
        "active": false,
        "text": "This message would be sent with every request on API v1 from January 2020 until June 2050",
        "condition": {
          "api_version": 1,
          "time_after": "2020-01-01T00:00:00Z",
          "time_before": "2050-06-01T00:00:00Z"
        }
      },
      {
        "active": false,
        "text": "This message would be sent with every request"
      }
    ]
  }
}

If this helps I do not have the problem on small routes. It is only when they go over around 500kms that it starts to be very slow. Any ideas on what could cause this ?

Hi @Augustin_Gervaise,

looking at your configuration, you are only using the basic Dijkstra routing, which takes much longer as routes get longer.

If you update the cycling profiles to be like the following, it will then use the algorithms that are designed to be much faster for longer distances, but at the expense of not taking into account turn restrictions.

"profile-bike-regular": {
    "profiles": "cycling-regular",
    "parameters": {
        "encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
        "elevation": true,
        "preparation": {
            "min_network_size": 200,
            "min_one_way_network_size": 200,
            "methods": {
                "ch": {
                    "enabled": true,
                    "threads": 8,
                    "weightings": "recommended"
                },
                "lm": {
                    "enabled": true,
                    "threads": 8,
                    "weightings": "recommended",
                    "landmarks": 8
                },
                "core": {
                    "enabled": true,
                    "threads": 8,
                    "weightings": "recommended,shortest",
                    "landmarks": 32
                }
            }
        },
        "execution": {
            "methods": {
                "astar": {
                    "approximation": "BeelineSimplification",
                    "epsilon": 1
                },
                "ch": {
                    "disabling_allowed": true
                },
                "lm": {
                    "disabling_allowed": true,
                    "active_landmarks": 6
                },
                "core": {
                    "disabling_allowed": true,
                    "active_landmarks": 6
                }
            }
        },
        "ext_storages": {
           "WayCategory": {},
           "WaySurfaceType": {},
           "HillIndex": {},
           "TrailDifficulty": {}
        }
    }
}

Please be aware though, doing these will increase the amount of RAM needed and the amount of time needed for building graphs.

Thank you very much for your answer. Is this what you do on the ORS API ? I really like the way it works on the ORS API with pretty much instant results. Would it be possible to replicate the same configuration on premise ?

Yes, basically we have the optimisations enabled as much as we can. CH and core are the ones that make route generation really quick, but it does increase the requirements (RAM, storage and build time) so whether you use them really depends on what the focus is and what resources you have. Building with all of the optimisations in place easily doubles the amount of time and resources needed.

Ok thank you very much ! I am going to try it that way :ok_hand:

1 Like