addok icon indicating copy to clipboard operation
addok copied to clipboard

Too long process if longitude coordinate value is very large

Open Jrmy-Msn opened this issue 4 years ago • 1 comments

Lately, our machine hosting addok was increasing in memory and CPU load with the need to restart it.

After investigation, many requests of the type GET /reverse?lon=2081535055002022&lat=48.078102 were sent to our server.

It turns out that during a "reverse" the longitude and latitude are transformed into a character string with the instruction (via the geohash library) to re-center the longitude between [-180; 180].

However, the value provided in the request for the longitude is of the order of 10 ^ 15 ... which generates a very very long processing of addok. This processing, multiplied by the number of requests, brings down the machine.

Wouldn't it be possible to do a check before encoding the coordinates?

exemple : core.py (line ~ 320)

        if lon > 360 * 5 or lon < -360 * 5:
            raise Exception("Encoding coordinates take too long")
        geoh = geohash.encode(lat, lon, config.GEOHASH_PRECISION)

cordially

Jrmy-Msn avatar Mar 24 '21 14:03 Jrmy-Msn

fixed by https://github.com/addok/addok/commit/aae1fbc985b6efe2b13bffa530c81de71794ef57

cquest avatar May 06 '21 07:05 cquest