-1

If I have a Database of 50,000 users with there address and every time a new user is created the want to see who are the top 10 closes users by driving distance.

Google starts charging 50 cents for 1000 requests. I'm looking a better may to do this that would limit my costs.

Also is there a better way then having to run the API against all 50,000 users every time a new user is added?

1 Answers1

0

At first you may select closest users by the direct distance. You don't need paid functionality for that. Let's say 20 would be enough bacause it's very unlikely that so many addresses will be the closest by distance but farther by driving route than others.

In that case you need only 20 requests to check the users closest by route.

Reni
  • 192
  • 9
  • thanks what api would i use for distance that does not charge? – Avraham Lichaa Nov 30 '17 at 03:12
  • actually you don't need an API for that, only maths you could program yourself or re-use someone else's solution. There is an answer and some advices [in this SO question](https://stackoverflow.com/questions/1502590/calculate-distance-between-two-points-in-google-maps-v3) – Reni Dec 19 '17 at 08:33
  • That would only work for direct distance I need driving distance – Avraham Lichaa Dec 20 '17 at 15:00
  • As I've described in my answer above you need to find closest users by direct distance as first step and then you may use google API to find closest by driving route among the 20 addresses selected on the 1st step. In such case you will need only 20 requests to google API per new user. – Reni Dec 21 '17 at 08:30
  • that's still 1million requests and as my database grows it will be more costly and further way to reduce this? – Avraham Lichaa Jan 06 '22 at 06:29