Golang - Problem statement
At our eCommerce company we are using a mapping service, lets say google maps or open street maps for reverse geo location i.e from lat,lng of a user get his address. From his full address we are mainly using pin code, and not the actual address. So for us pincode is only important.
Since we are getting a huge amount of traffic we cannot always use maps api, as there is always a cost associated with calling the map api. So we need to start caching data.
Since we are operating in fixed amount cities, we can ideally build our own internal database of lat,lng to pincode mapping. This way we don't need to always call map api and we can reduce costs over time.
Proposed solution
1. Store lat, lng of user to his pincode in redis. [login to view URL]
2. Define a threshold, lets say 1km inside which we assume that pincode won't change.
3. When we want to rev geo code, we first check if we have pin code already available in redis cache and we simply show user pin code from our cache. Using this function [login to view URL]
See if you can build a service to implement this.
Also think of any edge cases which might break in the above solution, and any workarounds for the same
I have 2.6 yrs of experience specifically in golang. Worked with edtech, space tech and freelance projects. I used redis in all this projects. I will work on this project for FREE and will deliver project in time
Hi.
Basically you need nearest (based on haversine distance) pin-code match within a given radius. However, postgres + postgis might be a better fit this task for the simple reason that it is ACID compliant - chances of data loss are less. If the only reason to go with Redis/GeoSearch is speed, then why not save the data within the go process and use geo-go to to the calculation. It'll be atleast 2-3 times faster than redis.
I can even develop this in Rust - for an even more performance microservice.
Let me know if you're interested.
Thanks
Looks like a interesting project to solve. Is this an interview question? Looks like the same. I would love to complete the same for you in 2 days. how does that sound like? Also would be happy to mentor you about the code. :)