Hi @Mia_Altieri and welcome to MongoDB community forums!!
Removing a shard from a sharding deployment is expected to take time from minutes to hours even to days and also depends on how the data have been distributed in the chunks on these shards.
Removing the shard from the deployment is however not a simple process. If the balancer is enabled in the configuration, as soon as you enter the remove shard command, the balancer will try to balance all the chunks in the available shards.
This also depends on how the shard key has been selected to make the event distribution between the chunks.
Please refer to the documentation to understand how to select the shard key in more detail.
Based on the above case I tried to replicate in my local environment and test the scenario.
I have around 20000 documents like:
[direct: mongos] test> db.sample.findOne()
{ _id: ObjectId("6548e52848f65c4016a4cea6"), name: 'Millie Curtis' }
[direct: mongos] test>
sharded on the name field. Since the name is unique, all the documents have moved to the same shard while other shards are still empty.
One I remove the shard, I see the balancer trying to balance the chunks between the shards
Below is the status after around 10 mins into removing of the shard process as begun:
chunkMetadata: [
{ shard: 'shard01', nChunks: 614 },
{ shard: 'shard02', nChunks: 218 },
{ shard: 'shard03', nChunks: 192 }
],
Perhaps this is due to other processes running in the background, which might be causing the slowdown.
Is the removing of shard a regular process? Could you clarify how often is the removal of the shard done?
Changing the shard key might be a way to make the process fast as the chunks would be more evenly distributed among all the shards and only a few number of chunks needs to be balanced rather than balancing one chunk between all the remaining available chunk.
Finally, can you confirm the shard where you are running this command?
Regards
Aasawari