« many website, one setup, many databases | Main | Starting a website from scratch - what technologies should I use? »

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.

Reader Comments (5)

Geographic load-balancing can be done at the proxy server level with">Nginx. There is an explanation starting on p. 21 of this document:

If you download Nginx from, check out the contrib/ 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.

November 29, 1990 | Unregistered CommenterEvan

You can also download IP files in CIDR format from
Updated daily by the way.

November 29, 1990 | Unregistered CommenterIP

Can you further breakdown the client IPs to like city,state or is it just at the country level ?

November 29, 1990 | Unregistered CommenterAnonymous

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.

November 29, 1990 | Unregistered Commenteracne treatment

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:

January 1, 2010 | Unregistered CommenterDanny Tuppeny

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>