Reputation: 13128
Forenote
This is a web application being written in PHP/etc
This will be a rather rhetorical question about the best practice/most effective way to go about this issue.
Basically, I've been handed a little task. With each post that gets posted to this app, it needs the geo information of the poster's IP address. The reason I asked this question is that this app has the potential to grow exponentially, very quickly and I don't want a silly bottleneck like this causing any issues.
I've thought of 2 possible options to handle getting the GEO Information (based off the IP Address) as below.
Example of the above being something like:
$ip = '127.0.0.1'; // derp
$url = "http://api.ipinfodb.com/v3/ip-city/?key=API_KEY&format=json&ip=". $ip; // or other api's, etc...
$info = file_get_contents($url); // or use curl etc..
$data = json_decode($info);
//....itterate through results of $data and use as required
Or would it be best
Example:
id | post_id | ip | lat | long | country | state | zip | .....etc
Or is there another way that you would do it / could do it? Open to any suggestions you have :)
Upvotes: 1
Views: 88
Reputation: 13128
To close this question off, I went with using RabbitMQ as zerkms stated in his comment.
Essentially wrapping it in a little bit of custom code and storing it as the following:
id | post_id | ip | lat | long | country | state
Upvotes: 1