Changeset 526 for branches/reproxy-cache

Show
Ignore:
Timestamp:
08/18/06 22:38:22 (4 years ago)
Author:
bradfitz
Message:

stats and a bug fix

Location:
branches/reproxy-cache/lib/Perlbal
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/reproxy-cache/lib/Perlbal/ClientProxy.pm

    r523 r526  
    740740 
    741741    my $req_hd = $self->{req_headers}; 
    742     my $cache  = $self->{service}->{reproxy_cache}; 
     742    my $svc    = $self->{service}; 
     743    my $cache  = $svc->{reproxy_cache}; 
     744    $svc->{_stat_requests}++; 
    743745 
    744746    my $requri   = $req_hd->request_uri    || ''; 
     
    753755    return 0 if time() > $timeout; 
    754756 
     757    $svc->{_stat_cache_hits}++; 
    755758    my %headers = map { ref $_ eq 'SCALAR' ? $$_ : $_ } @{$headers || []}; 
    756759 
    757760    if (my $ims = $req_hd->header("If-Modified-Since")) { 
    758761        my ($lm_key) = grep { uc($_) eq "LAST-MODIFIED" } keys %headers; 
    759         my $lm = $headers->{$lm_key} || ""; 
     762        my $lm = $headers{$lm_key} || ""; 
    760763 
    761764        # remove the IE length suffix 
     
    765768        if ($ims eq $lm) { 
    766769            my $res_hd = Perlbal::HTTPHeaders->new_response(304); 
     770            $res_hd->header("Content-Length", "0"); 
    767771            $self->tcp_cork(1); 
    768772            $self->state('xfer_resp'); 
  • branches/reproxy-cache/lib/Perlbal/Service.pm

    r525 r526  
    9090            'error_retry_schedule',  # string of comma-separated seconds (full or partial) to delay between retries 
    9191            'latency',               # int: milliseconds of latency to add to request 
     92 
     93            # stats: 
     94            '_stat_requests',       # total requests to this service 
     95            '_stat_cache_hits',     # total requests to this service that were served via the reproxy-url cache 
    9296            ); 
    9397 
     
    13341338 
    13351339    $out->("SERVICE $self->{name}"); 
    1336     $out->("     listening: $self->{listen}"); 
     1340    $out->("     listening: " . ($self->{listen} || "--")); 
    13371341    $out->("          role: $self->{role}"); 
    13381342    if ($self->{role} eq "reverse_proxy" || 
     
    13481352    } 
    13491353    if ($self->{role} eq "reverse_proxy") { 
     1354        if ($self->{reproxy_cache}) { 
     1355            my $hits     = $self->{_stat_cache_hits} || 0; 
     1356            my $hit_rate = sprintf("%0.02f%%", eval { $hits / ($self->{_stat_requests} || 0) * 100 } || 0); 
     1357            $out->("    cache hits: $hits"); 
     1358            $out->("cache hit rate: $hit_rate"); 
     1359        } 
     1360 
    13501361        my $bored_count = scalar @{$self->{bored_backends}}; 
    13511362        $out->(" connect-ahead: $bored_count/$self->{connect_ahead}");