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;
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;