-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
HTTP connections - keep-alive / sessions #2056
Comments
It sounds like it takes some time for your connectionpool code to add/remove connections from the pool. |
Thank you danpat! That's very useful to know as it was driving me mad (I thought I wasn't establishing a session correctly). Sticking to the python framework would you able to recommend a way of issuing HTTP get requests? E.g. asyncio, requests-futures, gevent, grequests, threading, multiprocessing, etc. |
@iliakarmanov If you're aiming for maximum performance, you can skip the HTTP overhead and use https://github.com/Project-OSRM/osrm-backend/tree/develop/example although it is not multi-threaded, an each request is single-threaded. If that's not an option, then you'll just have to experiment with the various frameworks - whatever keeps your per-request overhead to a minimum. I suspect you'll get pretty good results with multiprocessing and a worker queue, but it depends on what work you need to do with each response. Each HTTP response should just take a few ms, (like, 4-10ms per request). |
To be honest I've never never touched C but if it's the case of perhaps just inserting from-to coordinates line-by-line (e.g. create the C script as a string in python) I may experiment. The example you posted is great; ideally I would have something with a loop that loops through all the OD pairs given but perhaps I can make something work with a bit of play! With your last part -> multiprocessing and a worker queue is similar to something I've tried (basically my first post, no?) and it was too fast for HTTP (I was running out of sockets). So I guess I can't make it too fast (assuming I'm using HTTP); however if I leave HTTP then I'm not limited by the lack of keep-alive. Does that sound about correct? Thanks again for all your help! |
@iliakarmanov if you are more comfortable with node try something like:
Note this example works with |
Thanks both for the suggestions. I am more comfortable with js. However, it would be nice to incorporate keep-alive in the future (if possible) |
|
For the record, @systemed asked on IRC for I started an experimental Casablanca integration here: https://github.com/daniel-j-h/libosrm-http-casablanca which is quite small and limited. As of writing this it only accepts route requests and only returns distance and duration as JSON. I haven't had the time and / or use-case to work on it more. What it already gives you is a high-performance concurrent HTTP server with keep-alive and all that on top of Maybe it helps as an example. |
I notice that when I submit HTTP requests to the graphhopper server I am able to get 2000 a second using a HTTPConnectionPool and multiprocessing in python. However, if I use the exact same code but connect to the OSRM server for some reason the requests per second become super slow (perhaps 10 a second):
I'm not too sure why this may be. If I don't use a connectionpool then I run out of ports as it's very fast and creates a new TCP connection for each request.
This leads me to believe it is something to do with the server-routing.exe
The text was updated successfully, but these errors were encountered: