Created
July 17, 2012 19:16
-
-
Save drsnyder/3131372 to your computer and use it in GitHub Desktop.
Simplistic estimate of varnish cache size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
my %object_map = {}; | |
while (my $line = <>) { | |
if ($line =~ /.*?"GET (.*) HTTP\/\d\.\d" \d+ (\d+).*HIT/) { | |
my $url = $1; | |
my $size = $2; | |
$object_map{$url}{'size'} = $size; | |
$object_map{$url}{'count'}++; | |
#printf("Url: %s (%d)\n", $url, $size); | |
} | |
} | |
my $total = 0; | |
my $count = 0; | |
foreach my $key (keys %object_map) { | |
if ($object_map{$key}{'count'} > 1) { | |
$total += $object_map{$key}{'size'}; | |
$count++; | |
} | |
} | |
printf("The total size of object requested: %2.2f MB\n", $total / 1048576); | |
printf("The total number of objects: %d\n", $count); | |
printf("The average size: %2.2fb\n", ($total / $count)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment