Page MenuHomePhabricator
Paste P2509

parse_es_indices.php
ActivePublic

Authored by EBernhardson on Jan 21 2016, 8:10 PM.
Referenced Files
F3264790: parse_es_indices.php
Feb 24 2016, 5:27 AM
Subscribers
None
<?php
$indices = array();
while ( $line = fgets( STDIN ) ) {
$pieces = explode( ' ', preg_replace( '/ +/', ' ', $line ) );
$indices[$pieces[2]] = array(
'shards' => $pieces[3],
'replicas' => $pieces[4],
'size' => $pieces[8],
);
}
$GB = pow(2, 30);
$reduction = 0;
$totalShards = 0;
foreach ( $indices as $index => $data ) {
$totalShards += $data['shards'] * (1 + $data['replicas']);
if ( $data['shards'] == 1 ) {
continue;
}
if ( false === strpos( 'titlesuggest', $index ) ) {
$optimalShardSize = 2 * $GB;
} else {
$optimalShardSize = $GB / 2;
}
$optimalShardCount = ceil( $data['size'] / $optimalShardSize );
if ( $data['shards'] > $optimalShardCount ) {
$estSize = number_format( $data['size'] / $optimalShardCount / $GB, 2 );
echo "$index could be reduced to $optimalShardCount shards from ", $data['shards'],
" to achieve $estSize GB per shard\n";
$reduction += ($data['shards'] - $optimalShardCount) * (1+$data['replicas']);
}
}
$percentDiff = number_format( 100 * $reduction / $totalShards, 1 );
echo "\nCould reduce shard count across cluster by $reduction ({$percentDiff}%)\n";

Event Timeline

EBernhardson changed the title of this paste from untitled to parse_es_indices.php.Jan 21 2016, 8:10 PM
EBernhardson edited the content of this paste. (Show Details)
EBernhardson added a project: CirrusSearch.