Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The "BenchmarkingSolr" page has been changed by ShawnHeisey. http://wiki.apache.org/solr/BenchmarkingSolr?action=diff&rev1=4&rev2=5 -------------------------------------------------- = Benchmarking Solr = == Perl script (originally by ShawnHeisey) == - It's not very polished. Requires the Time::HiRes, Statistics::Descriptive, IO::Handle, and LWP::Simple Perl modules. As written, it will not work on Windows. If you wish to include the time required to write the query results to disk, there are some lines commented, just uncomment them. Although it does provide an average request time, I believe the median, 95th percentile, and 99th percentile values it outputs are more useful. The "if length $outputDir" tests on the rm lines are intentional to avoid erasing everything in the root directory if that variable somehow gets unset. + It's not very polished. It will not work on Windows as written, not sure if fork() will work right on Windows anyway. Requires the URI::Escape, Time::Hi``Res, Statistics::Descriptive, IO::Handle, and LWP::Simple Perl modules. + + The first part of the script has a number of options that you will probably need to change for your environment. From what gets output, the median, 95th percentile, and 99th percentile values seem to be the most useful. {{{#!ignoreme #!/usr/bin/perl @@ -18, +20 @@ my $urlPort = "8983"; my $urlCore = "live/"; # set to "" to not use a core my $urlOptions = "rows=50&fl=score,*"; + my $uriEscape = 1; # Enable if queries are not already URI escaped + my $writeResponses = 0; # Enable to write responses to disk #---- end config ---- use strict; + use URI::Escape; use warnings qw(all); use Time::HiRes qw ( time alarm sleep ); use Statistics::Descriptive; @@ -30, +35 @@ my %kids; my $pid; my $i; - #my $j = 0; + my $j = 0; my $r; my $query; my @queries; @@ -49, +54 @@ ### Main routine ### - #mkdir "$outputDir/result"; + mkdir $outputDir; + mkdir "$outputDir/result" if $writeResponses; + # The length test ensures that we don't clobber the root filesystem. system "rm -f $outputDir/* 2> /dev/null" if length $outputDir; - #system "rm -f $outputDir/result/* 2> /dev/null" if length $outputDir; + system "rm -f $outputDir/result/* 2> /dev/null" if length $outputDir + and $writeResponses; $urlTemplate =~ s/HOST/$urlHost/; $urlTemplate =~ s/PORT/$urlPort/; @@ -66, +74 @@ @queries = `cat $querySource`; $size = @queries; - open OUT, ">$outputDir/$$.hammer"; + open OUT, ">$outputDir/$$.zot"; OUT->autoflush(1); for ($i = 0; $i < $queryCount; $i++) { $num = int(rand $size); $query = $queries[$num]; chomp $query; + $query = uri_escape($query) if $uriEscape; $url = $urlTemplate; $url =~ s/QUERY/$query/; @@ -81, +90 @@ if (defined $r and $r) { $elapsed = time() - $start; print OUT "$elapsed\n"; + if ($writeResponses) { - # open R, ">$outputDir/result/$$.$j"; + open R, ">$outputDir/result/$$.$j"; - # print R $r; + print R $r; - # close R; + close R; - # $j++; + $j++; + } } } close OUT; @@ -98, +109 @@ $stat = Statistics::Descriptive::Full->new(); foreach $i (keys %kids) { - open IN, "<$outputDir/$i.hammer"; + open IN, "<$outputDir/$i.zot"; while (<IN>) { chomp; $stat->add_data($_); @@ -107, +118 @@ } system "rm -f $outputDir/* 2> /dev/null" if length $outputDir; - #system "rm -f $outputDir/result/* 2> /dev/null" if length $outputDir; + system "rm -f $outputDir/result/* 2> /dev/null" if length $outputDir + and $writeResponses; printf " Req/s: %1.03f (%1.03f sec, requests %d/%d)\n" , $stat->count() / (time() - $veryStart) @@ -116, +128 @@ printf "Median: %1.03f\n", $stat->median(); printf " 95th: %1.03f\n", $stat->percentile(95); printf " 99th: %1.03f\n", $stat->percentile(99); + printf " Max: %1.03f\n", $stat->max(); print "\n"; exit 0; @@ -123, +136 @@ Sample output: {{{ - Req/s: 144.035 (28.188 sec, requests 4060/4096) + Req/s: 139.682 (29.302 sec, requests 4093/4096) - Avg: 0.052 + Avg: 0.055 - Median: 0.040 + Median: 0.046 - 95th: 0.131 + 95th: 0.119 - 99th: 0.237 + 99th: 0.210 + Max: 1.180 }}}
