-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Make snapshot deletion faster #61513
Comments
Pinging @elastic/es-distributed (:Distributed/Snapshot/Restore) |
Thanks for raising this @piyushdaftary The fact that we only execute this single-threaded really isn't all that optimal I agree and can lead to some very suboptimal situations as in your example. |
Thanks @original-brownbear . I will raise the PR with implementation of Approach1. |
The delete snapshot task takes longer than expected. A major reason for this is that the (often many) stale indices are deleted iteratively. In this commit we change the deletion to be concurrent using the SNAPSHOT threadpool. Notice that in order to avoid putting too many delete tasks on the threadpool queue a similar methodology was used as in `executeOneFileSnapshot()`. This is due to the fact that the threadpool should allow other tasks to use this threadpool without too much of a delay. fixes issue elastic#61513 from Elasticsearch project
The delete snapshot task takes longer than expected. A major reason for this is that the (often many) stale indices are deleted iteratively. In this commit we change the deletion to be concurrent using the SNAPSHOT threadpool. Notice that in order to avoid putting too many delete tasks on the threadpool queue a similar methodology was used as in `executeOneFileSnapshot()`. This is due to the fact that the threadpool should allow other tasks to use this threadpool without too much of a delay. fixes issue elastic#61513 from Elasticsearch project
Ugh, I suffer from this slowness so much right now, thanks for raising it! I have a snapshot repo to clean up of 3 years of snapshots every 2 hours and well so far it goes with a speed of 2 snapshots a day. |
After deleting a snapshot today we clean up all the now-dangling indices sequentially, which can be rather slow. With this commit we parallelize the work across the whole `SNAPSHOT` pool on the master node. Closes elastic#61513 Co-authored-by: Piyush Daftary <[email protected]>
Elasticsearch version (
bin/elasticsearch --version
): 7.6 onwardsJVM version (
java -version
): Java 14OS version (
uname -a
if on a Unix-like system): CentOsIn Elasticsearch, snapshot deletion is a multithreaded synchronous master node operation. The sequence of the delete operation goes as follows:
Current implementation of "step 9.2 : Delete stale indices" : cleanupStaleIndices() is very slow . Snapshot deletion code deletes each stale indices from repository one after another synchronously .
With current implementation we tried to measure time taken to delete a snapshot for a cluster with 3 masters of type r5.12xlarge and 50 data nodes of type i3.4xlarge with 1601 indices and 8001 shards and 4.8 TB data. IT takes approximately 31 minutes to delete such snapshot.
Current flow diagram of cleanupStaleIndices :
This step to cleanup stale indices can be speed up with either of the following approaches :
Suggested Optimizations
Approach1 :
Instead of making snapshot delete of stale indices a single threaded operation we make it multithreaded operation and delete multiple stale indices in parallel using SNAPSHOT thread pool's workers.
When deletion of all the stale indices are complete , we return back the DeleteResult as response of method cleanupStaleIndices()
With above Approach1 time taken to delete a snapshot for similar cluster with 3 masters of type r5.12xlarge and 50 data nodes of type i3.4xlarge with 1601 indices and 8001 shards and 4.8 TB data. IT takes approximately only 9.8 minutes to delete such snapshot.
I noted system resource utilizations such is CPU, system memory of master node. There was no major change in resource utilizations in Approach1 compared to Current implementation
Approach1 Optimization Vs Current Implementation comparison :
Approach1 Optimization flow diagram of cleanupStaleIndices :
Approach2 :
Instead of deleting snapshot stale indices synchronously, we can completely make the method cleanupStaleIndices() asynchronous . When method is invoked to delete list of stale indices, send back the response immediately and do the snapshot deletion of stale indices in background (Using SNAPSHOT threadpool workers ).
With above Approach2 time taken to delete a snapshot for similar cluster with 3 masters of type r5.12xlarge and 50 data nodes of type i3.4xlarge with 1601 indices and 8001 shards and 4.8 TB data. IT takes approximately only 8 seconds to delete such snapshot.
In Approach2 if because of master node failure, if deletion of stale indices fails , then these stale indices will be deleted in next snapshot deletion iteration , as these are stale indices and are not been referenced by any snapshots.
To track the progress of stale indices cleanup in background, a new status can be added in cluster state (Open for suggestion on how we can track the progress of stale indices cleanup)
**Approach2 Optimization flow diagram of cleanupStaleIndices : **
I want to take feedback from community on above 2 snapshot deletion optimization approaches before raising PR .
The text was updated successfully, but these errors were encountered: