Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Error: Gateway Timeout (HTTP 504) in RStudio #1573

Closed
1 task done
cacomixtla opened this issue Oct 18, 2023 · 6 comments · Fixed by #1607
Closed
1 task done

Getting Error: Gateway Timeout (HTTP 504) in RStudio #1573

cacomixtla opened this issue Oct 18, 2023 · 6 comments · Fixed by #1607

Comments

@cacomixtla
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Where did you encounter this issue?

live API

Request URL

https://openrouteservice.org/dev/#/api-docs/v2/isochrones

POST Request Body

library(openrouteservice)
library(mapview)
library(tidyverse)
library(osmdata)
library(sf)
library(paletteer)
library(ggfx)

ors_api_key("5b3ce3597851110001cf62488c30fb776efd4dbb9d3a08e42f286d7d")
coordinates <- data.frame(lon = c(-0.171201), lat = c(51.464290))

cj_iso <- ors_isochrones(locations = coordinates, profile = "foot-walking", range = 6000, interval = 600, output = "sf")

Response

Error: Gateway Timeout (HTTP 504).

Current behavior

I'm using RStudio and the ORS's API for mapping isochrones between a UK station and walking time. It seems alright until I try to give the isochrones a range and an interval, in this case 6000 and 600 in that order.

cj_iso <- ors_isochrones(locations = coordinates, profile = "foot-walking", range = 6000, interval = 600, output = "sf")

It takes several minutes and the result is this message from the terminal:

Error: Gateway Timeout (HTTP 504).

So I don't know what else to do.

It's important to say that I contacted support and changing the interval to 600 worked out just fine, but I really needed to try 600.
Sin título

Expected behavior

The expected is running the code just as it is, with visually the double of isochrones in map.
1
2

Openrouteservice Version

6.6.1

Build date

No response

Graph date

No response

Forum Topic Link

No response

@cacomixtla cacomixtla added api bug 🐞 Erroneous behavior of the backend labels Oct 18, 2023
@EricSamson-Tract
Copy link

Just wanted to tack on and say that I am also experiencing the same problem for requesting isochrones from python.

@aoles
Copy link
Member

aoles commented Oct 20, 2023

I can confirm that, apparently, there is a performance issue for intervals smaller than 1000. This is quite evident from the following example, where the query with an interval of 500 takes almost 50x longer than one with and interval of 1000. Please note that this phenomenon is not R-specific, but rather a problem with the backend.

library(openrouteservice)

coordinates <- data.frame(lon = c(-0.171201), lat = c(51.464290))
profile <- "foot-walking"
range <- 3000
intervals <- c(3000, 1500, 1000, 500, 300)

query_times <- sapply(intervals, function(interval) {
  res <- ors_isochrones(locations = coordinates, profile = profile, range = range, interval = interval)
  attr(res, "query_time")
})

query_times
#> [1]  0.607648  0.475013  0.396023 19.449573 27.922645
plot(intervals, query_times)

Created on 2023-10-20 with reprex v2.0.2

@aoles
Copy link
Member

aoles commented Oct 23, 2023

Some additional benchmarks comparing the performance of isochrone queries across algorithms and ORS versions.

  • black is ORS v6.8.3
  • red is ORS v8 RC
  • blue is ORS v8 RC fastisochrones
    image

The plot has been generated with the following script.

library(openrouteservice)

coordinates <- list(c(8.676312, 49.371756))
profile <- "foot-walking"
range <- 3000
intervals <- c(3000, 1500, 1000, 500, 300)
rep <- 7

query_times <- function(ors_url = NULL) {
  options(openrouteservice.url = ors_url)
  sapply(intervals, function(interval) {
    cl = as.call(c(ors_isochrones, list(locations = coordinates, profile = profile, range = range, interval = interval)))
    query_times = as.vector(replicate(rep, attr(eval(cl), "query_time")))
    median(query_times)
  })
}

query_times_v7 <- query_times()
query_times_v7_fast <- query_times("http://localhost:8082/ors")
query_times_v6 <- query_times("http://localhost:8083/ors")

yran <- range(c(query_times_v6, query_times_v7, query_times_v7_fast))

plot(intervals, query_times_v7, col = "red", ylim = yran, ylab = "Query times [s]")
points(intervals, query_times_v7_fast, col = "blue")
points(intervals, query_times_v6)

@aoles
Copy link
Member

aoles commented Oct 23, 2023

Dear @cacomixtla,

thanks a lot for reporting the issue and for your patience.

The timeout error message you observe is caused by some performance issues of the isochrones service. Basically, the query timeouts before the service is able to compute the result.

The ORS team will look into addressing this deficiency. In the meantime, you can circumvent the issue by querying for single ranges corresponding to the desired intervals and combining them into a single isochrone geometry like in the example below.

Hope this helps. Cheers!
Andrzej

library(openrouteservice)
library(mapview)

coordinates <- data.frame(lon = c(-0.171201), lat = c(51.464290))
profile <- "foot-walking"
range <- 6000
interval <- 600
ranges <- seq(from = interval, to = range, by = interval)

res <- lapply(ranges, function(range) ors_isochrones(locations = coordinates, profile = profile, range = range, output = "sf"))
isochrone <- do.call(rbind, res)
isochrone$center <- NULL # otherwise mapview complains  ¯\_(ツ)_/¯

mapview(isochrone, alpha.regions = 0.2, homebutton = FALSE, legend = FALSE)

Created on 2023-10-23 with reprex v2.0.2

@cacomixtla
Copy link
Author

cacomixtla commented Oct 23, 2023 via email

@aoles
Copy link
Member

aoles commented Nov 23, 2023

Thanks @cacomixtla for your patience!

As it turns out, some of the performance issues have been already addressed in #1508. This fix is now included in 7.1.1 release which will be rolled out to ORS public API soon. Maybe @rabidllama could provide you with some more details on the timeline.

Apart from that, we are investigating possible further improvements to isochrone query times in #1607, so stay tuned!

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Awaiting release
Development

Successfully merging a pull request may close this issue.

3 participants