GeoIP Question - Speed & efficiency

Maxim Dounin mdounin at mdounin.ru
Sat Aug 16 07:22:20 MSD 2008


Hello!

On Sat, Aug 16, 2008 at 07:43:45AM +0700, Chris Savery wrote:

> I am thinking of using the GeoIP module with input from the maxmind  
> database converted with the perl script as described through the link on  
> the nginx site.
>
> I'm curious if the country-ip pairs are managed efficiently so that the  
> lookup/conversion is very fast or not? That is, does the module do  
> something like sort the list and then use a binary tree  to quickly  
> locate the country? Is the whole thing loaded in memory?

Geo module builds in-memory radix tree when loading configs.  This 
is the same data structure as used in routing, and lookups are 
really fast.

> This country  
> database is quite huge and if this process happens on every hit or even  
> on only a selected entry page then it could be very slow. Does anyone  
> here have experience with this?

The only inconvinience of using really large geobases is config 
reading time.  My currently takes about 30 seconds to load - but 
that's for more than 30 Mb of data, and not only countries.

> For my purposes I only really need to detect continents for deciding if  
> visitors should pull from one of a few server locations. So presumably  
> it may be possible to combine many countries into larger blocks so that  
> there are fewer steps in the lookup. Any input on how speedy or  
> efficient this has shown to be would be super helpful here.

Aggregating blocks is good thinks to do if you don't need detailed 
information, but you'll hardly notice any difference.

Maxim Dounin





More information about the nginx mailing list