Posted on 2009-10-23 15:46:06-07 by davesnell
IP-Country efficiency questions
1. The description says: "With a random selection of 65,000 IP addresses, the module can look up over 15,000 IP addresses per second on a 730MHz PIII (Coppermine) and over 25,000 IP addresses per second on a 1.3GHz Athlon."

Is that within a single program? If so, suppose the program was used on a "one lookup per run" basis, e.g. as a web service called by a web page. Approximately how many IP addresses per second could it look up on such systems?



2. "Out of this random selection of IP addresses, 43% had an associated country code. Please let me know if you've run this against a set of 'real' IP addresses from your log files, and have details of the proportion of IPs that had associated country codes."

Can you update us on the success percentage when looking up real IP addresses?
Direct Responses: 11647 | Write a response
Posted on 2009-10-24 07:02:46-07 by nwetters in response to 11642
Re: IP-Country efficiency questions

The speed of IP::Country::Fast is dependent on your processor and version of Perl. To look up any IP address, it takes a maximum of 32 x substr and 32 x unpack, with a couple of concatenations and arithmetic ops. These are extremely fast operations, and the cost of that code is pretty much zero.

However, on the first call to IP::Country::Fast, the module reads a 320KB file into memory. On the first use, this will involve disk access, but on subsequent uses any modern operating system will have cached the file in memory.

As a web service, any overhead from the module will be dwarfed by other parts of the system.

IP::Country is deployed on some very large sites, mainly used for geographic redirection, but I know it's also used in SpamAssassin and log analysis software. The underlying database is also used in JavaInetAddressLocator, which is bundled with a couple of Java content-management systems.

I receive a couple of emails a year from people who ask why a particular address isn't included, and when I receive such an email, I figure it's time to release an update to the database. The country code data is very, very reliable, but I have no real data to back up this assertion as I haven't used IP::Country myself for over five years. It's now just something I update and other people use.

Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.