开发者_运维问答
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this questionI am writing small geolocation service: then user come to my site I should to set his town from his IP-address. Now I found three way to solve this problem:
- Create from PHP connection to MySql DB and select town from it.
- From PHP go to cgi script (perl,c ?) and select town from file with towns and IP-addrs.
- Use services like http://ipinfodb.com/ip_location_api.php and get town from it.
But what way would be fastest? Minimal time etc?
Thanks!
3.
Primarily because of just how much data you'd have to manually compile together to do either 1 or 2.
There is no easy answer to it because a lot depends on unknown factors such as:
- Speed of your MySQL DB
- Speed of your php inplementation and size of the file
- Speed of the location_api service
In other words, there are only two ways to find out the answer:
- build them all and test
- gather all parameters (speeds, bandwidth, concurrent users of all systems) and calculate/guesstimate.
I've used the MaxMind database for country-level lookup from PHP (there is example code for other languages). The downloadable database is in a binary format optimised for speed of reading - although I've not compared it to a import into Mysql and searching with SQL, I have no doubt of Maxmind when they say it would be faster to use the API and original data rather than via another means, like SQL.
精彩评论