-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Predictive Primary shard count by ISM and Index Management #1225
Comments
@aswath86 making any assumptions on the shards count can cause unpredictable issues. Additionally, if the cluster changes the shards' count every time it sees a spike we may cause a state of high shard count (which may cause instability and can't be undone). On the flip side - we may reduce shards due to little shipping but when the next spike arrives we would get a hotspot. I don't think this is a bad idea, but the approach you described is similar to one I tried as well, and there are many manual tweaks that need to be made. Some are done on a daily basis. A great way to avoid any of the issues you stated is to spread the shards on the total number of nodes. While this solves all those issues it creates another one - too many shards. if we were ok with that then there would be no problem to have a full spread on all the nodes. |
I'm with you on the "This only works if there is a pattern". And I'm not in favour of analyzing an index pattern over a period of time for various reasons (sales season, newly onboarded features producing more logging, etc.,), so analyzing over a period of time would be misleading. We should be only considering the ingestion volume for the last x hours of the data, where x is the HOT retention period. We could also look at last few hours (say 2 hours) ingestion volume, as a means to validate the outcome that is based on the x hours.
This FR is primarily for an ISM Action which is going to be completely optional, suitable for shorter retention period (eg., 24 hours, 30 hours etc.,) index patterns that has a surge in ingestion pattern for a period of time before the surge disappearing. For example, a sale season where the application starts producing more logs for few days in which case it is not practical to change the sharding strategy manually, each time. Generally, setting the shard count to a static value is not the ideal solution for a fluctuating ingestion rate. Changing the primary count each time there is a change is workload pattern is also not ideal.
Its usually is straight forward if a cluster has very fewer tenants (handful of index patterns) where all of them are either large volume or have a longer retention period. But this FR is for cases where there are too many tenants in the same cluster, each with varying index volume/size with fluctuating ignition rate. For instance, if you classify the index patterns by volume and you end up with high, medium and low volume indices, then during an surge, a low volume index would become a medium volume index, yet the sharding strategy is unchanged until manually updated. This FR aims to automat the sharding strategy according to the best practices.
This FR is primarily geared for multi-tenant cluster with shorter retention period and this Action is to be used in combination with shard size based rollover to prevent shards getting bigger than the ideal size. We could also provide a parameter to overwrite the primary count in case a particular index patter is experiencing significant surge which the OpenSearch Admin is aware of (says application is undergoing stress testing or performance benchmarking and hence is going to produce significantly more logs), in which case they could overwrite the primary count, or better yet, don't use this action. This feature was successfully implemented via a python script that runs every hour, which updates the primary count of the index for the sub-sequent rollover, on a large cluster that has 200 tenants with varying index volume that has fluctuating ingestion rate. This FR is to offer this feature natively with OpenSearch. |
We can/should also include guard rails that prevent large changes in primary count. Some change in primary count, with a limited scope, will be better than not adjusting the shard count. Again, it's an optional feature, that users will choose to use by adding to the policy. Some potential, user-settable parameters
+1 optional, and aimed at weekly/seasonal pattern changes. Without this feature, users have to change everything manually.
I wanted to echo @aswath86 comments here. Users with multi-tenant logging clusters have the most problems with these kinds of index size changes. Especially for people managing 10s or 100s of end user groups in a centralized IT department, this FR can bring a ton of value where they don't have to manually configure every change or reach out to their end users to figure out what's changing, whether it's permanent, and what is the ideal primary count. |
I don't doubt that. I manage many clusters each with thousands of tenants sending logging data (of varying sharding). And I have implemented features similar to what you are describing in the FR. as external services. The problem that arrises over time in many cases is that there start to be too many shards per node after increasing and decreasing several times, 24 hour retention is rare in logging. This leads to guard rails that make the feature ineffective to avoid manual tampering. I think my main point here is that the approach taken is external and not making use of information that you can get your hands on when writing code in the project - such as some metric for indexing pressure of a specific tenant. Another approach for ism could be a set of indices with various shard counts and when pressure goes up you shift the write alias and this way the transition is smooth and have fewer shards in the end since it isn't an "all or nothing" shards increase (can be one size up and only create a standby index for the next available size) then you can later reindex and merge small indices if needed. Bottom line is - i agree with the requirement for adjustment due to load changes, but the algorithm provided doesn't fit well enough to avoid many manual adjustments on-the-fly on high tenant clusters from my experience, and doesn't use the OpenSearch internals that are available to us when running within the node. |
@aswath86 I have a different approach to suggest: |
@aswath86 and I will meet in the next week or so and add a summary of our discussion over here. just so we can expedite the conversation - does anyone else wanna join the call? @Jon-AtAWS ? |
Thanks @AmiStrn I'd love to join! BTW,
Sounds like what we were thinking about, but maybe didn't say so clearly? Let's figure out the details. J- |
Great, the invite is still open if anyone else wants in:) It's probably going to happen this upcoming week. |
Added on Sep 3rd, 2024. This is also appended to the feature description aboveGoals
??? means undecided/unsure ISM — Mutating RolloverThis can either be an Action that is separate from existing Rollover Action which only determines the primary count and sets its at the index template OR an extension to the Rollover Action. Properties for the Actions would be,
Sample implementationTo calculate the ingestion volume for the last 30 hours. Consider all the indices of an Index pattern in
Estimating the ingestion rateGet the sum of primary store size of all the indices of an index pattern. The HOT retention period is already known (let’s assume ‘x’ hours is HOT retention period). Estimate the ingestion volume for the last x hours. Look at the sample implementation (above) for estimating the primary shard count
Validate the accuracy of the estimation
The worst that can happen
Incomplete section Challenges
Index Management — Create IndexThe Create Index page on the OSD can be suggest the primary shard count. Ask the user to input the following information so a primary shard can be suggested to them. They can choose the suggested sharding strategy or overwrite it manually. Goal is to guide the user to adopt the Sharding Strategy best practices. Side question: Do people really use this to create indices? :-) What can be done for indices created via
Quoting AOS best practices documentation — https://docs.aws.amazon.com/opensearch-service/latest/developerguide/sizing-domains.html#bp-storage
|
@aswath86 Thanks! can you add that to the feature description above? |
Thanks for the meeting @aswath86 @Jon-AtAWS and Robert (what is your github handle?) Summary:
|
Thanks all! One more quick thought from me... the feature should work in the data node count as part of the guardrails, and attempt to make changes that are congruent with that node count. This will also help with hot spots |
I am @486 - thanks again for the discussion @AmiStrn , looking forward to the next steps! |
Is your feature request related to a problem?
What solution would you like?
Long term solution - to have a predictive primary shard sizing for indices, adaptively applied, and considering resource utilization, workload, data stored, and other metrics from the fleet with ML for classification. More on this later.
First step towards the long term solution (solution for time-series workload) - An ISM policy driven
Action
, let's call it "Mutating Rollover", which looks at past x hours of ingestion rate (where x is the HOT retention period), takes into account the number of data nodes, predicts a suitable primary shard count for the next rollover index. The prediction may not be precise but at least better than having a static primary shard count for an index with fluctuating ingestion rate.Additional solution (solution for search workload) - Index Management allows to create an index. This page should ask for additional details such as,
1. Type of workload (search/timeseries/vector)
2. Expected primary storage size
3. Number of data nodes (should probably can be auto populated)
4. Multi-tenant domain domain or not
5. etc., etc.,
and suggest a primary shard count that the user can either choose or ignore and go with a manual value.
What alternatives have you considered?
Developed a python script which does looks at the past ingestion rate for an index to determine the suitable primary shard count for the index rollover. The script will run every 1 hour to update the index templates. This could be available out of the box as a "Mutating Rollover" Action in ISM. The python script does the below,
Do you have any additional context?
I can provide the python script (for the above mentioned alternative solution) if it helps but it's fairly straight forward.
Below added on Sep 3rd, 2024
Goals
??? means undecided/unsure
ISM — Mutating Rollover
This can either be an Action that is separate from existing Rollover Action which only determines the primary count and sets its at the index template OR an extension to the Rollover Action. Properties for the Actions would be,
_hot
estimation Vs. estimation based on current index Vs estimation based on last 1 hour, 2 hours, 3 hours etc., )Sample implementation
To calculate the ingestion volume for the last 30 hours. Consider all the indices of an Index pattern in
_hot
.Estimating the ingestion rate
Get the sum of primary store size of all the indices of an index pattern. The HOT retention period is already known (let’s assume ‘x’ hours is HOT retention period). Estimate the ingestion volume for the last x hours. Look at the sample implementation (above) for estimating the primary shard count
Validate the accuracy of the estimation
_count
of documents from the current index for the last 1 hour, 2 hours, 3 hours etc., — This type of validation may be misleading if there is an off-hour traffic. Instead of last 1 hour, 2 hours, 3 hours random one hour window can be used, says now-7, now-5, now-1 etc.,docs.count
,pri.store.size
of the current index_hot
estimation Vs. estimation based on current index Vs estimation based on last 1 hour, 2 hours, 3 hours etc.,pri.store.size
of the last rolled-over Index AND/OR last by one rolled-over Index for further analysis on ingestion rate deviationThe worst that can happen
Incomplete section
Challenges
_hot
is currently not a straightforward API call asGET _cat/indices/_hot/<<index_name>>
doesn’t work. This needs to be fixed first.Index Management — Create Index
The Create Index page on the OSD can be suggest the primary shard count. Ask the user to input the following information so a primary shard can be suggested to them. They can choose the suggested sharding strategy or overwrite it manually. Goal is to guide the user to adopt the Sharding Strategy best practices.
Side question: Do people really use this to create indices? :-) What can be done for indices created via
PUT <<index_name>>
. That should be the ultimate goalQuoting AOS best practices documentation — https://docs.aws.amazon.com/opensearch-service/latest/developerguide/sizing-domains.html#bp-storage
The text was updated successfully, but these errors were encountered: