Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P2509
parse_es_indices.php
Active
Public
Actions
Authored by
EBernhardson
on Jan 21 2016, 8:10 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
CirrusSearch
Referenced Files
F3264790: parse_es_indices.php
Feb 24 2016, 5:27 AM
2016-02-24 05:27:50 (UTC+0)
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
"
\n
Could 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
2016-01-21 20:10:12 (UTC+0)
EBernhardson
edited the content of this paste.
(Show Details)
EBernhardson
added a project:
CirrusSearch
.
EBernhardson
mentioned this in
T124332: Evaluate reducing shard counts for smaller wikis
.
Jan 21 2016, 8:16 PM
2016-01-21 20:16:22 (UTC+0)
Log In to Comment