Why is the constructor of RouteResourse called on every request

I am running the routing engine web/service locally. Why is the constructor of com.graphhopper.resources.RouteResource called on every /route request? Is this how dropwizard or jersey works? I am not familiar with dropwizard.

Good question, I don’t know tbh. Do you think this is problematic?

@easbar I would expect a single instance of the RouteResource to be registered with jersey on server start up (or on first request) and used to serve requests for the live time of the server instance. Doing otherwise, I think, would waste resource. But again I am not familiar with how dropwizard/jersey work.

You can try it out and instantiate a single object of RouteResource and set this here: https://github.com/graphhopper/graphhopper/blob/51acef04023a33446adc75f1b9b36e495babb2cd/web-bundle/src/main/java/com/graphhopper/http/GraphHopperBundle.java#L282

But I highly doubt that this will make a measurable difference even under extreme load.

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