Closed bjarkeandersen closed 1 year ago
Hi @bjarkeandersen thanks for the idea!
I'm not familiar with gRPC so bear with me. It seems like it has two main advantages over HTTP:
Opentopodata spends 95+% of the time of a request either reading chunks from raster files, decompressing those chunks, and interpolating the elevation points. Because of this, any overhead from the network side of things are unlikely to have a noticeable impact on response time.
Streaming results is interesting though! The results for each raster file or file chunk could be streamed back as soon as they are calculated. Would this be something you'd use?
The biggest blocker here is that the webserver I'm using (uwsgi) doesn't have [good] support for gRPC, so supporting this would require a large rewrite of the application.
Are there other advantages I'm missing?
Also, I have some information here about increasing opentopodata performance. To summarise (and add some more):
max_locations_per_request
as much as possible, then put multiple locations in a single requestN_CPU
requests at a time and additional requests will be queued. So you can spin up a pool of size approx. N_CPU + 2
to keep the queue full.I wasn't familiar with gRPC until 2 days ago either, but from what I can see you're right about the advantages. I tried to build in support for gRPC in the python-files for OpenTopoData, but since I'm not that familiar with python and, as you mentioned, it's not straight forward with uwsgi, I opened this issue. We have a micro service made in c# that gets results from an instance of OpenTopoData running in Kubernetes. Another service is reading data from geonames and fetches elevations from the c# micro service through http requests.
I'll try experimenting with sending locations in batches and also using gRPC between the micro service and the service reading geodata from geonames. I'll keep you posted with the results.
Streaming sounds interesting and I'd love to test it, but I guess it will require a rather large rewrite of OpenTopoData to make it possible?
Yes, it would require a rewrite of most of the code, so isn't something that will be supported unfortunately. Still, thanks for teaching me about gRPC!
Would it be possible to build in support for gRPC? I'm building a location service that uses a lat,lon-coordinate to get the elevation from an opentopodata implementation. When importing updates of places we sometimes need to ask for elevation 100.000 times within a short duration. I'm wondering if using gRPC instead of http would speedup this process?