Friday
Nov302007
Strategy: Efficiently Geo-referencing IPs

A lot of apps need to map IP addresses to locations. Jeremy Cole in On efficiently geo-referencing IPs with MaxMind GeoIP and MySQL GIS succinctly explains the many uses for such a feature:
Geo-referencing IPs is, in a nutshell, converting an IP address, perhaps from an incoming web visitor, a log file, a data file, or some other place, into the name of some entity owning that IP address. There are a lot of reasons you may want to geo-reference IP addresses to country, city, etc., such as in simple ad targeting systems, geographic load balancing, web analytics, and many more applications.
This is difficult to do efficiently, at least it gives me a bit of brain freeze. In the same post Jeremy nicely explains where to get the geo-rereferncing data, how to load data, and the performance of different approaches for IP address searching. It's a great practical introduction to the subject.
Geo-referencing IPs is, in a nutshell, converting an IP address, perhaps from an incoming web visitor, a log file, a data file, or some other place, into the name of some entity owning that IP address. There are a lot of reasons you may want to geo-reference IP addresses to country, city, etc., such as in simple ad targeting systems, geographic load balancing, web analytics, and many more applications.
This is difficult to do efficiently, at least it gives me a bit of brain freeze. In the same post Jeremy nicely explains where to get the geo-rereferncing data, how to load data, and the performance of different approaches for IP address searching. It's a great practical introduction to the subject.
Reader Comments (5)
Geographic load-balancing can be done at the proxy server level with http://highscalability.com/product-nginx">Nginx. There is an explanation starting on p. 21 of this document:
http://www.o3magazine.com/o3/issue6/o3-i6-72.pdf
If you download Nginx from http://nginx.net, check out the contrib/geo2nginx.pl script. It converts a GeoIP CSV to an Nginx configuration file.
This method is much more efficient than doing a DB computation for each page hit.
You can also download IP files in CIDR format from www.ipdeny.com
Updated daily by the way.
Can you further breakdown the client IPs to like city,state or is it just at the country level ?
In today's day and age, often developmental technology is driven by the marketplace. It is also driven by Quantum leaps in creativity of the developers, but this is usually initiated by need.
More and more, as competition increases online, there is a need to know the customer better. This translates to Analytics. And a core component of Analytics is Geo-targeting.
My forte is marketing, and this alone is reason enough to establish core technologies from companies providing Geo targeting IP information, and just as much reason for companies to develop advanced technologies and calculations based on those databases.
You don't need to host your own IP database (and maintain it). The Google Javascript loader contains lat/lon, town, county and country of your visitors. And because it's hosted by Google it's very fast, always up-to-date, and scales :-)
I wrote an article on my blog about how to use it:
http://blog.dantup.me.uk/2009/12/serving-different-content-based-on-a-users-location-geo-targeting