Portal should refresh their configuration cache on expiration
We are making some benchmarks on LemonLDAP and we find a performance issue in the Portal when it checks the configuration cache. We use an OpenLDAP directory to store the configuration but it should be the same problem with other backends.
In Lemonldap::NG::Portal::SharedConf::getConf, the portal gets at each call from the backend all the configurations to get the number of the latest one. If the number is not the same as that in the localcache, it updates the shared hash %confCached. Unless, it uses the cache. This is a performance killer because a query is done on directory at each request and cache is not really usefull.
A simple ApacheBench gives 25 requests/s on the authentication and decrease when concurrency grows (we get some connections problems with OpenLDAP).
We modify this section like this and get 70 requests/s without OpenLDAP problems.
my $num = $self->__lmConf->lastCfg;
# Reload configuration
unless ( $confCached and $confCached->{cfgNum} == $num ) {
unless ($confCached) {
$self->lmLog( "Cached configuration too old, get configuration $num",
'debug' );
my $gConf = $self->__lmConf->getConf( { cfgNum => $num } );
my $gConf = $self->__lmConf->getConf();
my $lConf = $self->__lmConf->getLocalConf(PORTALSECTION);
unless ( ref($gConf) and ref($lConf) ) {
$self->abort( "Cannot get configuration",
$Lemonldap::NG::Common::Conf::msg );
}
%$confCached = ( %$gConf, %$lConf );
}
unless ($confCached) {
my $gConf = $self->__lmConf->getConf();
my $lConf = $self->__lmConf->getLocalConf(PORTALSECTION);
unless ( ref($gConf) and ref($lConf) ) {
$self->abort( "Cannot get configuration",
$Lemonldap::NG::Common::Conf::msg );
}
%$confCached = ( %$gConf, %$lConf );
}
Handlers have not this problem and refresh their configuration after expiration.