geoip is garbage under load

E

elia Mazzawi

i wrote this perl handler, it uses apache, mod_perl and geoip.

The handler uses geoip to to resolve the same ip with every apache
request to that handler. when geoip returns an unexpected result a
warning is logged in apache's error log.
geoip returns garbage and sometimes inconsistent results. this starts
and become more frequent as the load on the server increases and does
not happen under low load.
we were able to replicate the problem by hammering a server from 20
boxes using apache ab. apache was running with 50 or so processes.

an i doing something wrong or does geoip mess up under load

use strict;
use Geo::IP qw(GEOIP_STANDARD);

my $GC = Geo::IP->open("/opt/viper-2.0/lib/Viper/Geo/GeoIPCity-133.dat",
GEOIP_STANDARD );
my $GISP = Geo::IP->open("/opt/viper-2.0/lib/Viper/Geo/GeoIPISP-122.dat",
GEOIP_STANDARD );

my ( $RemoteAddr, $GeoRecord, $ISP, $country, $city, $state,
$postalCode, $areaCode);
my ( $lastISP, $lastcountry, $lastcity, $laststate, $lastpostalCode,
$lastareaCode) = ('Comspec Communications Inc', 'CA', 'Toronto', 'ON',
'm6b1p5' , 0);

sub handler {

#look up IP in geoIP
$RemoteAddr = '192.139.80.'. int(rand(255));
$GeoRecord = $GC->record_by_name($RemoteAddr);
$ISP = $GISP->org_by_name($RemoteAddr);
if ( $lastISP ne $ISP ){
warn "$ISP ne $lastISP\n";
}
if ($GeoRecord) {
$country = $GeoRecord->country_code;
if ( $lastcountry ne $country){
warn "$lastcountry ne $country\n";
}
$city = $GeoRecord->city;
if ($lastcity ne $city){
warn "$lastcity ne $city\n";
}
$state = $GeoRecord->region;
if ($laststate ne $state){
warn "$laststate ne $state\n";
}
$postalCode = $GeoRecord->postal_code;
if ($lastpostalCode ne $postalCode){
warn "$lastpostalCode ne $postalCode\n";
}
$areaCode = $GeoRecord->area_code;
if ($lastareaCode ne $areaCode){
warn "$lastareaCode ne $areaCode\n";
}
}
return 200;
}
1;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,420
Latest member
ZitaVos505

Latest Threads

Top