[英]storing ip address or geo data for it
Forenote Forenote
This is a web application being written in PHP/etc 这是一个用PHP / etc编写的Web应用程序
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. 在每条发布到此应用程序的帖子中,它都需要海报IP地址的地理位置信息。 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. 我想到了以下两种可能的方法来处理获取GEO信息( 基于IP地址 )。
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 :) 欢迎您提出任何建议:)
To close this question off, I went with using RabbitMQ as zerkms stated in his comment . 为了解决这个问题,我按照zerkms 在他的评论中所述使用RabbitMQ 。
Essentially wrapping it in a little bit of custom code and storing it as the following: 本质上,将其包装在一些自定义代码中,并将其存储如下:
id | post_id | ip | lat | long | country | state
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.