Here, is the information I have received over chat
1)
Does mongod create 1 thread for all the collections with ttl index enabled or is it 1 per collection
MongoDB index creation is not Multi- Threaded .
You can try increasing the maxIndexBuildMemoryUsageMegabytes
parameter value.
The default value is 500 MB.
What does it do?
Limits the amount of memory that the simultaneous foreground index builds on one collection may consume for the duration of the builds.
So by increasing this limit, may increase the performance of index creation. For Example:
db.adminCommand( { setParameter: 1, maxIndexBuildMemoryUsageMegabytes: 70000 } )
2) What happens when the this thread created by mongod doesn't exit in 60 seconds, does a new thread gets created after 60 seconds, if yes, then I guess doesn't it mean that ttl based index should not be used for write heavy systems?
It looks like it will go beyond the 60seconds until it deletes the doc.
-
By Default, the TTLMonitor thread runs once in every 60 seconds. You can find out the sleep interval using following admin command.
||> db.adminCommand({getParameter:1, ttlMonitorSleepSecs: 1});
{ “ttlMonitorSleepSecs” : 60, “ok” : 1 }
To change this interval, supply another admin command with the desired interval:
||> db.adminCommand({setParameter:1, ttlMonitorSleepSecs: 3600}); // 1 hour
{ “was” : 60, “ok” : 1 }
Only for 4th Question I seek answer